Commit 3cbc3fbb authored by Daniel Connolly's avatar Daniel Connolly

separate integration tests and enable for travis-ci.org (#6)

Merging this in, it optimizes test execution.
parent 24507359
......@@ -3,13 +3,31 @@ sudo: false
dist: trusty
language: java
jdk: oraclejdk8
install: true # remove default
addons:
postgresql: "9.3" # min supported version
cache:
directories:
- $HOME/.m2
services:
- mysql
install: true # disable default because no need to do the mvn install before mvn verify
before_script:
- psql -c "create user bitcoinj with password 'password';" -U postgres
- psql -c 'create database bitcoinj_test owner bitcoinj;' -U postgres
- mysql -e 'CREATE DATABASE bitcoinj_test;'
- mysql -e "grant all PRIVILEGES on bitcoinj_test.* to 'bitcoinj' identified by 'password';"
- mysql -e 'SET GLOBAL max_allowed_packet=20971520;'
script:
- mvn -q clean install -Pno-network
- jdk_switcher use openjdk7
- cd core
- mvn -q clean package -Pno-network
- mvn verify -Ptravis -Dmaven.javadoc.skip=true
# to run one specific test - in this case only testFirst100kBlocksWithCustomSchema test in PostgresFullPrunedBlockChainIT class
# - mvn clean verify -Ptravis -Dmaven.javadoc.skip=true -Dit.test=PostgresFullPrunedBlockChainIT#testFirst100kBlocksWithCustomSchema -Dtest=nothing -DfailIfNoTests=false
# run only mysql integration tests
# - mvn clean verify -Ptravis -Dmaven.javadoc.skip=true -Dit.test=MySQLFullPrunedBlockChainIT -Dtest=nothing -DfailIfNoTests=false
after_success:
- cd ../core
- cd core
- mvn jacoco:report coveralls:report
This diff is collapsed.
......@@ -46,11 +46,11 @@ import org.junit.rules.ExpectedException;
* We don't do any wallet tests here, we leave that to {@link ChainSplitTest}
*/
public abstract class AbstractFullPrunedBlockChainTest {
public abstract class AbstractFullPrunedBlockChainIT {
@org.junit.Rule
public ExpectedException thrown = ExpectedException.none();
private static final Logger log = LoggerFactory.getLogger(AbstractFullPrunedBlockChainTest.class);
private static final Logger log = LoggerFactory.getLogger(AbstractFullPrunedBlockChainIT.class);
protected static final NetworkParameters PARAMS = new UnitTestParams() {
@Override public int getInterval() {
......
......@@ -139,7 +139,7 @@ class RuleList {
}
public class FullBlockTestGenerator {
// Used by BitcoindComparisonTool and AbstractFullPrunedBlockChainTest to create test cases
// Used by BitcoindComparisonTool and AbstractFullPrunedBlockChainIT to create test cases
private NetworkParameters params;
private ECKey coinbaseOutKey;
private byte[] coinbaseOutKeyPubKey;
......
......@@ -24,7 +24,7 @@ import java.io.File;
/**
* An H2 implementation of the FullPrunedBlockStoreTest
*/
public class H2FullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest {
public class H2FullPrunedBlockChainIT extends AbstractFullPrunedBlockChainIT {
@After
public void tearDown() throws Exception {
deleteFiles();
......
......@@ -26,8 +26,8 @@ import java.io.File;
/**
* An H2 implementation of the FullPrunedBlockStoreTest
*/
public class LevelDBFullPrunedBlockChainTest extends
AbstractFullPrunedBlockChainTest {
public class LevelDBFullPrunedBlockChainIT extends
AbstractFullPrunedBlockChainIT {
@After
public void tearDown() throws Exception {
deleteFiles();
......
......@@ -21,7 +21,7 @@ import org.bitcoinj.store.MemoryFullPrunedBlockStore;
/**
* A MemoryStore implementation of the FullPrunedBlockStoreTest
*/
public class MemoryFullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest
public class MemoryFullPrunedBlockChainIT extends AbstractFullPrunedBlockChainIT
{
@Override
public FullPrunedBlockStore createStore(NetworkParameters params, int blockCount) throws BlockStoreException
......
......@@ -21,12 +21,12 @@ import org.bitcoinj.store.FullPrunedBlockStore;
import org.bitcoinj.store.MySQLFullPrunedBlockStore;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
/**
* A MySQL implementation of the {@link AbstractFullPrunedBlockChainTest}
* A MySQL implementation of the {@link AbstractFullPrunedBlockChainIT}
*/
@Ignore("enable the mysql driver dependency in the maven POM")
public class MySQLFullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest {
public class MySQLFullPrunedBlockChainIT extends AbstractFullPrunedBlockChainIT {
@After
public void tearDown() throws Exception {
......@@ -49,4 +49,11 @@ public class MySQLFullPrunedBlockChainTest extends AbstractFullPrunedBlockChainT
public void resetStore(FullPrunedBlockStore store) throws BlockStoreException {
((MySQLFullPrunedBlockStore)store).resetStore();
}
@Override
@Test
@Ignore("causes error on travis MySQL - redo log not big enough")
// The size of BLOB/TEXT data inserted in one transaction is greater than 10% of redo log size. Increase the redo log size using innodb_log_file_size.
public void testGeneratedChain() {
}
}
\ No newline at end of file
......@@ -22,10 +22,9 @@ import org.junit.Ignore;
import org.junit.Test;
/**
* A Postgres implementation of the {@link AbstractFullPrunedBlockChainTest}
* A Postgres implementation of the {@link AbstractFullPrunedBlockChainIT}
*/
@Ignore("enable the postgres driver dependency in the maven POM")
public class PostgresFullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest
public class PostgresFullPrunedBlockChainIT extends AbstractFullPrunedBlockChainIT
{
// Replace these with your postgres location/credentials and remove @Ignore to test
// You can set up a fresh postgres with the command: create user bitcoinj superuser password 'password';
......
<configuration debug="false">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!--
turn logs off by default for tests
to debug tests you might need to increase this, but be aware that a lot of logs are produced
including intentional warnings and errors
-->
<root level="OFF">
<appender-ref ref="STDOUT" />
</root>
</configuration>
\ No newline at end of file
handlers=java.util.logging.ConsoleHandler
org.bitcoinj.level=OFF
\ No newline at end of file
# Maven Build Process
* to run unit tests - `mvn clean test`
* to run unit tests & integration tests - `mvn clean verify`
Coverage reports are produced for bitcoincashj-core by the integration tests and are available
at `core/target/site/jacoco/index.html`.
## Profiles
The default profile is the `dev` profile. This profile will exclude Integration tests that have
external dependencies (e.g. Postgresql, MySQL).
The `travis` profile is used for travis-ci.org. This profile will include all Integration tests.
## MySQL Integration Tests
To run the MySQL Integration tests locally, you will need a standard MySQL installation. The following SQL commands create a database and user account:
```
CREATE DATABASE bitcoinj_test;
GRANT ALL PRIVILEGES ON bitcoinj_test.* TO 'bitcoinj' IDENTIFIED BY 'password';
SET GLOBAL max_allowed_packet=20971520;
```
Notes:
* the maximum allowed packet size must be at least 20MB. The command above will set this properly until the next MySQL restart
* this is not a secure configuration, only expose the MySQL on localhost and delete the user and database when no longer needed
## PostgreSQL Integration Tests
To run the PostgreSQL integration tests locally, you will need a standard PostgreSQL installation, version 9.3 or higher. The following SQL commands
create a database and user account for the tests:
```
create user bitcoinj with password 'password';
create database bitcoinj_test owner bitcoinj;
```
Notes:
* this is not a secure configuration, only expose the PostgreSQL on localhost and delete the user and database when no longer needed
## Process Design Goals
* follow Maven philosophy & be as standard as possible
* devs can immediately get started with defaults
* separate unit and integration tests
* travis-ci.org support
* coveralls.io support
Unit tests must not have external dependencies and must be fast. Developers must be
able to execute these tests frequently without disrupting flow of work. Unit tests
which take too much time should be moved to the integration test set.
Integration tests are divided into a number of groups. Tests in the base group must
have no external dependencies except disk, io, memory, network. Tests which have other
external dependencies (e.g. Postgres, MySQL) must be grouped according to the
dependency. By default, only the tests from the base group are performed.
The tests from all groups must be performed by Travis.
Coverage reports must be produced for bitcoincashj-core by the Integration tests. Travis must
upload these to coveralls.io.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment