Skip to content

Commit

Permalink
ci: fix kokoro windows build scripts (GoogleContainerTools#3979)
Browse files Browse the repository at this point in the history
* Java 8 issue: updated scripts to use the new environment's default JAVA_HOME and removes the previously set location.
* BuildFilesTest issue: switched test to unix-based newline instead of System.lineSeparator() in BuildFilesTest.
* UpdateCheckerTest issue: added extra lag time between operations in UpdateCheckerTest with before/after timestamp comparison.
  • Loading branch information
emmileaf authored Apr 6, 2023
1 parent fa8cc95 commit 618670b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,7 @@ public void testToBuildFileSpec_templateMultiLineBehavior()
Paths.get(Resources.getResource("buildfiles/projects/templating/multiLine.yaml").toURI());

Mockito.when(buildCli.getTemplateParameters())
.thenReturn(
ImmutableMap.of("replace" + System.lineSeparator() + "this", "creationTime: 1234"));
.thenReturn(ImmutableMap.of("replace" + "\n" + "this", "creationTime: 1234"));
JibContainerBuilder jibContainerBuilder =
BuildFiles.toJibContainerBuilder(
buildfile.getParent(), buildfile, buildCli, commonCliOptions, consoleLogger);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ public void tearDown() throws IOException {
}

@Test
public void testPerformUpdateCheck_newVersionFound() throws IOException {
public void testPerformUpdateCheck_newVersionFound() throws IOException, InterruptedException {
Instant before = Instant.now();
Thread.sleep(100);
setupLastUpdateCheck();
Optional<String> message =
UpdateChecker.performUpdateCheck(
Expand Down Expand Up @@ -99,8 +100,9 @@ public void testPerformUpdateCheck_newJsonField()
}

@Test
public void testPerformUpdateCheck_onLatest() throws IOException {
public void testPerformUpdateCheck_onLatest() throws IOException, InterruptedException {
Instant before = Instant.now();
Thread.sleep(100);
setupLastUpdateCheck();
Optional<String> message =
UpdateChecker.performUpdateCheck(
Expand All @@ -115,8 +117,9 @@ public void testPerformUpdateCheck_onLatest() throws IOException {
}

@Test
public void testPerformUpdateCheck_noLastUpdateCheck() throws IOException {
public void testPerformUpdateCheck_noLastUpdateCheck() throws IOException, InterruptedException {
Instant before = Instant.now();
Thread.sleep(100);
Optional<String> message =
UpdateChecker.performUpdateCheck(
configDir, "1.0.2", testWebServer.getEndpoint(), "tool-name", ignored -> {});
Expand All @@ -129,9 +132,11 @@ public void testPerformUpdateCheck_noLastUpdateCheck() throws IOException {
}

@Test
public void testPerformUpdateCheck_emptyLastUpdateCheck() throws IOException {
public void testPerformUpdateCheck_emptyLastUpdateCheck()
throws IOException, InterruptedException {
Files.createFile(configDir.resolve("lastUpdateCheck"));
Instant before = Instant.now();
Thread.sleep(100);
Optional<String> message =
UpdateChecker.performUpdateCheck(
configDir, "1.0.2", testWebServer.getEndpoint(), "tool-name", ignored -> {});
Expand Down Expand Up @@ -164,8 +169,9 @@ public void testPerformUpdateCheck_lastUpdateCheckTooSoon() throws IOException {
}

@Test
public void testPerformUpdateCheck_badLastUpdateTime() throws IOException {
public void testPerformUpdateCheck_badLastUpdateTime() throws IOException, InterruptedException {
Instant before = Instant.now();
Thread.sleep(100);
Files.write(
configDir.resolve("lastUpdateCheck"), "bad timestamp".getBytes(StandardCharsets.UTF_8));
Optional<String> message =
Expand Down
3 changes: 1 addition & 2 deletions kokoro/continuous.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@echo on

REM Java 9 does not work with Mockito mockmaker.
set JAVA_HOME=c:\program files\java\jdk1.8.0_152
set PATH=%JAVA_HOME%\bin;%PATH%
echo %JAVA_HOME%

cd github/jib

Expand Down
3 changes: 1 addition & 2 deletions kokoro/presubmit.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@echo on

REM Java 9 does not work with Mockito mockmaker.
set JAVA_HOME=c:\program files\java\jdk1.8.0_152
set PATH=%JAVA_HOME%\bin;%PATH%
echo %JAVA_HOME%

cd github/jib

Expand Down

0 comments on commit 618670b

Please sign in to comment.