Visitar URL original
docs(samples): added basic samples and tests by Sita04 · Pull Request #43 · googleapis/java-batch · GitHub
Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
minor refactoring
  • Loading branch information
Sita04 authored Sep 19, 2022
commit 99c1840d9594243987a1cd702bffae65dc371544
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,7 @@ public static void createContainerJob(String projectId, String region, String jo
.futureCall(createJobRequest)
.get(3, TimeUnit.MINUTES);

String resultJobName = result.getName();
System.out.printf(
"Successfully created the job: %s",
resultJobName.substring(resultJobName.lastIndexOf("\\") + 1));
System.out.printf("Successfully created the job: %s", result.getName());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ public static void createScriptJob(String projectId, String region, String jobNa
"echo Hello world! This is task ${BATCH_TASK_INDEX}. "
+ "This job has a total of ${BATCH_TASK_COUNT} tasks.")
// You can also run a script from a file. Just remember, that needs to be a
// script that's
// already on the VM that will be running the job.
// script that's already on the VM that will be running the job.
// Using setText() and setPath() is mutually exclusive.
// .setPath("/tmp/test.sh")
.build())
Expand Down Expand Up @@ -135,10 +134,7 @@ public static void createScriptJob(String projectId, String region, String jobNa
.futureCall(createJobRequest)
.get(3, TimeUnit.MINUTES);

String resultJobName = result.getName();
System.out.printf(
"Successfully created the job: %s",
resultJobName.substring(resultJobName.lastIndexOf("\\") + 1));
System.out.printf("Successfully created the job: %s", result.getName());
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions samples/snippets/src/test/java/BatchBasicIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,13 @@ public static void setUp()
CONTAINER_JOB_NAME = "test-job-container-" + uuid;

CreateWithContainerNoMounting.createContainerJob(PROJECT_ID, REGION, CONTAINER_JOB_NAME);
assertThat(stdOut.toString()).contains("Successfully created the job: " + CONTAINER_JOB_NAME);
assertThat(stdOut.toString()).contains(
"Successfully created the job: " + String.format("projects/%s/locations/%s/jobs/%s",
PROJECT_ID, REGION, CONTAINER_JOB_NAME));
CreateWithScriptNoMounting.createScriptJob(PROJECT_ID, REGION, SCRIPT_JOB_NAME);
assertThat(stdOut.toString()).contains("Successfully created the job: " + SCRIPT_JOB_NAME);
assertThat(stdOut.toString()).contains(
"Successfully created the job: " + String.format("projects/%s/locations/%s/jobs/%s",
PROJECT_ID, REGION, SCRIPT_JOB_NAME));
TimeUnit.SECONDS.sleep(10);

stdOut.close();
Expand Down