embulk-input-marketo 0.6.3 → 0.6.4.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/build.gradle +1 -1
- data/src/main/java/org/embulk/input/marketo/delegate/MarketoBaseBulkExtractInputPlugin.java +5 -0
- data/src/main/java/org/embulk/input/marketo/rest/MarketoRestClient.java +2 -1
- data/src/test/java/org/embulk/input/marketo/delegate/LeadBulkExtractInputPluginTest.java +2 -2
- data/src/test/java/org/embulk/input/marketo/delegate/MarketoBaseBulkExtractInputPluginTest.java +45 -1
- data/src/test/java/org/embulk/input/marketo/rest/MarketoRestClientTest.java +2 -3
- data/src/test/resources/config/lead_bulk_extract_config.yaml +1 -1
- metadata +5 -5
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 47ff0275d371bcd43598a2ab817a3bc4c78812e7
         | 
| 4 | 
            +
              data.tar.gz: 0b78b699fa476b68f513a325739dea9dd02b359d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 7e893d80d51a2dc629ff237e00459587b72b39ae09e95c967e7f6ebf01eed1e9706ce6afd18470d160ac4c76188a5c1bb1e194c7684b443672af8281b72a8d45
         | 
| 7 | 
            +
              data.tar.gz: f4bf3162dc79643f725a722e0ab853a2ff7b709c30cd648b581bf62b4d11339fbfd59bcdee578608e77c5e3d21e51cfd1a6053650b9de0722ca04a689ef1b2fa
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,3 +1,9 @@ | |
| 1 | 
            +
            ## 0.6.4 - 2017-12-13
         | 
