Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn on mvn verify in github #45

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -30,4 +33,4 @@ jobs:

# Gradle check
- name: Check
run: mvn test
run: mvn verify
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 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";

/*
* Since the database is only read, setting it up once suffices.
*
Expand All @@ -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();
Expand All @@ -76,13 +90,15 @@ 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();
List<String> tableNames = getTableNames(dbSettings);
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading