From be67daa53eff76b0ae9ba07058d681f099bad4bd Mon Sep 17 00:00:00 2001 From: Jan Blom Date: Thu, 15 Feb 2024 16:13:06 +0100 Subject: [PATCH 1/4] Turn on mvn verify in github --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f1c4cd36..44d05edb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,4 +30,4 @@ jobs: # Gradle check - name: Check - run: mvn test + run: mvn verify From f86b2ab63a5ed9c98b8baebd3906fac8201a8678 Mon Sep 17 00:00:00 2001 From: Jan Blom Date: Fri, 16 Feb 2024 09:45:58 +0100 Subject: [PATCH 2/4] Disable Oracle integration tests in Github workflow as they tend to generate a timeout --- .github/workflows/main.yml | 3 ++ .../scan/SourceDataScanOracleIT.java | 30 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 44d05edb..bf54a723 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,6 +1,9 @@ # Continuous integration, including test and integration test name: CI +env: + SKIP_ORACLE_TESTS: true + # Run in master and dev branches and in all pull requests to those branches on: push: diff --git a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java index 6b046fe4..638a4447 100644 --- a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java +++ b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java @@ -17,8 +17,10 @@ ******************************************************************************/ package org.ohdsi.whiterabbit.scan; +import org.apache.commons.lang.StringUtils; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable; import org.junit.jupiter.api.io.TempDir; import org.ohdsi.databases.configuration.DbSettings; import org.ohdsi.databases.configuration.DbType; @@ -35,12 +37,17 @@ import java.util.*; import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assumptions.assumeTrue; class SourceDataScanOracleIT { private final static String USER_NAME = "test_user"; private final static String SCHEMA_NAME = USER_NAME; + // The Oracle test containersomehwat is slow to start, and these tests can be configured to be skipped by + // setting the environment variable SKIP_ORACLE_TESTS to "true" (e.g. in a Github workflow) + private final static String SKIP_ORACLE_TESTS = "SKIP_ORACLE_TESTS"; + /* * Since the database is only read, setting it up once suffices. * @@ -51,22 +58,29 @@ class SourceDataScanOracleIT { * for this data is know and could simply be copied instead of composed. * Also, for the technical correctness of WhiteRabbit (does it open the database, get the table * names and scan those tables), the actual nature of the source data does not matter. + * */ @Container - public static OracleContainer oracleContainer = new OracleContainer("gvenzl/oracle-xe:11.2.0.2-slim-faststart") - .withReuse(true) - .usingSid() - .withUsername(USER_NAME) - .withPassword("test_password") - .withDatabaseName("testDB") - .withInitScript("scan_data/create_data_oracle.sql"); + public static OracleContainer oracleContainer; @BeforeAll public static void startContainer() { + String skipOracleTests = System.getenv(SKIP_ORACLE_TESTS); + assumeTrue(!(StringUtils.isNotEmpty(skipOracleTests) && skipOracleTests.matches("true")), + String.format("Skipping Oracle tests, triggered by environment variable %s", SKIP_ORACLE_TESTS)); + + oracleContainer = new OracleContainer("gvenzl/oracle-xe:11.2.0.2-slim-faststart") + .withReuse(true) + .usingSid() + .withUsername(USER_NAME) + .withPassword("test_password") + .withDatabaseName("testDB") + .withInitScript("scan_data/create_data_oracle.sql"); oracleContainer.start(); } @Test + @DisabledIfEnvironmentVariable(named = SKIP_ORACLE_TESTS, matches = "true") public void connectToDatabase() { // this is also implicitly tested by testSourceDataScan(), but having it fail separately helps identify problems quicker DbSettings dbSettings = getTestDbSettings(); @@ -76,6 +90,7 @@ public void connectToDatabase() { } @Test + @DisabledIfEnvironmentVariable(named = SKIP_ORACLE_TESTS, matches = "true") public void testGetTableNames() { // this is also implicitly tested by testSourceDataScan(), but having it fail separately helps identify problems quicker DbSettings dbSettings = getTestDbSettings(); @@ -83,6 +98,7 @@ public void testGetTableNames() { assertEquals(2, tableNames.size()); } @Test + @DisabledIfEnvironmentVariable(named = SKIP_ORACLE_TESTS, matches = "true") void testSourceDataScan(@TempDir Path tempDir) throws IOException, URISyntaxException { loadData(); Path outFile = tempDir.resolve("scanresult.xslx"); From fcfeb73fcf24c5047d49c44dccbc2d91fac624c4 Mon Sep 17 00:00:00 2001 From: Jan Blom Date: Mon, 19 Feb 2024 12:40:46 +0100 Subject: [PATCH 3/4] Fix typo --- .../java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java index 638a4447..2f049169 100644 --- a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java +++ b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanOracleIT.java @@ -44,7 +44,7 @@ class SourceDataScanOracleIT { private final static String USER_NAME = "test_user"; private final static String SCHEMA_NAME = USER_NAME; - // The Oracle test containersomehwat is slow to start, and these tests can be configured to be skipped by + // The Oracle test container is somewhat is slow to start, and these tests can be configured to be skipped by // setting the environment variable SKIP_ORACLE_TESTS to "true" (e.g. in a Github workflow) private final static String SKIP_ORACLE_TESTS = "SKIP_ORACLE_TESTS"; From f7978898909aae6533a68e2b4edec33ab6b97980 Mon Sep 17 00:00:00 2001 From: Jan Blom Date: Mon, 19 Feb 2024 12:52:43 +0100 Subject: [PATCH 4/4] Avoid starting containers for Snowflake when configuration is not present --- .../org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeGuiIT.java | 1 + .../org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeIT.java | 1 + 2 files changed, 2 insertions(+) diff --git a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeGuiIT.java b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeGuiIT.java index 880c8c2f..b8098b89 100644 --- a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeGuiIT.java +++ b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeGuiIT.java @@ -71,6 +71,7 @@ public static void setupOnce() { @BeforeEach public void onSetUp() { + Assumptions.assumeTrue(new SnowflakeTestUtils.SnowflakeSystemPropertiesFileChecker(), "Snowflake system properties file not available"); try { testContainer = createPythonContainer(); prepareTestData(testContainer); diff --git a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeIT.java b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeIT.java index 8478adc6..376484a6 100644 --- a/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeIT.java +++ b/whiterabbit/src/test/java/org/ohdsi/whiterabbit/scan/SourceDataScanSnowflakeIT.java @@ -56,6 +56,7 @@ public class SourceDataScanSnowflakeIT { @BeforeEach public void setUp() { + Assumptions.assumeTrue(new SnowflakeTestUtils.SnowflakeSystemPropertiesFileChecker(), "Snowflake system properties file not available"); try { testContainer = createPythonContainer(); prepareTestData(testContainer);