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

Broker integration test #397

Closed
wants to merge 5 commits into from
Closed
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
21 changes: 19 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
language: java
sudo: true

sudo: required

env:
# Give Maven 1GB of memory to work with
- MAVEN_OPTS=-Xmx2048M

services:
- docker

before_install:
# - setup_docker.sh
- docker-compose rm -f
- docker-compose pull

script: mvn clean test package
script:
# docker needs jar file to start
- mvn clean test package
- docker-compose up -d
# - sleep 20 # wait that containers are ready
- mvn integration-test -P integration-test

after_script:
- docker-compose stop -t 1
62 changes: 55 additions & 7 deletions datavault-broker/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

<!-- Jackson JSON Processor -->
<dependency>
Expand Down Expand Up @@ -190,11 +184,43 @@
<artifactId>datavault-common</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>


<!-- Tests -->
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>hamcrest-core</artifactId>
<groupId>org.hamcrest</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.2.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.8.RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>datavault-broker</finalName>

<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -204,15 +230,37 @@
<target>1.8</target>
</configuration>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests>

<includes>
<include>**/*Tests.java</include>
</includes>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>

<configuration>
<skipTests>${skip.integration.tests}</skipTests>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.datavaultplatform.broker.services;

import static org.hamcrest.Matchers.is;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import static org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace.NONE;

import java.util.List;

import org.datavaultplatform.common.model.Vault;
import org.datavaultplatform.common.model.dao.VaultDAO;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
//import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;

@RunWith(SpringJUnit4ClassRunner.class)
@DataJpaTest
@AutoConfigureTestDatabase(replace = NONE)
@ActiveProfiles("it")
@ContextConfiguration(locations = {
"file:src/test/resources/datavault-broker-root.xml"
})
@TransactionConfiguration(defaultRollback=true,transactionManager="transactionManager")
public class VaultsServiceIT {
@Autowired
private VaultsService vaultsService;

@Test
public void checkVaultCount() {
int prevVaultCount = vaultsService.count();

Vault vault = new Vault("Vault Test");
vaultsService.addVault(vault);

int newVaultCount = prevVaultCount + 1;
Assert.assertThat(vaultsService.count(), is(newVaultCount));
}
}
123 changes: 123 additions & 0 deletions datavault-broker/src/test/resources/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
# This is the DataVault configuration file. Settings are used to customise different options.
#
# This file is used to set properties in the various Spring files located in each application.

# Broker settings
# ===============
# The URL of the broker API for use by the default web application
broker.url = http://localhost:58080/datavault-broker
# API key for the default web client
broker.api.key = datavault-webapp
# Debug setting to disable API authentication
broker.validateclient = true

# Database settings
# =================
# The location of the MySQL database
db.url = localhost:53306/datavault?useUnicode=true
#The MySQL username
db.username = datavault
# The MySQL password
db.password = datavault

# Message queue settings
# ======================
# The location of the RabbitMQ server
queue.server = localhost
# The RabbitMQ username
queue.user = datavault
# The RabbitMQ password
queue.password = datavault
# The name of the primary RabbitMQ queue for communication between the broker and workers
queue.name = datavault
# The name of the RabbitMQ queue to use for notifying the broker of events
queue.events = datavault-event

# Worker settings
# ===============
# The number of concurrent workers to start
worker.number = 1

# Top level storage location settings
# ===================================
# A default directory for sample user data (if per-user storage is not configured)
activeDir = /Users
# Directory for archive data (if using 'local storage')
archiveDir = /tmp/datavault/archive
# A temporary directory for workers to process files before storing in the archive
tempDir = /tmp/datavault/temp
# A directory for storing archive metadata
metaDir = /tmp/datavault/meta

# Email server settings
# =====================
# The email account of the system administrator
mail.administrator = [email protected]
# SMTP host for sending mail
mail.host = smtp.gmail.com
# SMTP port for sending mail
mail.port = 587
# SMTP account name for sending mail
mail.username = [email protected]
# SMTP password for sending mail
mail.password = XXX

# Welcome settings
# ================
# Welcome message (HTML) displayed by the (non-shibboleth) login page.
webapp.welcome =

# CRIS system settings
# ====================
# The URL of the external metadata service (for example, a Pure CRIS API). Leave this blank to use a mock provider
# eg. https://example.org/ws/rest/datasets
# If using HTTP BASIC authentication, use: https://username:[email protected]/ws/rest/datasets
metadata.url =
# Name displayed in the help page for the institutional CRIS or external metadata system
metadata.system = CRIS
# URL displayed in the help page for the institutional CRIS or external metadata system
metadata.link = http://cris.example.com/

# Retention policy checker settings
# =================================
# How frequently the retention policy check job is run (in 'cron' format)
# Example: Check the retention policies each weekday at 9am
retentioncheck.schedule = 0 0 9 * * MON-FRI

# SFTP server settings
# ====================
# Default SFTP host
sftp.host = localhost
# Default SFTP port
sftp.port = 22
# Default SFTP path
sftp.rootPath = /
# Default SFTP key passphrase
sftp.passphrase = datavault

# Shibboleth authentication settings
# ==================================
# Shibboleth header containing the username
shibboleth.principal= uid
# Shibboleth header containing the user's first name
shibboleth.firstname = givenName
# Shibboleth header containing the user's last name
shibboleth.lastname = sn
# Shibboleth header containing the user's email
shibboleth.email = mail

# LDAP settings
# =============
# Set this to false if you don't need to retrieve attributes from LDAP
ldap.enabled = true
ldap.host = hostname
ldap.port = 636
ldap.useSsl = true
# In this example the uun is an account with privileged access to LDAP
ldap.dn = uid=uun,ou=people,o=myu.ed
ldap.password = secret
ldap.searchContext = ou=people,o=myu.ed
ldap.searchFilter = uid
# A list of the attributes you want to retrieve from LDAP
ldap.attrs = attr1,attr2,etc

Loading