embulk-input-marketo 0.6.7 → 0.6.8.alpha1

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: af6c681344d0710a3803c198298732c5fe271140
4
- data.tar.gz: 3816444d0f15f51aab2efffd6f1c6637c09833a1
3
+ metadata.gz: d23d2cfa89b67071f75d5972006bfc13723f4879
4
+ data.tar.gz: a23b0cc19c7e884d9e75126319e718244e7e7905
5
5
  SHA512:
6
- metadata.gz: 37719bf91a9f4a1ba5456770cb7a6ec92036e6854bfa02224ee87ad4d853dfd57e6d541a2e002f4832c0865ebaa26c000b745d0612357cc64d9f59a7c83630bf
7
- data.tar.gz: 911428dc09e0b2a61ffd708bc3ab613f106b4dd53ca54f99a293d9a1c9c28c42061949b3c97c4697da3a4de02b23954d4dcafcacc3286fe4c6280c55c0433b7e
6
+ metadata.gz: 266e3cbbf8e3ee5bbe289fdb4b4327b6b6da510ca9bd09514f0e2b698ed25462fa13e297741f46804cd478eaf9f36cc09bd38a7de62ab17ced20ba4af7006a22
7
+ data.tar.gz: d65566dbe869de9925df1055acfc7dfe7997e170222737e3f5953c77020f6e409d99a5ea5be727837878372d5b65f7be47c676b291266990aff92a271d8e8943
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.6.7 - 2018-02-26
2
+ * [fixed] Remove de-duplication logic [#83](https://github.com/treasure-data/embulk-input-marketo/pull/83)
3
+
1
4
  ## 0.6.6 - 2018-01-30
2
5
  * [fixed] Fix JettyRetryHelper not closed [#82](https://github.com/treasure-data/embulk-input-marketo/pull/82)
3
6
 
data/build.gradle CHANGED
@@ -16,7 +16,7 @@ repositories {
16
16
  configurations {
17
17
  provided
18
18
  }
19
- version = "0.6.7"
19
+ version = "0.6.8.alpha1"
20
20
  sourceCompatibility = 1.7
21
21
  targetCompatibility = 1.7
22
22
 
@@ -43,12 +43,13 @@ checkstyle {
43
43
  toolVersion = '6.14.1'
44
44
  }
45
45
  checkstyleMain {
46
+ exclude '**/**/CsvTokenizer*'
46
47
  configFile = file("${project.rootDir}/config/checkstyle/default.xml")
47
- ignoreFailures = true
48
+ ignoreFailures = false
48
49
  }
49
50
  checkstyleTest {
50
51
  configFile = file("${project.rootDir}/config/checkstyle/default.xml")
51
- ignoreFailures = true
52
+ ignoreFailures = false
52
53
  }
53
54
  task checkstyle(type: Checkstyle) {
54
55
  classpath = sourceSets.main.output + sourceSets.test.output
@@ -112,6 +112,15 @@ public class MarketoBaseRestClient implements AutoCloseable
112
112
  {
113
113
  return response.getStatus() == 502;
114
114
  }
115
+
116
+ @Override
117
+ protected boolean isExceptionToRetry(Exception exception)
118
+ {
119
+ if (exception instanceof ExecutionException) {
120
+ return this.toRetry((Exception) exception.getCause());
121
+ }
122
+ return exception instanceof TimeoutException || exception instanceof SocketTimeoutException || exception instanceof EOFException || super.isExceptionToRetry(exception);
123
+ }
115
124
  });
116
125
 
117
126
  MarketoAccessTokenResponse accessTokenResponse;
@@ -189,11 +198,7 @@ public class MarketoBaseRestClient implements AutoCloseable
189
198
  protected boolean isExceptionToRetry(Exception exception)
190
199
  {
191
200
  if (exception instanceof ExecutionException) {
192
- this.toRetry((Exception) exception.getCause());
193
- }
194
- //Anything that is EOFException or cause by EOF exception
195
- if (exception instanceof EOFException || exception.getCause() instanceof EOFException) {
196
- return true;
201
+ return this.toRetry((Exception) exception.getCause());
197
202
  }
198
203
  if (exception instanceof MarketoAPIException) {
199
204
  //Retry Authenticate Exception
@@ -201,6 +206,7 @@ public class MarketoBaseRestClient implements AutoCloseable
201
206
  String code = error.getCode();
202
207
  switch (code) {
203
208
  case "602":
209
+ case "601":
204
210
  LOGGER.info("Access token expired");
205
211
  renewAccessToken();
206
212
  return true;
@@ -219,7 +225,7 @@ public class MarketoBaseRestClient implements AutoCloseable
219
225
  return false;
220
226
  }
221
227
  }
222
- return exception instanceof TimeoutException || exception instanceof SocketTimeoutException || super.isExceptionToRetry(exception);
228
+ return exception instanceof EOFException || exception instanceof TimeoutException || exception instanceof SocketTimeoutException || super.isExceptionToRetry(exception);
223
229
  }
224
230
  });