| 2 | 
            +
            * [fixed] Fix incorrect job timeout calculation  [#78](https://github.com/treasure-data/embulk-input-marketo/pull/78)
         | 
| 3 | 
            +
            * [enhance] Disable incremental import by updatedAt  [#77](https://github.com/treasure-data/embulk-input-marketo/pull/77)
         | 
| 4 | 
            +
            * [enhance] Add log for exported file size  [#76](https://github.com/treasure-data/embulk-input-marketo/pull/76)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
             | 
| 1 7 | 
             
            ## 0.6.3 - 2017-11-13
         | 
| 2 8 | 
             
            * [enhance] Ignore records with timestamp smaller or equal to latest_fetch_time  [#74](https://github.com/treasure-data/embulk-input-marketo/pull/74)
         | 
| 3 9 |  | 
    
        data/README.md
    CHANGED
    
    | @@ -73,7 +73,7 @@ Configuration: | |
| 73 73 |  | 
| 74 74 | 
             
            | name               | required | default value | description                                                                                                                                                      |
         | 
| 75 75 | 
             
            |--------------------|----------|---------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------|
         | 
| 76 | 
            -
            | **use_updated_at** | false    | false | 
| 76 | 
            +
            | **use_updated_at** | false    | false       | Support filter with `updateAt` column, but not all Marketo Account have the feature to filter by updatedAt, updatedAt don't support incremental ingestion        |
         | 
| 77 77 |  | 
| 78 78 | 
             
            Schema type: Dynamic via describe lead endpoint.
         | 
| 79 79 |  | 
    
        data/build.gradle
    CHANGED
    
    
| @@ -127,6 +127,11 @@ public abstract class MarketoBaseBulkExtractInputPlugin<T extends MarketoBaseBul | |
| 127 127 | 
             
                    if (task.getFromDate().getTime() >= task.getJobStartTime().getMillis()) {
         | 
| 128 128 | 
             
                        throw new ConfigException("From date can't not be in future");
         | 
| 129 129 | 
             
                    }
         | 
| 130 | 
            +
                    if (task.getIncremental()
         | 
| 131 | 
            +
                            && task.getIncrementalColumn().isPresent()
         | 
| 132 | 
            +
                            && task.getIncrementalColumn().get().equals("updatedAt")) {
         | 
| 133 | 
            +
                        throw new ConfigException("Column 'updatedAt' cannot be incremental imported");
         | 
| 134 | 
            +
                    }
         | 
| 130 135 | 
             
                    //Calculate to date
         | 
| 131 136 | 
             
                    DateTime toDate = getToDate(task);
         | 
| 132 137 | 
             
                    task.setToDate(Optional.of(toDate.toDate()));
         | 
| @@ -256,6 +256,7 @@ public class MarketoRestClient extends MarketoBaseRestClient | |
| 256 256 | 
             
                            switch (status) {
         | 
| 257 257 | 
             
                                case "Completed":
         | 
| 258 258 | 
             
                                    LOGGER.info("Total wait time ms is [{}]", waitTime);
         | 
| 259 | 
            +
                                    LOGGER.info("File size is [{}] bytes", objectNode.get("fileSize"));
         | 
| 259 260 | 
             
                                    return;
         | 
| 260 261 | 
             
                                case "Failed":
         | 
| 261 262 | 
             
                                    throw new DataException("Bulk extract job failed exportId: " + exportId + " errorMessage: " + objectNode.get("errorMsg").asText());
         | 
| @@ -264,7 +265,7 @@ public class MarketoRestClient extends MarketoBaseRestClient | |
| 264 265 | 
             
                            }
         | 
| 265 266 | 
             
                        }
         | 
| 266 267 | 
             
                        Thread.sleep(pollingInterval * 1000);
         | 
| 267 | 
            -
                        waitTime =  | 
| 268 | 
            +
                        waitTime = System.currentTimeMillis() - now;
         | 
| 268 269 | 
             
                        if (waitTime >= waitTimeoutMs) {
         | 
| 269 270 | 
             
                            throw new DataException("Job timeout exception, exportJob: " + exportId + ", run longer than " + waitTimeout + " seconds");
         | 
| 270 271 | 
             
                        }
         | 
| @@ -81,7 +81,7 @@ public class LeadBulkExtractInputPluginTest | |
| 81 81 | 
             
                    Mockito.verify(mockMarketoRestclient, Mockito.times(1)).waitLeadExportJobComplete(eq(exportId1), eq(task.getPollingIntervalSecond()), eq(task.getBulkJobTimeoutSecond()));
         | 
| 82 82 | 
             
                    Mockito.verify(mockMarketoRestclient, Mockito.times(1)).startLeadBulkExtract(eq(exportId2));
         | 
| 83 83 | 
             
                    Mockito.verify(mockMarketoRestclient, Mockito.times(1)).waitLeadExportJobComplete(eq(exportId2), eq(task.getPollingIntervalSecond()), eq(task.getBulkJobTimeoutSecond()));
         | 
| 84 | 
            -
                    String filterField = " | 
| 84 | 
            +
                    String filterField = "createdAt";
         | 
| 85 85 | 
             
                    Mockito.verify(mockMarketoRestclient, Mockito.times(1)).createLeadBulkExtract(startDate.toDate(), startDate.plusDays(30).toDate(), fieldNameFromMarketoFields, filterField);
         | 
| 86 86 | 
             
                    DateTime startDate2 = startDate.plusDays(30).plusSeconds(1);
         | 
| 87 87 | 
             
                    Mockito.verify(mockMarketoRestclient, Mockito.times(1)).createLeadBulkExtract(startDate2.toDate(), startDate.plusDays(task.getFetchDays()).toDate(), fieldNameFromMarketoFields, filterField);
         | 
| @@ -89,7 +89,7 @@ public class LeadBulkExtractInputPluginTest | |
| 89 89 | 
             
                    Assert.assertEquals(19, leadIds.size());
         | 
| 90 90 | 
             
                    long latestFetchTime = taskReport.get(Long.class, "latest_fetch_time");
         | 
| 91 91 | 
             
                    Assert.assertTrue(taskReport.get(Set.class, "latest_uids").isEmpty());
         | 
| 92 | 
            -
                    Assert.assertEquals( | 
| 92 | 
            +
                    Assert.assertEquals(1504888754000L, latestFetchTime);
         | 
| 93 93 | 
             
                    Assert.assertArrayEquals(new Long[]{102488L, 102456L, 102445L, 102439L, 102471L, 102503L, 102424L, 102473L, 102505L, 102492L, 102495L, 102452L, 102435L, 102467L, 102420L, 102496L, 102448L, 102499L, 102431L}, leadIds.toArray());
         | 
| 94 94 | 
             
                }
         | 
| 95 95 | 
             
            }
         | 
    
        data/src/test/java/org/embulk/input/marketo/delegate/MarketoBaseBulkExtractInputPluginTest.java
    CHANGED
    
    | @@ -5,6 +5,8 @@ import com.google.common.collect.Sets; | |
| 5 5 | 
             
            import org.embulk.EmbulkTestRuntime;
         | 
| 6 6 | 
             
            import org.embulk.config.ConfigDiff;
         | 
| 7 7 | 
             
            import org.embulk.config.ConfigException;
         | 
| 8 | 
            +
            import org.embulk.config.ConfigLoader;
         | 
| 9 | 
            +
            import org.embulk.config.ConfigSource;
         | 
| 8 10 | 
             
            import org.embulk.config.TaskReport;
         | 
| 9 11 | 
             
            import org.embulk.input.marketo.MarketoInputPluginDelegate;
         | 
| 10 12 | 
             
            import org.embulk.input.marketo.MarketoUtils;
         | 
| @@ -16,6 +18,7 @@ import org.junit.Test; | |
| 16 18 | 
             
            import org.mockito.ArgumentCaptor;
         | 
| 17 19 | 
             
            import org.mockito.Mockito;
         | 
| 18 20 |  | 
| 21 | 
            +
            import java.io.IOException;
         | 
| 19 22 | 
             
            import java.text.DateFormat;
         | 
| 20 23 | 
             
            import java.text.SimpleDateFormat;
         | 
| 21 24 | 
             
            import java.util.Arrays;
         | 
| @@ -24,6 +27,9 @@ import java.util.Set; | |
| 24 27 |  | 
| 25 28 | 
             
            import static org.junit.Assert.assertEquals;
         | 
| 26 29 | 
             
            import static org.junit.Assert.fail;
         | 
| 30 | 
            +
            import static org.mockito.AdditionalAnswers.delegatesTo;
         | 
| 31 | 
            +
            import static org.mockito.Mockito.mock;
         | 
| 32 | 
            +
            import static org.mockito.Mockito.when;
         | 
| 27 33 |  | 
| 28 34 | 
             
            /**
         | 
| 29 35 | 
             
             * Created by khuutantaitai on 10/3/17.
         | 
| @@ -34,11 +40,16 @@ public class MarketoBaseBulkExtractInputPluginTest | |
| 34 40 | 
             
                public EmbulkTestRuntime embulkTestRuntime = new EmbulkTestRuntime();
         | 
| 35 41 |  | 
| 36 42 | 
             
                private MarketoBaseBulkExtractInputPlugin<MarketoBaseBulkExtractInputPlugin.PluginTask> baseBulkExtractInputPlugin;
         | 
| 43 | 
            +
                private MarketoBaseBulkExtractInputPlugin.PluginTask validBaseTask;
         | 
| 37 44 |  | 
| 38 45 | 
             
                @Before
         | 
| 39 | 
            -
                public void prepare()
         | 
| 46 | 
            +
                public void prepare() throws IOException
         | 
| 40 47 | 
             
                {
         | 
| 41 48 | 
             
                    baseBulkExtractInputPlugin = Mockito.mock(MarketoBaseBulkExtractInputPlugin.class, Mockito.CALLS_REAL_METHODS);
         | 
| 49 | 
            +
                    ConfigLoader configLoader = embulkTestRuntime.getInjector().getInstance(ConfigLoader.class);
         | 
| 50 | 
            +
                    ConfigSource configSource = configLoader.fromYaml(
         | 
| 51 | 
            +
                            this.getClass().getResourceAsStream("/config/activity_bulk_extract_config.yaml"));
         | 
| 52 | 
            +
                    validBaseTask = configSource.loadConfig(MarketoBaseBulkExtractInputPlugin.PluginTask.class);
         | 
| 42 53 | 
             
                }
         | 
| 43 54 |  | 
| 44 55 | 
             
                @Test(expected = ConfigException.class)
         | 
| @@ -49,6 +60,39 @@ public class MarketoBaseBulkExtractInputPluginTest | |
| 49 60 | 
             
                    baseBulkExtractInputPlugin.validateInputTask(pluginTask);
         | 
| 50 61 | 
             
                }
         | 
| 51 62 |  | 
| 63 | 
            +
                @Test(expected = ConfigException.class)
         | 
| 64 | 
            +
                public void invalidInputTaskWhenIncrementalByUpdatedAt()
         | 
| 65 | 
            +
                {
         | 
| 66 | 
            +
                    MarketoBaseBulkExtractInputPlugin.PluginTask task = mock(
         | 
| 67 | 
            +
                            MarketoBaseBulkExtractInputPlugin.PluginTask.class,
         | 
| 68 | 
            +
                            delegatesTo(validBaseTask));
         | 
| 69 | 
            +
                    when(task.getIncrementalColumn()).thenReturn(Optional.of("updatedAt"));
         | 
| 70 | 
            +
                    when(task.getIncremental()).thenReturn(true);
         | 
| 71 | 
            +
                    baseBulkExtractInputPlugin.validateInputTask(task);
         | 
| 72 | 
            +
                }
         | 
| 73 | 
            +
             | 
| 74 | 
            +
                @Test
         | 
| 75 | 
            +
                public void validInputTaskWhenIncrementalOtherThanUpdatedAt()
         | 
| 76 | 
            +
                {
         | 
| 77 | 
            +
                    MarketoBaseBulkExtractInputPlugin.PluginTask task = mock(
         | 
| 78 | 
            +
                            MarketoBaseBulkExtractInputPlugin.PluginTask.class,
         | 
| 79 | 
            +
                            delegatesTo(validBaseTask));
         | 
| 80 | 
            +
                    when(task.getIncremental()).thenReturn(true);
         | 
| 81 | 
            +
                    when(task.getIncrementalColumn()).thenReturn(Optional.of("anythingButUpdatedAt"));
         | 
| 82 | 
            +
                    baseBulkExtractInputPlugin.validateInputTask(task);  // should not throw
         | 
| 83 | 
            +
                }
         | 
| 84 | 
            +
             | 
| 85 | 
            +
                @Test
         | 
| 86 | 
            +
                public void validInputTaskWhenNonIncrementalWhileSetUpdatedAt()
         | 
| 87 | 
            +
                {
         | 
| 88 | 
            +
                    MarketoBaseBulkExtractInputPlugin.PluginTask task = mock(
         | 
| 89 | 
            +
                            MarketoBaseBulkExtractInputPlugin.PluginTask.class,
         | 
| 90 | 
            +
                            delegatesTo(validBaseTask));
         | 
| 91 | 
            +
                    when(task.getIncremental()).thenReturn(false);
         | 
| 92 | 
            +
                    when(task.getIncrementalColumn()).thenReturn(Optional.of("updatedAt"));
         | 
| 93 | 
            +
                    baseBulkExtractInputPlugin.validateInputTask(task);  // should not throw
         | 
| 94 | 
            +
                }
         | 
| 95 | 
            +
             | 
| 52 96 | 
             
                @Test()
         | 
| 53 97 | 
             
                public void validateInputTaskToDateLessThanJobStartTime()
         | 
| 54 98 | 
             
                {
         | 
| @@ -1,6 +1,5 @@ | |
| 1 1 | 
             
            package org.embulk.input.marketo.rest;
         | 
| 2 2 |  | 
| 3 | 
            -
            import com.fasterxml.jackson.core.JsonProcessingException;
         | 
| 4 3 | 
             
            import com.fasterxml.jackson.databind.DeserializationFeature;
         | 
| 5 4 | 
             
            import com.fasterxml.jackson.databind.JavaType;
         | 
| 6 5 | 
             
            import com.fasterxml.jackson.databind.ObjectMapper;
         | 
| @@ -237,11 +236,11 @@ public class MarketoRestClientTest | |
| 237 236 | 
             
                    Mockito.when(result.get("status")).thenReturn(new TextNode("Queued")).thenReturn(new TextNode("Processing"));
         | 
| 238 237 | 
             
                    Mockito.doReturn(marketoResponse).when(marketoRestClient).doGet(Mockito.eq(END_POINT + MarketoRESTEndpoint.GET_LEAD_EXPORT_STATUS.getEndpoint(pathParams)), Mockito.isNull(Map.class), Mockito.isNull(ImmutableListMultimap.class), Mockito.any(MarketoResponseJetty92EntityReader.class));
         | 
| 239 238 | 
             
                    try {
         | 
| 240 | 
            -
                        marketoRestClient.waitLeadExportJobComplete(bulkExportId,  | 
| 239 | 
            +
                        marketoRestClient.waitLeadExportJobComplete(bulkExportId, 2, 4);
         | 
| 241 240 | 
             
                    }
         | 
| 242 241 | 
             
                    catch (DataException e) {
         | 
| 243 242 | 
             
                        Assert.assertTrue(e.getMessage().contains("Job timeout exception"));
         | 
| 244 | 
            -
                        Mockito.verify(marketoRestClient, Mockito.times( | 
| 243 | 
            +
                        Mockito.verify(marketoRestClient, Mockito.times(2)).doGet(Mockito.eq(END_POINT + MarketoRESTEndpoint.GET_LEAD_EXPORT_STATUS.getEndpoint(pathParams)), Mockito.isNull(Map.class), Mockito.isNull(ImmutableListMultimap.class), Mockito.any(MarketoResponseJetty92EntityReader.class));
         | 
| 245 244 | 
             
                        return;
         | 
| 246 245 | 
             
                    }
         | 
| 247 246 | 
             
                    Assert.fail();
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: embulk-input-marketo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.6. | 
| 4 | 
            +
              version: 0.6.4.alpha.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - uu59
         | 
| @@ -10,7 +10,7 @@ authors: | |
| 10 10 | 
             
            autorequire:
         | 
| 11 11 | 
             
            bindir: bin
         | 
| 12 12 | 
             
            cert_chain: []
         | 
| 13 | 
            -
            date: 2017- | 
| 13 | 
            +
            date: 2017-12-13 00:00:00.000000000 Z
         | 
| 14 14 | 
             
            dependencies:
         | 
| 15 15 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 16 16 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -125,8 +125,8 @@ files: | |
| 125 125 | 
             
            - src/test/resources/fixtures/program_response.json
         | 
| 126 126 | 
             
            - classpath/jetty-http-9.2.14.v20151106.jar
         | 
| 127 127 | 
             
            - classpath/embulk-base-restclient-0.5.3.jar
         | 
| 128 | 
            +
            - classpath/embulk-input-marketo-0.6.4.alpha.1.jar
         | 
| 128 129 | 
             
            - classpath/jetty-client-9.2.14.v20151106.jar
         | 
| 129 | 
            -
            - classpath/embulk-input-marketo-0.6.3.jar
         | 
| 130 130 | 
             
            - classpath/jetty-util-9.2.14.v20151106.jar
         | 
| 131 131 | 
             
            - classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
         | 
| 132 132 | 
             
            - classpath/jetty-io-9.2.14.v20151106.jar
         | 
| @@ -145,9 +145,9 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 145 145 | 
             
                  version: '0'
         | 
| 146 146 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 147 147 | 
             
              requirements:
         | 
| 148 | 
            -
              - - ' | 
| 148 | 
            +
              - - '>'
         | 
| 149 149 | 
             
                - !ruby/object:Gem::Version
         | 
| 150 | 
            -
                  version:  | 
| 150 | 
            +
                  version: 1.3.1
         | 
| 151 151 | 
             
            requirements: []
         | 
| 152 152 | 
             
            rubyforge_project:
         | 
| 153 153 | 
             
            rubygems_version: 2.1.9
         |