diff --git a/README.adoc b/README.adoc index 8c931e9..fece31e 100644 --- a/README.adoc +++ b/README.adoc @@ -2,7 +2,7 @@ :linkattrs: :project-owner: oracle-actions :project-name: setup-testpilot -:project-tag: v1.0.24 +:project-tag: v1.0.25 ifdef::env-github[] :tip-caption: :bulb: diff --git a/action.yml b/action.yml index f899b4c..446ac51 100644 --- a/action.yml +++ b/action.yml @@ -9,7 +9,7 @@ branding: inputs: version: description: 'The version to use.' - default: 'v1.0.24' + default: 'v1.0.25' required: true action: description: 'The action to run (create*, delete, skip-testing).' diff --git a/pom.xml b/pom.xml index 3293b3f..a7491bd 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.oracle.testpilot testpilot-services - 1.0.24 + 1.0.25 Oracle Test Pilot actions Actions provided by Oracle Test Pilot. diff --git a/setup-testpilot.sh b/setup-testpilot.sh index 9fe1a24..a43a52a 100755 --- a/setup-testpilot.sh +++ b/setup-testpilot.sh @@ -5,7 +5,7 @@ set -e if [ ! -f "${GITHUB_ACTION_PATH}"/setup-testpilot ]; then echo "::group::🔽 Downloading setup-testpilot" -wget https://github.com/oracle-actions/setup-testpilot/releases/download/${VERSION}/setup-testpilot-linux-x86_64.tar.gz -O ${GITHUB_ACTION_PATH}/setup-testpilot-linux-x86_64.tar.gz -q +wget --continue --progress=dot:mega --tries=0 https://github.com/oracle-actions/setup-testpilot/releases/download/${VERSION}/setup-testpilot-linux-x86_64.tar.gz -O ${GITHUB_ACTION_PATH}/setup-testpilot-linux-x86_64.tar.gz -q echo "::endgroup::" echo "::group::📦 Unpacking setup-testpilot" diff --git a/src/main/java/com/oracle/testpilot/Main.java b/src/main/java/com/oracle/testpilot/Main.java index 2c112f0..3292aa2 100644 --- a/src/main/java/com/oracle/testpilot/Main.java +++ b/src/main/java/com/oracle/testpilot/Main.java @@ -23,7 +23,7 @@ public class Main { System.setProperty("java.net.useSystemProxies", "false"); } - public static final String VERSION="1.0.24"; + public static final String VERSION="1.0.25"; public static void main(final String[] args) { int exitStatus = 0; diff --git a/src/main/java/com/oracle/testpilot/Session.java b/src/main/java/com/oracle/testpilot/Session.java index 74e2455..50158d1 100644 --- a/src/main/java/com/oracle/testpilot/Session.java +++ b/src/main/java/com/oracle/testpilot/Session.java @@ -279,27 +279,28 @@ private void create() { try { final String type = getInternalTechnologyType(technologyType); - setOAuth2Token(); - final String uri = String.format("https://%s/ords/testpilot/resources/create", apiHOST); - final HttpRequest request = HttpRequest.newBuilder() - .uri(new URI(uri)) - .headers("Accept", "application/json", - "Content-Type", "application/json", - "Pragma", "no-cache", - "Cache-Control", "no-store", - "User-Agent", "setup-testpilot/" + Main.VERSION, - "Authorization", "Bearer " + token) - .POST(HttpRequest.BodyPublishers.ofString( - String.format("{\"runID\":\"%s\",\"type\":\"%s\",\"user\":[%s]}", - runID, type, buildUserList(users,true)) - )) - .build(); - boolean done = false; + int retryCount = 5; do { + setOAuth2Token(); + + final HttpRequest request = HttpRequest.newBuilder() + .uri(new URI(uri)) + .headers("Accept", "application/json", + "Content-Type", "application/json", + "Pragma", "no-cache", + "Cache-Control", "no-store", + "User-Agent", "setup-testpilot/" + Main.VERSION, + "Authorization", "Bearer " + token) + .POST(HttpRequest.BodyPublishers.ofString( + String.format("{\"runID\":\"%s\",\"type\":\"%s\",\"user\":[%s]}", + runID, type, buildUserList(users,true)) + )) + .build(); + try (HttpClient client = HttpClient .newBuilder() .connectTimeout(Duration.ofSeconds(ONE_MINUTE_TIMEOUT)) @@ -357,7 +358,32 @@ else if(response.statusCode() == 429) { // too many requests (rate limiting) Thread.sleep(10 * 1000L); } + else if(response.statusCode() == 504) { + // Gateway time-out (load balancer) + // retry 5 times with 1 minute time-out each time + retryCount--; + if(retryCount == 0) { + if(githubOutput != null) { + try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { + out.println("create=ko"); + } + } + + throw new TestPilotException(CREATE_DATABASE_REST_ENDPOINT_ISSUE, + new IllegalStateException("HTTP/S status code: " + response.statusCode(), + new IllegalStateException(response.body()))); + } else { + System.out.printf("Gateway time-out, retrying in 10 seconds...%n"); + Thread.sleep(10 * 1000L); + } + } else { + if(githubOutput != null) { + try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { + out.println("create=ko"); + } + } + throw new TestPilotException(CREATE_DATABASE_REST_ENDPOINT_ISSUE, new IllegalStateException("HTTP/S status code: " + response.statusCode(), new IllegalStateException(response.body()))); @@ -366,9 +392,23 @@ else if(response.statusCode() == 429) { } while(!done); } catch (URISyntaxException e) { + if (githubOutput != null) { + try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { + out.println("delete=ko"); + } + catch(IOException ignored) {} + } + throw new TestPilotException(WRONG_MAIN_CONTROLLER_URI, e); } catch (IOException | InterruptedException e) { + if (githubOutput != null) { + try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { + out.println("delete=ko"); + } + catch(IOException ignored) {} + } + throw new TestPilotException(WRONG_MAIN_CONTROLLER_REST_CALL, e); } } @@ -460,6 +500,12 @@ else if(response.statusCode() == 504) { } } else { + if (githubOutput != null) { + try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { + out.println("delete=ko"); + } + } + throw new TestPilotException(DROP_DATABASE_REST_ENDPOINT_ISSUE, new IllegalStateException("HTTP/S status code: " + response.statusCode())); } @@ -467,9 +513,23 @@ else if(response.statusCode() == 504) { } while(!done); } catch (URISyntaxException e) { + if(githubOutput != null) { + try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { + out.println("delete=ko"); + } + catch(IOException ignored) {} + } + throw new TestPilotException(WRONG_MAIN_CONTROLLER_URI, e); } catch (IOException | InterruptedException e) { + if(githubOutput != null) { + try (PrintWriter out = new PrintWriter(new BufferedOutputStream(new FileOutputStream(githubOutput, true)))) { + out.println("delete=ko"); + } + catch(IOException ignored) {} + } + throw new TestPilotException(WRONG_MAIN_CONTROLLER_REST_CALL, e); } }