225
231
  }
@@ -26,9 +26,13 @@ import org.junit.Test;
26
26
  import org.mockito.ArgumentCaptor;
27
27
  import org.mockito.Mockito;
28
28
 
29
+ import java.io.EOFException;
30
+ import java.net.SocketTimeoutException;
29
31
  import java.nio.charset.StandardCharsets;
30
32
  import java.util.HashMap;
31
33
  import java.util.Map;
34
+ import java.util.concurrent.ExecutionException;
35
+ import java.util.concurrent.TimeoutException;
32
36
 
33
37
  /**
34
38
  * Created by tai.khuu on 9/21/17.
@@ -72,18 +76,25 @@ public class MarketoBaseRestClientTest
72
76
  Mockito.when(mockJetty92.requestWithRetry(Mockito.any(StringJetty92ResponseEntityReader.class), jetty92SingleRequesterArgumentCaptor.capture())).thenReturn("{\"access_token\": \"access_token\"}");
73
77
  String accessToken = marketoBaseRestClient.getAccessToken();
74
78
  Assert.assertEquals("access_token", accessToken);
75
- Jetty92SingleRequester value = jetty92SingleRequesterArgumentCaptor.getValue();
79
+ Jetty92SingleRequester jetty92SingleRequester = jetty92SingleRequesterArgumentCaptor.getValue();
76
80
  HttpClient client = Mockito.mock(HttpClient.class);
77
81
  Response.Listener listener = Mockito.mock(Response.Listener.class);
78
82
  Request mockRequest = Mockito.mock(Request.class);
79
83
  Mockito.when(client.newRequest(Mockito.eq(IDENTITY_END_POINT + MarketoRESTEndpoint.ACCESS_TOKEN.getEndpoint()))).thenReturn(mockRequest);
80
84
  Request request1 = Mockito.mock(Request.class);
81
85
  Mockito.when(mockRequest.method(Mockito.eq(HttpMethod.GET))).thenReturn(request1);
82
- value.requestOnce(client, listener);
86
+ jetty92SingleRequester.requestOnce(client, listener);
83
87
  Mockito.verify(request1, Mockito.times(1)).param(Mockito.eq("client_id"), Mockito.eq("clientId"));
84
88
  Mockito.verify(request1, Mockito.times(1)).param(Mockito.eq("client_secret"), Mockito.eq("clientSecret"));
85
89
  Mockito.verify(request1, Mockito.times(1)).param(Mockito.eq("grant_type"), Mockito.eq("client_credentials"));
86
- Assert.assertTrue(value.toRetry(createHttpResponseException(502)));
90
+ Assert.assertTrue(jetty92SingleRequester.toRetry(createHttpResponseException(502)));
91
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new ExecutionException(new TimeoutException())));
92
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new ExecutionException(new EOFException())));
93
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new ExecutionException(new SocketTimeoutException())));
94
+ // Retry SocketTimeoutException, TimeoutException and EOFException
95
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new SocketTimeoutException()));
96
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new TimeoutException()));
97
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new EOFException()));
87
98
  }
88
99
  @Test
89
100
  public void testGetAccessTokenWithError()
@@ -184,8 +195,18 @@ public class MarketoBaseRestClientTest
184
195
  Assert.assertTrue(jetty92SingleRequester.toRetry(createMarketoAPIException("606", "")));
185
196
  Assert.assertTrue(jetty92SingleRequester.toRetry(createMarketoAPIException("615", "")));
186
197
  Assert.assertTrue(jetty92SingleRequester.toRetry(createMarketoAPIException("602", "")));
187
-
188
- Mockito.verify(mockJetty92, Mockito.times(2)).requestWithRetry(Mockito.any(StringJetty92ResponseEntityReader.class), Mockito.any(Jetty92SingleRequester.class));
198
+ // Should retry 601 error too
199
+ Assert.assertTrue(jetty92SingleRequester.toRetry(createMarketoAPIException("601", "")));
200
+ // Retry wrap SocketTimeoutException, TimeoutException and EOFException
201
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new ExecutionException(new TimeoutException())));
202
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new ExecutionException(new EOFException())));
203
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new ExecutionException(new SocketTimeoutException())));
204
+ // Retry SocketTimeoutException, TimeoutException and EOFException
205
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new SocketTimeoutException()));
206
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new TimeoutException()));
207
+ Assert.assertTrue(jetty92SingleRequester.toRetry(new EOFException()));
208
+ // Call 3 times First call then 602 error and 601 error
209
+ Mockito.verify(mockJetty92, Mockito.times(3)).requestWithRetry(Mockito.any(StringJetty92ResponseEntityReader.class), Mockito.any(Jetty92SingleRequester.class));
189
210
  }
190
211
 
191
212
  private HttpResponseException createHttpResponseException(int statusCode)
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.7
4
+ version: 0.6.8.alpha1
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: 2018-02-26 00:00:00.000000000 Z
13
+ date: 2018-03-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  requirement: !ruby/object:Gem::Requirement
@@ -94,7 +94,6 @@ files:
94
94
  - src/main/java/org/embulk/input/marketo/rest/RecordPagingIterable.java
95
95
  - src/test/java/org/embulk/input/marketo/MarketoServiceImplTest.java
96
96
  - src/test/java/org/embulk/input/marketo/MarketoUtilsTest.java
97
- - src/test/java/org/embulk/input/marketo/TestMarketoInputPlugin.java
98
97
  - src/test/java/org/embulk/input/marketo/delegate/ActivityBulkExtractInputPluginTest.java
99
98
  - src/test/java/org/embulk/input/marketo/delegate/CampaignInputPluginTest.java
100
99
  - src/test/java/org/embulk/input/marketo/delegate/LeadBulkExtractInputPluginTest.java
@@ -125,9 +124,9 @@ files:
125
124
  - src/test/resources/fixtures/program_response.json
126
125
  - classpath/jetty-http-9.2.14.v20151106.jar
127
126
  - classpath/embulk-base-restclient-0.5.3.jar
127
+ - classpath/embulk-input-marketo-0.6.8.alpha1.jar
128
128
  - classpath/jetty-client-9.2.14.v20151106.jar
129
129
  - classpath/jetty-util-9.2.14.v20151106.jar
130
- - classpath/embulk-input-marketo-0.6.7.jar
131
130
  - classpath/embulk-util-retryhelper-jetty92-0.5.3.jar
132
131
  - classpath/jetty-io-9.2.14.v20151106.jar
133
132
  homepage: https://github.com/treasure-data/embulk-input-marketo
@@ -145,9 +144,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
144
  version: '0'
146
145
  required_rubygems_version: !ruby/object:Gem::Requirement
147
146
  requirements:
148
- - - '>='
147
+ - - '>'
149
148
  - !ruby/object:Gem::Version
150
- version: '0'
149
+ version: 1.3.1
151
150
  requirements: []
152
151
  rubyforge_project:
153
152
  rubygems_version: 2.1.9
@@ -1,5 +0,0 @@
1
- package org.embulk.input.marketo;
2
-
3
- public class TestMarketoInputPlugin
4
- {
5
- }