Skip to content

Commit

Permalink
In response to demo1 failing in github actions, moved some code creat…
Browse files Browse the repository at this point in the history
…ing the mock database back into Demo1 from the base workflow class.
  • Loading branch information
michelleblom committed Nov 22, 2024
1 parent 75a6f72 commit 7bc0349
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
import io.restassured.path.json.JsonPath;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.testcontainers.containers.PostgreSQLContainer;
import org.testcontainers.ext.ScriptUtils;
import org.testcontainers.jdbc.JdbcDatabaseDelegate;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import us.freeandfair.corla.persistence.Persistence;
Expand All @@ -50,6 +52,18 @@ public class Demo1 extends Workflow {
*/
private static final Logger LOGGER = LogManager.getLogger(Demo1.class);


/**
* Container for the mock-up database.
*/
private final static PostgreSQLContainer<?> postgres = createTestContainer();

/**
* Container delegate for initialising mock-up database.
*/
private final static JdbcDatabaseDelegate containerDelegate = setupContainerStartPostgres(postgres);


/**
* Database init.
*/
Expand Down Expand Up @@ -136,7 +150,7 @@ public void runDemo1() throws InterruptedException {
assertEquals(dashboard.get(ASM_STATE), PARTIAL_AUDIT_INFO_SET.toString());

// 4. Generate assertions; sanity check
generateAssertions("SQL/demo1-assertions.sql", 1);
generateAssertions("SQL/demo1-assertions.sql", containerDelegate,1);
dashboard = getDoSDashBoardRefreshResponse();

// There should be 4 IRV contests.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ public class Workflow extends TestClassWithDatabase {
/**
* Container for the mock-up database.
*/
protected final static PostgreSQLContainer<?> postgres = createTestContainer();
//protected final static PostgreSQLContainer<?> postgres = createTestContainer();

/**
* Container delegate for initialising mock-up database.
*/
protected final static JdbcDatabaseDelegate containerDelegate = setupContainerStartPostgres(postgres);
//protected final static JdbcDatabaseDelegate containerDelegate = setupContainerStartPostgres(postgres);

/**
* Strings for colorado-rla JSON structures.
Expand Down Expand Up @@ -393,8 +393,10 @@ protected boolean uploadSuccessfulWithin(int timeAllowedSeconds, final Set<Integ
* See <a href="https://github.com/DemocracyDevelopers/colorado-rla/issues/218">...</a>
* Set it up so that we run raire-service inside the Docker container and tell main where to find it.
*/
protected void generateAssertions(final String sqlPath, final double timeLimitSeconds) {
ScriptUtils.runInitScript(containerDelegate, sqlPath);
protected void generateAssertions(final String sqlPath, final JdbcDatabaseDelegate delegate,
final double timeLimitSeconds)
{
ScriptUtils.runInitScript(delegate, sqlPath);

// Version that connects to raire-service below:
// Login as state admin.
Expand Down

0 comments on commit 7bc0349

Please sign in to comment.