Skip to content

Commit

Permalink
Tweak Job REST controller integration tests
Browse files Browse the repository at this point in the history
Slow down the job to make sure requests hit while job is running (sleep 5 rather than sleep 1).
Reduce the number of request in content-type test.
  • Loading branch information
mprimi committed Aug 20, 2020
1 parent 86c8002 commit 9306eda
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 58 deletions.
Expand Up @@ -163,7 +163,7 @@ class JobRestControllerIntegrationTest extends RestControllerIntegrationTestBase
// related to charset headers
private static final String GB18030_TXT = "GB18030.txt";
private static final List<String> SLEEP_AND_ECHO_COMMAND_ARGS =
Lists.newArrayList("-c", "'sleep 1 && echo hello world'");
Lists.newArrayList("-c", "'sleep 5 && echo hello world'");
private static final ArrayList<String> SLEEP_60_COMMAND_ARGS = Lists.newArrayList("-c", "'sleep 60'");
private static final String EXPECTED_STDOUT_CONTENT = "hello world\n";
private static final int EXPECTED_STDOUT_LENGTH = EXPECTED_STDOUT_CONTENT.length();
Expand Down Expand Up @@ -1491,60 +1491,7 @@ void testResponseContentType() throws Exception {
.header(HttpHeaders.LOCATION)
);

this.waitForDone(jobId);

RestAssured
.given(this.getRequestSpecification())
.when()
.port(this.port)
.get(JOBS_API + "/" + jobId + "/output/genie/logs/env.log")
.then()
.statusCode(Matchers.is(HttpStatus.OK.value()))
.contentType(Matchers.containsString(MediaType.TEXT_PLAIN_VALUE))
.contentType(Matchers.containsString(utf8));

if (this.agentExecution) {
RestAssured
.given(this.getRequestSpecification())
.when()
.port(this.port)
.get(JOBS_API + "/" + jobId + "/output/genie/logs/agent.log")
.then()
.statusCode(Matchers.is(HttpStatus.OK.value()))
.contentType(Matchers.containsString(MediaType.TEXT_PLAIN_VALUE))
.contentType(Matchers.containsString(utf8));

RestAssured
.given(this.getRequestSpecification())
.when()
.port(this.port)
.get(JOBS_API + "/" + jobId + "/output/genie/logs/setup.log")
.then()
.statusCode(Matchers.is(HttpStatus.OK.value()))
.contentType(Matchers.containsString(MediaType.TEXT_PLAIN_VALUE))
.contentType(Matchers.containsString(utf8));

} else {
RestAssured
.given(this.getRequestSpecification())
.when()
.port(this.port)
.get(JOBS_API + "/" + jobId + "/output/genie/logs/genie.log")
.then()
.statusCode(Matchers.is(HttpStatus.OK.value()))
.contentType(Matchers.containsString(MediaType.TEXT_PLAIN_VALUE))
.contentType(Matchers.containsString(utf8));

RestAssured
.given(this.getRequestSpecification())
.when()
.port(this.port)
.get(JOBS_API + "/" + jobId + "/output/genie/genie.done")
.then()
.statusCode(Matchers.is(HttpStatus.OK.value()))
.contentType(Matchers.containsString(MediaType.TEXT_PLAIN_VALUE))
.contentType(Matchers.containsString(utf8));
}
this.waitForRunning(jobId);

RestAssured
.given(this.getRequestSpecification())
Expand Down Expand Up @@ -1652,7 +1599,7 @@ void testFileNotFound() throws Exception {
.header(HttpHeaders.LOCATION)
);

this.waitForDone(jobId);
this.waitForRunning(jobId);

RestAssured
.given(this.getRequestSpecification())
Expand Down
Expand Up @@ -135,7 +135,7 @@ exec 2>&7 7>&-
env | sort > ${__GENIE_ENVIRONMENT_DUMP_FILE}

# Launch the command
/bin/bash -c 'sleep 1 && echo hello world' <&0 &
/bin/bash -c 'sleep 5 && echo hello world' <&0 &
wait %1
exit $?

Expand Up @@ -124,7 +124,7 @@ source ${GENIE_JOB_DIR}/jobsetupfile
env | sort > ${GENIE_JOB_DIR}/genie/logs/env.log

# Kick off the command in background mode and wait for it using its pid
/bin/bash -c 'sleep 1 && echo hello world' > ${GENIE_JOB_DIR}/stdout 2> ${GENIE_JOB_DIR}/stderr &
/bin/bash -c 'sleep 5 && echo hello world' > ${GENIE_JOB_DIR}/stdout 2> ${GENIE_JOB_DIR}/stderr &
export CHILDREN_PID=$!
wait ${CHILDREN_PID}

Expand Down

0 comments on commit 9306eda

Please sign in to comment.