diff --git a/.travis.yml b/.travis.yml index 3d8e9c42412..0d178eaa525 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/core/pom.xml b/core/pom.xml index c32ff64ac6d..6eae1201011 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -51,6 +51,27 @@ + + dev + + true + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + **/PostgresFullPrunedBlockChainIT.java + **/MySQLFullPrunedBlockChainIT.java + + + + + + update-protobuf @@ -92,7 +113,7 @@ - no-network + travis @@ -105,6 +126,10 @@ + + org.apache.maven.plugins + maven-failsafe-plugin + @@ -183,6 +208,8 @@ cglib:cglib-nodep:2.2:jar:null:test:59afed7ab65e7ec6585d5bc60556c3cbd203532b + ch.qos.logback:logback-classic:1.2.3:jar:null:test:7c4f3c474fb2c041d8028740440937705ebb473a + ch.qos.logback:logback-core:1.2.3:jar:null:test:864344400c3d4d92dfeb0a305dc87d953677c03c com.fasterxml.jackson.core:jackson-annotations:2.5.0:jar:null:test:a2a55a3375bc1cef830ca426d68d2ea22961190e com.fasterxml.jackson.core:jackson-core:2.5.1:jar:null:test:e2a00ad1d7e540ec395e9296a34da484c8888d4d com.fasterxml.jackson.core:jackson-databind:2.5.2:jar:null:test:2b4dd13fbe6f8c6b146d4c3b7fd70862f136802d @@ -275,12 +302,15 @@ org.jacoco jacoco-maven-plugin - 0.7.5.201505241946 + 0.7.9 **/Protos*.class + **/ClientState* + **/ServerState* org/bitcoinj/jni/* - org/bitcoin/* + org/bitcoin/**/* + **/HttpDiscovery.class @@ -290,24 +320,23 @@ prepare-agent - ${project.build.directory}/coverage-reports/jacoco.exec + ${project.build.directory}/jacoco.exec surefireArgLine - post-unit-test - test + pre-integration-test + pre-integration-test - report + prepare-agent - ${project.build.directory}/coverage-reports/jacoco.exec - ${project.reporting.outputDirectory}/jacoco + ${project.build.directory}/jacoco.exec + failsafeArgLine default-report - prepare-package report @@ -315,22 +344,34 @@ - + org.apache.maven.plugins maven-surefire-plugin -Xmx1024m ${surefireArgLine} alphabetical - - - java.util.logging.config.file - src/test/resources/logging.properties - - + + + org.apache.maven.plugins + maven-failsafe-plugin + + alphabetical + ${failsafeArgLine} + + + + + integration-test + verify + + + + + org.eluder.coveralls @@ -341,39 +382,6 @@ - - junit - junit - 4.12 - test - - - org.easymock - easymock - 3.2 - test - - - - org.slf4j - slf4j-jdk14 - 1.7.20 - test - - - com.fasterxml.jackson.core - jackson-databind - 2.5.2 - test - - - com.h2database - h2 - 1.3.167 - true - com.madgag.spongycastle core @@ -404,17 +412,35 @@ scrypt 1.4.0 - - - postgresql - postgresql - 9.1-901.jdbc4 - true + org.bitcoinj + orchid + 1.2.1 + + + com.squareup.okhttp + okhttp + 2.7.2 + + + + + com.h2database + h2 + 1.3.167 + true + + + + + postgresql + postgresql + 9.1-901.jdbc4 + true - - + + mysql mysql-connector-java 5.1.33 @@ -426,16 +452,31 @@ 1.8 true + + - org.bitcoinj - orchid - 1.2.1 + junit + junit + 4.12 + test - com.squareup.okhttp - okhttp - 2.7.2 + org.easymock + easymock + 3.2 + test + + + ch.qos.logback + logback-classic + 1.2.3 + test + + + com.fasterxml.jackson.core + jackson-databind + 2.5.2 + test - diff --git a/core/src/test/java/org/bitcoinj/core/AbstractFullPrunedBlockChainTest.java b/core/src/test/java/org/bitcoinj/core/AbstractFullPrunedBlockChainIT.java similarity index 99% rename from core/src/test/java/org/bitcoinj/core/AbstractFullPrunedBlockChainTest.java rename to core/src/test/java/org/bitcoinj/core/AbstractFullPrunedBlockChainIT.java index aa93a1884b1..67105862616 100644 --- a/core/src/test/java/org/bitcoinj/core/AbstractFullPrunedBlockChainTest.java +++ b/core/src/test/java/org/bitcoinj/core/AbstractFullPrunedBlockChainIT.java @@ -46,11 +46,11 @@ * 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() { diff --git a/core/src/test/java/org/bitcoinj/core/FullBlockTestGenerator.java b/core/src/test/java/org/bitcoinj/core/FullBlockTestGenerator.java index 08481e13b5c..24d942ebc4f 100644 --- a/core/src/test/java/org/bitcoinj/core/FullBlockTestGenerator.java +++ b/core/src/test/java/org/bitcoinj/core/FullBlockTestGenerator.java @@ -139,7 +139,7 @@ public RuleList(List list, Map hashHeaderMap, int maxim } 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; diff --git a/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainTest.java b/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainIT.java similarity index 94% rename from core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainTest.java rename to core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainIT.java index 1c2301d03c5..c47a076b3a4 100644 --- a/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainTest.java +++ b/core/src/test/java/org/bitcoinj/core/H2FullPrunedBlockChainIT.java @@ -24,7 +24,7 @@ /** * An H2 implementation of the FullPrunedBlockStoreTest */ -public class H2FullPrunedBlockChainTest extends AbstractFullPrunedBlockChainTest { +public class H2FullPrunedBlockChainIT extends AbstractFullPrunedBlockChainIT { @After public void tearDown() throws Exception { deleteFiles(); diff --git a/core/src/test/java/org/bitcoinj/core/LevelDBFullPrunedBlockChainTest.java b/core/src/test/java/org/bitcoinj/core/LevelDBFullPrunedBlockChainIT.java similarity index 94% rename from core/src/test/java/org/bitcoinj/core/LevelDBFullPrunedBlockChainTest.java rename to core/src/test/java/org/bitcoinj/core/LevelDBFullPrunedBlockChainIT.java index 12c2788d63c..32876cb91db 100644 --- a/core/src/test/java/org/bitcoinj/core/LevelDBFullPrunedBlockChainTest.java +++ b/core/src/test/java/org/bitcoinj/core/LevelDBFullPrunedBlockChainIT.java @@ -26,8 +26,8 @@ /** * An H2 implementation of the FullPrunedBlockStoreTest */ -public class LevelDBFullPrunedBlockChainTest extends - AbstractFullPrunedBlockChainTest { +public class LevelDBFullPrunedBlockChainIT extends + AbstractFullPrunedBlockChainIT { @After public void tearDown() throws Exception { deleteFiles(); diff --git a/core/src/test/java/org/bitcoinj/core/MemoryFullPrunedBlockChainTest.java b/core/src/test/java/org/bitcoinj/core/MemoryFullPrunedBlockChainIT.java similarity index 93% rename from core/src/test/java/org/bitcoinj/core/MemoryFullPrunedBlockChainTest.java rename to core/src/test/java/org/bitcoinj/core/MemoryFullPrunedBlockChainIT.java index 68f3d55c313..7d9825a9052 100644 --- a/core/src/test/java/org/bitcoinj/core/MemoryFullPrunedBlockChainTest.java +++ b/core/src/test/java/org/bitcoinj/core/MemoryFullPrunedBlockChainIT.java @@ -21,7 +21,7 @@ /** * 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 diff --git a/core/src/test/java/org/bitcoinj/core/MySQLFullPrunedBlockChainTest.java b/core/src/test/java/org/bitcoinj/core/MySQLFullPrunedBlockChainIT.java similarity index 81% rename from core/src/test/java/org/bitcoinj/core/MySQLFullPrunedBlockChainTest.java rename to core/src/test/java/org/bitcoinj/core/MySQLFullPrunedBlockChainIT.java index e26ddcb14b5..2eaab30170f 100644 --- a/core/src/test/java/org/bitcoinj/core/MySQLFullPrunedBlockChainTest.java +++ b/core/src/test/java/org/bitcoinj/core/MySQLFullPrunedBlockChainIT.java @@ -21,12 +21,12 @@ 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 FullPrunedBlockStore createStore(NetworkParameters params, int blockCount 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 diff --git a/core/src/test/java/org/bitcoinj/core/PostgresFullPrunedBlockChainTest.java b/core/src/test/java/org/bitcoinj/core/PostgresFullPrunedBlockChainIT.java similarity index 93% rename from core/src/test/java/org/bitcoinj/core/PostgresFullPrunedBlockChainTest.java rename to core/src/test/java/org/bitcoinj/core/PostgresFullPrunedBlockChainIT.java index 57b448b9d17..d0d848df745 100644 --- a/core/src/test/java/org/bitcoinj/core/PostgresFullPrunedBlockChainTest.java +++ b/core/src/test/java/org/bitcoinj/core/PostgresFullPrunedBlockChainIT.java @@ -22,10 +22,9 @@ 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'; diff --git a/core/src/test/resources/logback-test.xml b/core/src/test/resources/logback-test.xml new file mode 100644 index 00000000000..e136e9cc372 --- /dev/null +++ b/core/src/test/resources/logback-test.xml @@ -0,0 +1,18 @@ + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + \ No newline at end of file diff --git a/core/src/test/resources/logging.properties b/core/src/test/resources/logging.properties deleted file mode 100644 index 0aa499fae1d..00000000000 --- a/core/src/test/resources/logging.properties +++ /dev/null @@ -1,2 +0,0 @@ -handlers=java.util.logging.ConsoleHandler -org.bitcoinj.level=OFF \ No newline at end of file diff --git a/docs/designdocs/MavenBuildProcess.md b/docs/designdocs/MavenBuildProcess.md new file mode 100644 index 00000000000..7e0c045fce8 --- /dev/null +++ b/docs/designdocs/MavenBuildProcess.md @@ -0,0 +1,57 @@ +# 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. diff --git a/pom.xml b/pom.xml index f206d53acd0..1061e63d7ec 100644 --- a/pom.xml +++ b/pom.xml @@ -1,266 +1,270 @@ - 4.0.0 + 4.0.0 - cash.bitcoinj - bitcoinj-parent - 0.15-SNAPSHOT - pom + cash.bitcoinj + bitcoinj-parent + 0.15-SNAPSHOT + pom - - core - examples - tools - wallettemplate - + + core + examples + tools + wallettemplate + - - org.sonatype.oss - oss-parent - 7 - + + org.sonatype.oss + oss-parent + 7 + - - scm:git:https://github.com/bitcoinj-cash/bitcoinj - scm:https://github.com/bitcoinj-cash/bitcoinj - scm:git:https://github.com/bitcoinj-cash/bitcoinj - + + scm:git:https://github.com/bitcoinj-cash/bitcoinj + scm:https://github.com/bitcoinj-cash/bitcoinj + scm:git:https://github.com/bitcoinj-cash/bitcoinj + - bitcoinj Parent - Provides the common configuration for the BitCoinJ modules - http://bitcoinj.cash/ + bitcoinj Parent + Provides the common configuration for the BitCoinJ modules + http://bitcoinj.cash/ - - - Apache 2 - http://www.apache.org/licenses/LICENSE-2.0 - repo - A business-friendly OSS license - - + + + Apache 2 + http://www.apache.org/licenses/LICENSE-2.0 + repo + A business-friendly OSS license + + - - GitHub - https://github.com/bitcoinj-cash/bitcoinj/issues - + + GitHub + https://github.com/bitcoinj-cash/bitcoinj/issues + - - - bitcoinj.cash Google Group - https://groups.google.com/forum/#!forum/bitcoinj-cash - - + + + bitcoinj.cash Google Group + https://groups.google.com/forum/#!forum/bitcoinj-cash + + - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - + + 3.0.4 + - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - true - true - - + + UTF-8 + gen + 1.7.25 + - - maven-jar-plugin - - - false - - - - - maven-javadoc-plugin - - true - - + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + ossrh + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + - - org.sonatype.plugins - nexus-staging-maven-plugin - 1.6.5 - true - - ossrh - https://oss.sonatype.org/ - false - - - - - - - maven-clean-plugin - 2.6.1 - - - maven-compiler-plugin - 3.2 - - - maven-dependency-plugin - 2.10 - - - maven-deploy-plugin - 2.8.2 - - - maven-enforcer-plugin - 1.4 - - - maven-install-plugin - 2.5.2 - - - maven-jar-plugin - 2.6 - - - maven-javadoc-plugin - 2.10.2 - - - maven-resources-plugin - 2.7 - - - maven-shade-plugin - 2.3 - - - maven-site-plugin - 3.4 - - - maven-source-plugin - 2.4 - - - org.codehaus.mojo - cobertura-maven-plugin - 2.7 - - - maven-surefire-plugin - 2.19.1 - - - - - - - - org.slf4j - slf4j-api - 1.7.20 - - - - org.slf4j - slf4j-jdk14 - 1.7.20 - runtime - true - - + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + true + true + + - - 3.0.4 - + + maven-jar-plugin + + + false + + + - - UTF-8 - gen - + + maven-javadoc-plugin + + true + + - - - doclint-java8-disable - - [1.8,) - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - -Xdoclint:none - - + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.5 + true + + ossrh + https://oss.sonatype.org/ + false + + - - + + + + maven-clean-plugin + 2.6.1 + + + maven-compiler-plugin + 3.2 + + + maven-dependency-plugin + 2.10 + + + maven-deploy-plugin + 2.8.2 + + + maven-enforcer-plugin + 1.4 + + + maven-install-plugin + 2.5.2 + + + maven-jar-plugin + 2.6 + + + maven-javadoc-plugin + 2.10.2 + + + maven-resources-plugin + 2.7 + + + maven-shade-plugin + 2.3 + + + maven-site-plugin + 3.4 + + + maven-source-plugin + 2.4 + + + org.codehaus.mojo + cobertura-maven-plugin + 2.7 + + + maven-surefire-plugin + 2.20.1 + + + maven-failsafe-plugin + 2.20.1 + + + + + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + + + + + + org.slf4j + slf4j-api + + + + + + + dev + + true + + + + + + travis + - - release - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - verify - - jar-no-fork - - - - + + release + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + verify + + jar-no-fork + + + + - - org.apache.maven.plugins - maven-javadoc-plugin - - - attach-javadocs - - jar - - - - + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + + - - org.apache.maven.plugins - maven-gpg-plugin - 1.5 - - - sign-artifacts - verify - - sign - - - - - - - - + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + +