Skip to content

Commit

Permalink
Use external redis for tests (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbpennel authored Jul 23, 2024
1 parent 56bfedb commit cb505d5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:

runs-on: ubuntu-latest

services:
redis:
image: redis:6
ports:
- 46380:6379

steps:
- name: Checkout boxc repository
uses: actions/checkout@v2
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ mvn clean package

If there are updates to the box-c project which need to be pulled in for use in the migration utility, you will need to do a `pull` in the box-c clone (or make the changes locally), and build the box-c project with a `mvn clean install -DskipTests`.

### Running tests
The tests can be run in intellij or from the command line with `mvn test` or `mvn verify`.

A few of the tests depend on Redis to be running externally. The preferred way to run Redis is to use the docker-compose file in the box-c project, see the readme in box-c for instructions. After building it the first time, you can start the Redis container directly in Docker Desktop.

### Deploying
In order to deploy the project to a server or the development VM, see the `deploy_migration_util.rb` command from the `boxc-ansible` project. You can deploy uncommitted changes to the utility by providing the `-p` option. For example, `./deploy_migration_util.rb dev -p /path/to/cdm-to-boxc-migration-util` would build and deploy the current state of the migration util located at the provided path.

Expand Down
12 changes: 0 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,6 @@
<version>${wiremock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>it.ozimov</groupId>
<artifactId>embedded-redis</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
<version>${embedded-redis.version}</version>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.junit.jupiter.api.Test;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.embedded.RedisServer;

import java.io.IOException;
import java.net.URI;
Expand Down Expand Up @@ -58,18 +57,15 @@ public class CompleteMigrationIT extends AbstractCommandIT {
private TestSshServer testSshServer;
private Path filesBasePath;

private RedisServer redisServer;
private DepositStatusFactory depositStatusFactory;
private JedisPool jedisPool;

@BeforeEach
public void setup() throws Exception {
filesBasePath = tmpFolder;

redisServer = new RedisServer(REDIS_PORT);
System.setProperty("REDIS_HOST", "localhost");
System.setProperty("REDIS_PORT", Integer.toString(REDIS_PORT));
redisServer.start();

testSshServer = new TestSshServer();
testSshServer.startServer();
Expand Down Expand Up @@ -102,7 +98,6 @@ public void initDepositStatusFactory() {
public void after() throws Exception {
System.clearProperty("REDIS_HOST");
System.clearProperty("REDIS_PORT");
redisServer.stop();
if (jedisPool != null) {
jedisPool.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
import edu.unc.lib.boxc.migration.cdm.services.SipService;
import edu.unc.lib.boxc.migration.cdm.services.SourceFileService;
import edu.unc.lib.boxc.model.api.ids.PIDMinter;
import edu.unc.lib.boxc.model.fcrepo.ids.RepositoryPIDMinter;
import edu.unc.lib.boxc.operations.impl.events.PremisLoggerFactoryImpl;
import edu.unc.lib.boxc.persist.api.PackagingType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.embedded.RedisServer;

import java.io.BufferedWriter;
import java.net.URI;
Expand All @@ -41,7 +39,6 @@ public class SubmitSipsCommandIT extends AbstractCommandIT {
private final static int REDIS_PORT = 46380;
private final static String GROUPS = "my:admin:group";

private RedisServer redisServer;
private SipService sipService;

private DepositStatusFactory depositStatusFactory;
Expand All @@ -58,10 +55,8 @@ public class SubmitSipsCommandIT extends AbstractCommandIT {
@BeforeEach
public void setup() throws Exception {
initProjectAndHelper();
redisServer = new RedisServer(REDIS_PORT);
System.setProperty("REDIS_HOST", "localhost");
System.setProperty("REDIS_PORT", Integer.toString(REDIS_PORT));
redisServer.start();
sipService = testHelper.createSipsService();
}

Expand All @@ -83,7 +78,6 @@ public void after() throws Exception {
if (jedisPool != null) {
jedisPool.close();
}
redisServer.stop();
}

@Test
Expand Down

0 comments on commit cb505d5

Please sign in to comment.