Commit Graph

97 Commits

Author SHA1 Message Date
ghubstan
c19afebc04
Fix 'bitcoind not found' error message 2020-07-15 19:26:16 -03:00
ghubstan
d108d89bb2
Fix comment and code styling 2020-07-15 11:13:00 -03:00
ghubstan
cf3b545173
Fix hardcoded bitcoin.conf property values 2020-07-15 10:56:35 -03:00
ghubstan
a00bc4b414
Add --bisqAppInitTime=<Long> config option
This change makes configurable the amount of time (ms) each Bisq
instance is given to initialize before starting (a) another Bisq
instance, or (b) tests.
2020-07-15 10:45:05 -03:00
ghubstan
28aefc5cb1
Add tests for resetting a wallet password 2020-07-14 16:17:10 -03:00
ghubstan
2cf7915f25
Add wallet protect method tests
Some of these 'method' tests make more than one gRPC call, but
they are for checking correctness of a single gRPC method,
and don't quite fall into the 'scenario' test category.
2020-07-14 15:04:42 -03:00
ghubstan
5df0b1ec4b
Refactor ApiTestCase class hierarchy
Also added a new base ScenarioTest class, which extends
MethodTest;  Method and Scenario tests cases have access to gRPC
service stubs, but end to end test cases should never use them.
2020-07-14 14:20:26 -03:00
ghubstan
498939a9ff
Allow more time for background app shutdown 2020-07-14 12:41:41 -03:00
ghubstan
6b738f7443
Replace config 'numSetupTasks' with 'supportingApps'
This change replaces the non-intuitive numSetupTasks=<Integer>
configuration option with a supportingApps=<String> option.  It
accepts a comma delimited list of app names, and determines
which background apps will be started in @BeforeClass.

None of the current method tests need all supporting apps, and
this change will reduce scaffolding setup and teardown time.

The current method test cases were changed to use this option.
WalletProtectionTest and GetVersionTest only need to start "alicedaemon".
GetBalanceTest needs "bitcoind,seednode,arbdaemon,alicedaemon".
2020-07-14 12:37:13 -03:00
ghubstan
45c1a97938
Fix codacy problem in bash script
Double quote to prevent globbing and word splitting.
2020-07-14 12:21:13 -03:00
ghubstan
8ed44b8cee
Remove @Skip annotaion
We are using JUnit now and can use @Ignore
2020-07-14 10:37:32 -03:00
ghubstan
1acf340f79
Get rid of references to removed @Skip annotation 2020-07-14 10:35:14 -03:00
ghubstan
84af092401
Add driver for running method tests
API test cases are not in a maven/gradle project test folder.
IDEs may not automatically configure JUnit test launchers,
and a gradle build command will not automatically run tests.
This class is provided as a convenience until gradle tasks
for running test cases are implemented.
2020-07-13 22:17:05 -03:00
ghubstan
4f08ec3edc
Add first JUnit 'method' tests
These @Order-ed test cases should be run with OrderedRunner.

They are called 'method' tests because they are the closest
thing to an API 'unit' test.  Method tests are not end to end
tests;  they have access to gRPC service stubs and do asserts
on Java values.  We can write 'method' tests for the new
gRPC methods we need to implement (test driven development).

Some notes about the three API test categories...

The plan is to categorize some of the narrower functional tests
as 'scenario' tests.  Like 'method' tests, 'scenario' tests will
have  access to gRPC service stubs and do asserts on Java values,
but they will cover use cases requiring several gRPC and bitcoin-cli
method calls.  One example is funding a wallet:  using bitcoin-cli
and bisq-cli to generate new addresses, send BTC from bitcoin-core
to a Bisq wallet, generate a bitcoin block, and check the Bisq
wallet's balance.  Another example is wallet unlocking/locking
scenarios that are a bit more complex than 'unit' or 'method' tests.

The third category of tests will be end to end, and live in an
'e2e' package.  They will cover more complex use cases and
do asserts on the Bisq CLI's console output (stdout/stderr),
not return values from gRPC service stubs.

