From 742f35339b6732522d11be3eed74fcaa1da79143 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Tue, 27 Jun 2023 12:21:27 +0530 Subject: [PATCH 1/2] Add check to skip project-api tests if Asgadeo dev is not available --- gradle.properties | 1 + project-api-tests/build.gradle | 44 ++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index b44121283d..bd67bd2138 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,7 @@ dependencyJREVersion=jdk-11.0.18+10-jre specVersion=2022R4 slf4jVersion=1.7.30 balstdlibBranch=master +devIdpUrl=https://dev.api.asgardeo.io/oauth2/token/.well-known/openid-configuration # Stdlib Level 01 stdlibConstraintVersion=1.2.0 diff --git a/project-api-tests/build.gradle b/project-api-tests/build.gradle index a6b152fb35..5e473cf80e 100644 --- a/project-api-tests/build.gradle +++ b/project-api-tests/build.gradle @@ -15,8 +15,8 @@ ~ */ apply from: "$rootDir/gradle/javaProject.gradle" - -description = 'Ballerina - Central Tests' + + description = 'Ballerina - Central Tests' configurations { jBallerinaDistribution @@ -48,7 +48,6 @@ task centralTests { dependsOn configurations.jBallerinaDistribution dependsOn configurations.ballerinaDistribution dependsOn configurations.ballerinaLinuxDistribution - dependsOn configurations.ballerinaLinuxDistribution dependsOn configurations.ballerinaWindowsDistribution test { systemProperty "distributions.dir", "$buildDir/../../ballerina/build/distributions" @@ -69,4 +68,41 @@ task centralTests { } } -test.dependsOn centralTests + + task checkURL { + doLast { + try { + URL url = new URL("${devIdpUrl}") + HttpURLConnection connection = (HttpURLConnection) url.openConnection() + connection.setRequestMethod("GET") + connection.connect() + + int code = connection.getResponseCode() + if (code == 200) { + logger.lifecycle("Connection to ${devIdpUrl} is successful. Running tests...") + ext.isURLAvailable = true + } else { + logger.lifecycle("Connection to ${devIdpUrl} is not successful. Skipping tests...") + logger.lifecycle("-----------------------------------------") + logger.lifecycle(" WARNING: Skipping the project api tests") + logger.lifecycle("-----------------------------------------") + ext.isURLAvailable = false + } + } catch(Exception ex) { + logger.lifecycle("Connection to ${devIdpUrl} is not successful. Exception while connecting to " + + "${devIdpUrl}. Skipping tests...") + logger.lifecycle("-----------------------------------------") + logger.lifecycle(" WARNING: Skipping the project api tests") + logger.lifecycle("-----------------------------------------") + ext.isURLAvailable = false + } + } + } + + test { + dependsOn checkURL + onlyIf { + checkURL.isURLAvailable + } + dependsOn centralTests + } From 39242088f50614b7acb66ca48f69b039b31d8392 Mon Sep 17 00:00:00 2001 From: Fathima Dilhasha Date: Fri, 30 Jun 2023 10:24:59 +0530 Subject: [PATCH 2/2] Fix indentation Co-authored-by: Tharik Kanaka --- project-api-tests/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project-api-tests/build.gradle b/project-api-tests/build.gradle index 5e473cf80e..0be4c140e5 100644 --- a/project-api-tests/build.gradle +++ b/project-api-tests/build.gradle @@ -15,8 +15,8 @@ ~ */ apply from: "$rootDir/gradle/javaProject.gradle" - - description = 'Ballerina - Central Tests' + +description = 'Ballerina - Central Tests' configurations { jBallerinaDistribution