-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1026 from hiroyuki-sato/validate-project-on-serve…
…r-side Digdag push validation on the server side.
- Loading branch information
Showing
3 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
digdag-tests/src/test/java/acceptance/ValidateProjectIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package acceptance; | ||
|
||
import org.junit.Before; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
import utils.CommandStatus; | ||
import utils.TemporaryDigdagServer; | ||
|
||
import java.nio.file.Path; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.containsString; | ||
import static org.hamcrest.Matchers.is; | ||
import static utils.TestUtils.copyResource; | ||
import static utils.TestUtils.main; | ||
|
||
// | ||
// This file doesn't contain normal case. | ||
// It defined in another test. | ||
// | ||
public class ValidateProjectIT | ||
{ | ||
@Rule | ||
public TemporaryFolder folder = new TemporaryFolder(); | ||
|
||
@Rule | ||
public TemporaryDigdagServer server = TemporaryDigdagServer.builder() | ||
.build(); | ||
|
||
private Path config; | ||
private Path projectDir; | ||
|
||
@Before | ||
public void setUp() | ||
throws Exception | ||
{ | ||
projectDir = folder.getRoot().toPath().resolve("foobar"); | ||
config = folder.newFile().toPath(); | ||
} | ||
|
||
@Test | ||
public void uploadInvalidTaskProject() | ||
throws Exception | ||
{ | ||
// Create new project | ||
CommandStatus initStatus = main("init", | ||
"-c", config.toString(), | ||
projectDir.toString()); | ||
assertThat(initStatus.code(), is(0)); | ||
|
||
copyResource("acceptance/error_task/invalid_at_group.dig", projectDir.resolve("invalid_at_group.dig")); | ||
|
||
// Push the project | ||
CommandStatus pushStatus = main( | ||
"push", | ||
"--project", projectDir.toString(), | ||
"foobar", | ||
"-c", config.toString(), | ||
"-e", server.endpoint()); | ||
assertThat(pushStatus.code(), is(1)); | ||
assertThat(pushStatus.errUtf8(), containsString("A task can't have more than one operator")); | ||
} | ||
|
||
@Test | ||
public void uploadInvalidScheduleProject() | ||
throws Exception | ||
{ | ||
// Create new project | ||
CommandStatus initStatus = main("init", | ||
"-c", config.toString(), | ||
projectDir.toString()); | ||
assertThat(initStatus.code(), is(0)); | ||
|
||
copyResource("acceptance/schedule/invalid_schedule.dig", projectDir.resolve("invalid_schedule.dig")); | ||
|
||
// Push the project | ||
CommandStatus pushStatus = main( | ||
"push", | ||
"--project", projectDir.toString(), | ||
"foobar", | ||
"-c", config.toString(), | ||
"-e", server.endpoint()); | ||
assertThat(pushStatus.code(), is(1)); | ||
assertThat(pushStatus.errUtf8(), containsString("scheduler requires mm:ss format")); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
digdag-tests/src/test/resources/acceptance/schedule/invalid_schedule.dig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
timezone: UTC | ||
|
||
schedule: | ||
hourly>: "10:11:12" # correct format is "MM:SS" | ||
|
||
+foo: | ||
sh>: "touch foo.out" | ||
|