Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validates that input and output GCS paths specify a bucket #2602

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public String validateOutputFilePrefixSupported(String filePrefix) {
public String verifyPath(String path) {
GcsPath gcsPath = getGcsPath(path);
checkArgument(gcsPath.isAbsolute(), "Must provide absolute paths for Dataflow");
checkArgument(!gcsPath.getObject().isEmpty(),
"Missing object or bucket in path: '%s', did you mean: 'gs://some-bucket/%s'?",
gcsPath, gcsPath.getBucket());
checkArgument(!gcsPath.getObject().contains("//"),
"Dataflow Service does not allow objects with consecutive slashes");
return gcsPath.toResourceName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ public void testInvalidFilePattern() {
validator.validateInputFilePatternSupported("/local/path");
}

@Test
public void testFilePatternMissingBucket() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage(
"Missing object or bucket in path: 'gs://input/', "
+ "did you mean: 'gs://some-bucket/input'?");
validator.validateInputFilePatternSupported("gs://input");
}

@Test
public void testWhenBucketDoesNotExist() throws Exception {
when(mockGcsUtil.bucketAccessible(any(GcsPath.class))).thenReturn(false);
Expand All @@ -84,4 +93,13 @@ public void testInvalidOutputPrefix() {
"Expected a valid 'gs://' path but was given '/local/path'");
validator.validateOutputFilePrefixSupported("/local/path");
}

@Test
public void testOutputPrefixMissingBucket() {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage(
"Missing object or bucket in path: 'gs://output/', "
+ "did you mean: 'gs://some-bucket/output'?");
validator.validateOutputFilePrefixSupported("gs://output");
}
}