Skip to content

Commit

Permalink
Merge pull request #4632 from Dilhasha/central-base-check
Browse files Browse the repository at this point in the history
Add check to skip project-api tests if Asgadeo dev is not available
  • Loading branch information
keizer619 authored Jun 30, 2023
2 parents adff056 + 3924208 commit feacfd4
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencyJREVersion=jdk-11.0.18+10-jre
specVersion=2023R1
slf4jVersion=1.7.30
balstdlibBranch=master
devIdpUrl=https://dev.api.asgardeo.io/oauth2/token/.well-known/openid-configuration

# Stdlib Level 01
stdlibConstraintVersion=1.3.0-20230620-195700-ca941bc
Expand Down
40 changes: 38 additions & 2 deletions project-api-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
}

0 comments on commit feacfd4

Please sign in to comment.