embulk-input-gcs 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 219d292e87e6a2b326144302280e10bba7e3ea2a
4
- data.tar.gz: c7e6e1933bc1961e16f18c68022261e1948cd5bc
3
+ metadata.gz: d25891998dc1d0794b0fcfac04ea7a011f777f9c
4
+ data.tar.gz: cd7d9977e6bfa8df5212181ba49aaacf7998110b
5
5
  SHA512:
6
- metadata.gz: e09e566db719125bc872a33026c4dd15bb1b29bf3ad82ce75a5cdd1fc5c342e2c8c72179accd3b9fafecf8ca3945dd26c0e1cdc70036d3a82d509485c388e925
7
- data.tar.gz: aa068f8ac05d9fafec71baa24d71f18b59096521277ce836a5b27c1f1c491d4aee8ffe004d71117d5d6d68482e6525071fbcb2da4f3ca30601c638582cf7d260
6
+ metadata.gz: 9beb8bfab93341c05b076fb1937096cb86ab850da685806cd1aa29cf65ffea356e318bfdddc566321499e4ffa8b5ccac9c8028b0dd83aa20f29a6955c8556e9a
7
+ data.tar.gz: d3f872c0dd1460e5234b836761fbd7ea5f723b17371d881e4a91989b62edd10cfa98a0110eb26af5940c684a318164b1448f0ccd73962bc5db126b5c60070e8b
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Release 0.1.9 - 2015-10-30
2
+
3
+ Fix GcsAuthentication object initialization for mapreduce executor. @muga thanks!
4
+
1
5
  Release 0.1.8 - 2015-10-29
2
6
 
3
7
  * Added unit tests
data/build.gradle CHANGED
@@ -16,7 +16,7 @@ configurations {
16
16
  sourceCompatibility = 1.7
17
17
  targetCompatibility = 1.7
18
18
 
19
- version = "0.1.8"
19
+ version = "0.1.9"
20
20
 
21
21
  dependencies {
22
22
  compile "org.embulk:embulk-core:0.7.5"
@@ -86,7 +86,6 @@ public class GcsFileInputPlugin
86
86
  }
87
87
 
88
88
  private static final Logger log = Exec.getLogger(GcsFileInputPlugin.class);
89
- private static GcsAuthentication auth;
90
89
 
91
90
  @Override
92
91
  public ConfigDiff transaction(ConfigSource config,
@@ -115,8 +114,18 @@ public class GcsFileInputPlugin
115
114
  }
116
115
  }
117
116
 
117
+ Storage client = newGcsClient(task, newGcsAuth(task));
118
+
119
+ // list files recursively
120
+ task.setFiles(listFiles(task, client));
121
+ // number of processors is same with number of files
122
+ return resume(task.dump(), task.getFiles().size(), control);
123
+ }
124
+
125
+ private GcsAuthentication newGcsAuth(PluginTask task)
126
+ {
118
127
  try {
119
- auth = new GcsAuthentication(
128
+ return new GcsAuthentication(
120
129
  task.getAuthMethod().getString(),
121
130
  task.getServiceAccountEmail(),
122
131
  task.getP12Keyfile().transform(localFileToPathString()),
@@ -126,11 +135,6 @@ public class GcsFileInputPlugin
126
135
  } catch (GeneralSecurityException | IOException ex) {
127
136
  throw new ConfigException(ex);
128
137
  }
129
-
130
- // list files recursively
131
- task.setFiles(listFiles(task));
132
- // number of processors is same with number of files
133
- return resume(task.dump(), task.getFiles().size(), control);
134
138
  }
135
139
 
136
140
  @Override
@@ -165,7 +169,7 @@ public class GcsFileInputPlugin
165
169
  {
166
170
  }
167
171
 
168
- protected Storage newGcsClient(final PluginTask task)
172
+ protected Storage newGcsClient(final PluginTask task, final GcsAuthentication auth)
169
173
  {
170
174
  Storage client = null;
171
175
  try {
@@ -188,9 +192,8 @@ public class GcsFileInputPlugin
188
192
  };
189
193
  }
190
194
 
191
- public List<String> listFiles(PluginTask task)
195
+ public List<String> listFiles(PluginTask task, Storage client)
192
196
  {
193
- Storage client = newGcsClient(task);
194
197
  String bucket = task.getBucket();
195
198
 
196
199
  return listGcsFilesByPrefix(client, bucket, task.getPathPrefix(), task.getLastPath());
@@ -291,7 +294,7 @@ public class GcsFileInputPlugin
291
294
 
292
295
  public SingleFileProvider(PluginTask task, int taskIndex)
293
296
  {
294
- this.client = newGcsClient(task);
297
+ this.client = newGcsClient(task, newGcsAuth(task));
295
298
  this.bucket = task.getBucket();
296
299
  this.key = task.getFiles().get(taskIndex);
297
300
  }
@@ -34,6 +34,8 @@ import org.junit.Rule;
34
34
  import org.junit.Test;
35
35
  import static org.junit.Assert.assertEquals;
36
36
  import static org.junit.Assume.assumeNotNull;
37
+ import java.lang.reflect.Method;
38
+ import java.lang.reflect.InvocationTargetException;
37
39
 
38
40
  public class TestGcsFileInputPlugin
39
41
  {
@@ -103,7 +105,8 @@ public class TestGcsFileInputPlugin
103
105
  .set("path_prefix", "my-prefix")
104
106
  .set("auth_method", "private_key")
105
107
  .set("service_account_email", GCP_EMAIL)
106
- .set("p12_keyfile", null);
108
+ .set("p12_keyfile", null)
109
+ .set("parser", parserConfig(schemaConfig()));
107
110
 
108
111
  runner.transaction(config, new Control());
109
112
  }
@@ -118,7 +121,8 @@ public class TestGcsFileInputPlugin
118
121
  .set("auth_method", "private_key")
119
122
  .set("service_account_email", GCP_EMAIL)
120
123
  .set("p12_keyfile", GCP_P12_KEYFILE)
121
- .set("p12_keyfile_fullpath", GCP_P12_KEYFILE);
124
+ .set("p12_keyfile_fullpath", GCP_P12_KEYFILE)
125
+ .set("parser", parserConfig(schemaConfig()));
122
126
 
123
127
  runner.transaction(config, new Control());
124
128
  }
@@ -132,7 +136,8 @@ public class TestGcsFileInputPlugin
132
136
  .set("path_prefix", "my-prefix")
133
137
  .set("auth_method", "private_key")
134
138
  .set("service_account_email", GCP_EMAIL)
135
- .set("p12_keyfile", "invalid-key.p12");
139
+ .set("p12_keyfile", "invalid-key.p12")
140
+ .set("parser", parserConfig(schemaConfig()));
136
141
 
137
142
  runner.transaction(config, new Control());
138
143
  }
@@ -146,34 +151,44 @@ public class TestGcsFileInputPlugin
146
151
  .set("path_prefix", "my-prefix")
147
152
  .set("auth_method", "json_key")
148
153
  .set("service_account_email", GCP_EMAIL)
149
- .set("json_keyfile", null);
154
+ .set("json_keyfile", null)
155
+ .set("parser", parserConfig(schemaConfig()));
150
156
 
151
157
  runner.transaction(config, new Control());
152
158
  }
153
159
 
154
160
  @Test
155
161
  public void testGcsClientCreateSuccessfully()
156
- throws GeneralSecurityException, IOException, NoSuchFieldException
162
+ throws GeneralSecurityException, IOException, NoSuchMethodException,
163
+ IllegalAccessException, InvocationTargetException
157
164
  {
158
165
  PluginTask task = config().loadConfig(PluginTask.class);
159
166
  runner.transaction(config, new Control());
160
- plugin.newGcsClient(task); // no errors happens
167
+
168
+ Method method = GcsFileInputPlugin.class.getDeclaredMethod("newGcsAuth", PluginTask.class);
169
+ method.setAccessible(true);
170
+ plugin.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task)); // no errors happens
161
171
  }
162
172
 
163
173
  @Test(expected = ConfigException.class)
164
174
  public void testGcsClientCreateThrowConfigException()