There may sometimes be a fine line between what is a 'scenario'
test and an 'e2e' test.  But what starts out as a 'scenario' test
during test driven development can migrate to an 'e2e' test after
thorough testing in the quicker 'scenario' dev/test cycle.
2020-07-13 20:34:25 -03:00
ghubstan
080952b1d7
Support @Order-ing of JUnit tests 2020-07-13 20:30:48 -03:00
ghubstan
e17480ad8f
Remove hacked method tests
Although JUnit is geared towards running randomly ordered unit
tests, we can use it to write API tests to be run in a pre-defined
order.  This is necessary because API tests will be functional
(narrow to broad) and end-to-end;  we want to be able to write
@Test methods that run in @Order.

The next commit will add a JUnit OrderedRunner class, and an @Order
annotation.
2020-07-13 20:13:30 -03:00
ghubstan
486f06beef
Refresh dao-setup files in Scaffold setup
Many test cases will need to run on a clean, initialized dao-setup;
we do not want call dao-setup.gradle tasks from Java.

For now, every JUnit test case will refresh the dao-setup data in
@BeforeClass, but @AfterClass will not clean out the dao-setup files.
We want to be able to look at bitcoin-core and bisq app data & log
files after a test.

Given the difficulty of refreshing dao-setup files using Java,
I took a short cut and used the apitest.linux pkg's BashCommand
to replace dao-setup files.

Some bitcoin.conf and blocknotify configuratation logic was
also moved from ApiTestConfig to Scaffold in this commit.
2020-07-13 19:54:39 -03:00
ghubstan
2678b31a18
Remove test scaffolding logic from ApiTestConfig 2020-07-13 19:52:21 -03:00
ghubstan
84976fef35
Fix varible names 2020-07-13 19:51:27 -03:00
ghubstan
d782e8d8ec
Do not run dummy test from driver 2020-07-13 19:50:33 -03:00
ghubstan
35ff4e5d79
Delete commented statement 2020-07-13 19:48:59 -03:00
ghubstan
4d5c767902
Fix codacy problem
Add comment inside empty method.
2020-07-13 10:28:31 -03:00
ghubstan
458d2f3f4f
Add license note 2020-07-12 22:15:16 -03:00
ghubstan
fae661c912
Run MethodTestSuite 2020-07-12 22:05:36 -03:00
ghubstan
65e3370d51
Add license note, format tearDown(), fix comment 2020-07-12 22:03:46 -03:00
ghubstan
db5a685468
Make init() method public 2020-07-12 21:56:51 -03:00
ghubstan
81aeeddc4a
Add MethodTestSuite 2020-07-12 21:52:23 -03:00
ghubstan
0edcc3baa8
Add first method test cases
These are method test cases for gRPC methods that have already been
well tested by :cli/test.sh
2020-07-12 21:48:22 -03:00
ghubstan
96cabfb177
Support @Skip on test classes and methods
Add super class for all test types (method, scenario, end-to-end),
and an class & method level annotation for skipping tests.
2020-07-12 21:44:21 -03:00
ghubstan
390cba1b75
Fix codacy problem
Codacy wants comments inside an empty method.
2020-07-12 14:53:32 -03:00
ghubstan
ffe376e8dc
Fix codacy problems
Avoid throwing raw exception types.

Document empty method body.
2020-07-12 14:39:20 -03:00
ghubstan
2c10836a69
Expose grpc service stubs
Added :proto to the :apitest classpath for access to grpc
service stubs (to be) used in method (unit) tests.  Added new
GrpcStubs class to expose the grpc service stubs to method and
scenario tests.

The larger goal of :apitest is end to end testing, where :cli's
console output is checked for correctness.

This change partially addresses two other important use cases:

 * "method" testing -- an analog to unit testing
 * "scenario" testing -- an analog to narrow functional testing

For example, tests in the apitest.method package will directly
call grpc services, and asserts will be made on the return values
instead of console output.

Tests in the apitest.scenario package will check correctness
for broader use cases, such as funding a wallet, encrypting then
unlocking a wallet  for a specific time frame, or checking error
messages from the server when a "getbalance" call is made after
an "unlockwallet" timeout has expired.

The broader end to end tests will not use grpc stubs.
2020-07-12 13:55:08 -03:00
ghubstan
87525ca85d
Move test setup scaffolding into new Scaffold class
ApiTestMain will run all defined tests, but we also want to run
individual test suites and test cases, and they will need to
run the setup tasks as well.
2020-07-12 13:36:10 -03:00
ghubstan
851902117d
Add line break in front of port config 2020-07-12 13:23:53 -03:00
ghubstan
a1e2536ed5
Fix hanging background process problem
SetupTask submissions for Bisq background apps seednode, arbnode,
etc., would not always complete due to a blocking stderr stream
handler thread.join() call.  This change makes waiting on a bash
process err stream optional.
2020-07-11 18:15:17 -03:00
ghubstan
898219aba5
Assume bitcoin-core is statically linked to berkeley-db
The `berkeleyDbLibPath` option now defaults to an empty string.
If not set to a berkeley lib path on the command line or the
apitest.properties file, this option is ignored, and 'bitcoind'
will be started without first exporting the berkeley db library
path.

In other words:  If the bitcoind binary is dynamically linked to
berkeley db libs, export the configured berkeley-db lib path before
starting 'bitcoind'.  If statically linked,  the berkeley db lib
path will not be exported.

Also fixed exception msgs to show missing config file's absolute path.
2020-07-11 10:26:26 -03:00
ghubstan
798fde847b
Fix error msgs 2020-07-10 14:27:25 -03:00
ghubstan
ca378cdd13
Fix error msg spacing 2020-07-10 14:24:35 -03:00
ghubstan
05d0ce0ef8
Fix codacy problem
Avoid throwing null pointer exceptions.
2020-07-09 16:56:09 -03:00
ghubstan
efbaa5be73
Fix codacy problems
Avoid throwing raw exception types.

Combine nested if statements.
2020-07-09 16:54:03 -03:00
ghubstan
09929c833f
Fix codacy problems
Unnecessary use of fully qualified name 'System.exit' due to existing
static import 'java.lang.System.exit'.  (line 100)

Avoid throwing raw exception types.  (lines 295, 302)
2020-07-09 16:49:16 -03:00
ghubstan
e9baebc443
Add build tasks for installing dao-setup files
This gradle file is 'applied' by the main build file.

Usage:

  Run a full clean, build, download dao-setup.zip,
  and install the zip files contents in directory
  apitest/build/resources/main:

    ./gradlew clean build :apitest:installDaoSetup

  Download (if necessary) the dao-setup.zip file
  and install its contents in directory
  apitest/build/resources/main  (no build).

    ./gradlew :apitest:installDaoSetup
2020-07-09 16:03:46 -03:00
ghubstan
ae3b263cac
Add :apitest main driver, setup task & dummy tests
The driver class uses an ExecutorService to submit Callable
tasks for starting bitcoind and Bisq nodes as Linux background
processes.

By default, ApiTestMain starts background processes to support
regtest/dao testing, runs a few bitcoin-cli commands, then
shuts down all background processes before exiting.
(Actual API test suites have not been implemented yet.)

ApiTestConfig options can be used to skip tests and/or leave
background processes running indefinitely.
2020-07-09 15:49:12 -03:00
ghubstan
c0c75e2471
Support starting bitcoin & bisq apps on Linux
The apitest.linux package is for running random bash commands,
running 'bitcoind -regtest', running random 'bitcoin-cli -regtest'
commands, and spinning up Bisq apps such as seednode, arbnode,
and bob & alice nodes.

All but random bash and bitcoin-cli commands are run in the background.

The bitcoin-cli response processing is crude;  a more sophiticated
bitcoin-core rpc interface is not in the scope of this PR.
2020-07-09 15:35:45 -03:00
ghubstan
77b6878ec6
Add script to get Bisq app pid
Finding the pid of background linux/java processes has been
difficult to do from java, so a bash script is provided to
simplify the task.
2020-07-09 15:30:22 -03:00
ghubstan
e0c27eedcf
Add main resource files
* apitest.properties - config file for customizing ApiTestConfig
  options

* logback.xml - logging config file, will override logback files
  found in classpath

* bitcoin.conf - bitcoin-core regtest config file, overwritten
  during startup with correct path to blocknofity

* blocknotify - bitcoin-core blocknotify config file
2020-07-09 15:27:01 -03:00
ghubstan
88b5e9dbad
Add configuration support
ApiTestConfig works like :common Config, but specific to this subproject.

BisqAppConfig is an enumeration specifying Bisq desktop and daemon
options for running seednode, arbnode, bob & alices nodes in regtest /
full-dao mode.
2020-07-09 15:11:42 -03:00