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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd1171d528fb826e6f5a55aa69e3006fea9e08e3
4
- data.tar.gz: 800a0f43636d84a5bdf503d8ce7d10b17007f285
3
+ metadata.gz: 47ff0275d371bcd43598a2ab817a3bc4c78812e7
4
+ data.tar.gz: 0b78b699fa476b68f513a325739dea9dd02b359d
5
5
  SHA512:
6
- metadata.gz: 28b96cceda90b61e429e9c76a01d1034852ec0348ccb33e45c4d1bba8e8cf0b5e47e1d0eb89d732519cd2d55b797629481a11e237b2c0da7eb11718533bb794b
7
- data.tar.gz: 36e22aa23c8f08fb8c3731fce02fe9ef329f9db9c8fbb8702e0a4053f622b82286ff4959a025ee06c58a0eca9d0988264f11f15c7bf601bc5038874f287d0eaf
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 | Lead data are not immutable so it better to do incremental ingesting with `updateAt` column, but not all Marketo Account have the feature to filter by updatedAt |
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
@@ -16,7 +16,7 @@ repositories {
16
16
  configurations {
17
17
  provided
18
18
  }
19
- version = "0.6.3"
19
+ version = "0.6.4.alpha.1"
20
20
  sourceCompatibility = 1.7
21
21
  targetCompatibility = 1.7
22
22
 
@@ -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 = waitTime + (System.currentTimeMillis() - now);
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 = "updatedAt";
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(1504888753000L, latestFetchTime);
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
  }
@@ -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, 1, 4);
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(3)).doGet(Mockito.eq(END_POINT + MarketoRESTEndpoint.GET_LEAD_EXPORT_STATUS.getEndpoint(pathParams)), Mockito.isNull(Map.class), Mockito.isNull(ImmutableListMultimap.class), Mockito.any(MarketoResponseJetty92EntityReader.class));
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();
@@ -5,4 +5,4 @@ client_secret: client_secret
5
5
  fetch_days: "60"
6
6
  escape: "\""
7
7
  incremental: true
8
- use_updated_at: true
8
+ use_updated_at: false
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.3
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-11-13 00:00:00.000000000 Z
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: '0'
150
+ version: 1.3.1
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 2.1.9