165
- throws GeneralSecurityException, IOException, NoSuchFieldException
175
+ throws GeneralSecurityException, IOException, NoSuchMethodException,
176
+ IllegalAccessException, InvocationTargetException
166
177
  {
167
178
  ConfigSource config = Exec.newConfigSource()
168
179
  .set("bucket", "non-exists-bucket")
169
180
  .set("path_prefix", "my-prefix")
170
181
  .set("auth_method", "json_key")
171
182
  .set("service_account_email", GCP_EMAIL)
172
- .set("json_keyfile", GCP_JSON_KEYFILE);
183
+ .set("json_keyfile", GCP_JSON_KEYFILE)
184
+ .set("parser", parserConfig(schemaConfig()));
173
185
 
174
186
  PluginTask task = config().loadConfig(PluginTask.class);
175
187
  runner.transaction(config, new Control());
176
- plugin.newGcsClient(task);
188
+
189
+ Method method = GcsFileInputPlugin.class.getDeclaredMethod("newGcsAuth", PluginTask.class);
190
+ method.setAccessible(true);
191
+ plugin.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task));
177
192
  }
178
193
 
179
194
  @Test
@@ -201,6 +216,7 @@ public class TestGcsFileInputPlugin
201
216
 
202
217
  @Test
203
218
  public void testListFilesByPrefix()
219
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
204
220
  {
205
221
  List<String> expected = Arrays.asList(
206
222
  GCP_BUCKET_DIRECTORY + "sample_01.csv",
@@ -216,24 +232,30 @@ public class TestGcsFileInputPlugin
216
232
  }
217
233
  });
218
234
 
219
- Storage client = plugin.newGcsClient(task);
235
+ Method method = GcsFileInputPlugin.class.getDeclaredMethod("newGcsAuth", PluginTask.class);
236
+ method.setAccessible(true);
237
+ Storage client = plugin.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task));
220
238
  List<String> actual = plugin.listGcsFilesByPrefix(client, GCP_BUCKET, GCP_PATH_PREFIX, Optional.<String>absent());
221
239
  assertEquals(expected, actual);
222
-
223
240
  assertEquals(GCP_BUCKET_DIRECTORY + "sample_02.csv", configDiff.get(String.class, "last_path"));
224
241
  }
225
242
 
226
243
  @Test
227
244
  public void testListFilesByPrefixNonExistsBucket()
245
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
228
246
  {
229
247
  PluginTask task = config.loadConfig(PluginTask.class);
230
248
  runner.transaction(config, new Control());
231
- Storage client = plugin.newGcsClient(task);
249
+
250
+ Method method = GcsFileInputPlugin.class.getDeclaredMethod("newGcsAuth", PluginTask.class);
251
+ method.setAccessible(true);
252
+ Storage client = plugin.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task));
232
253
  plugin.listGcsFilesByPrefix(client, "non-exists-bucket", "prefix", Optional.<String>absent()); // no errors happens
233
254
  }
234
255
 
235
256
  @Test
236
- public void testGcsFileInputByOpen() throws IOException
257
+ public void testGcsFileInputByOpen()
258
+ throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, IOException
237
259
  {
238
260
  ConfigSource config = Exec.newConfigSource()
239
261
  .set("bucket", GCP_BUCKET)
@@ -245,7 +267,11 @@ public class TestGcsFileInputPlugin
245
267
 
246
268
  PluginTask task = config.loadConfig(PluginTask.class);
247
269
  runner.transaction(config, new Control());
248
- task.setFiles(plugin.listFiles(task));
270
+
271
+ Method method = GcsFileInputPlugin.class.getDeclaredMethod("newGcsAuth", PluginTask.class);
272
+ method.setAccessible(true);
273
+ Storage client = plugin.newGcsClient(task, (GcsAuthentication) method.invoke(plugin, task));
274
+ task.setFiles(plugin.listFiles(task, client));
249
275
 
250
276
  assertRecords(config, output);
251
277
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embulk-input-gcs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Akama
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-28 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -63,7 +63,7 @@ files:
63
63
  - src/test/resources/sample_02.csv
64
64
  - classpath/commons-codec-1.3.jar
65
65
  - classpath/commons-logging-1.1.1.jar
66
- - classpath/embulk-input-gcs-0.1.8.jar
66
+ - classpath/embulk-input-gcs-0.1.9.jar
67
67
  - classpath/google-api-client-1.19.1.jar
68
68
  - classpath/google-api-services-storage-v1-rev27-1.19.1.jar
69
69
  - classpath/google-http-client-1.19.0.jar
Binary file