From e9a5a933664b755887c7acd9888d5ba584877af0 Mon Sep 17 00:00:00 2001 From: Lukas Kuklinek Date: Mon, 15 Nov 2021 18:55:22 +0000 Subject: [PATCH 1/9] runtime: Cargo feature to make block production faster Add a compilation-time feature to shorten the block interval to 3 seconds. Intended mainly for testing. Use the `--features short-block-time` switch to Cargo to enable. --- runtime/Cargo.toml | 1 + runtime/src/lib.rs | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/runtime/Cargo.toml b/runtime/Cargo.toml index 1c0c972..f947e73 100644 --- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -248,6 +248,7 @@ path = "../pallets/pp" [features] default = ['std'] +short-block-time = [] runtime-benchmarks = [ 'frame-benchmarking', 'frame-support/runtime-benchmarks', diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 31fa527..f9951df 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -125,7 +125,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { /// up by `pallet_aura` to implement `fn slot_duration()`. /// /// Change this to adjust the block time. -pub const MILLISECS_PER_BLOCK: u64 = 60_000; //1 min +#[cfg(not(feature = "short-block-time"))] +pub const MILLISECS_PER_BLOCK: u64 = 60_000; // 1 min +#[cfg(feature = "short-block-time")] +pub const MILLISECS_PER_BLOCK: u64 = 3_000; // 3 sec // NOTE: Currently it is not possible to change the slot duration after the chain has started. // Attempting to do so will brick block production. From 6680699299cc339c4d3278929ed8291cf4909718 Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 10:16:56 +0100 Subject: [PATCH 2/9] Attempt to use short block times with CI --- .github/workflows/build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9f7d495..b92d81f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,9 +67,9 @@ jobs: with: submodules: recursive - name: Build - run: cargo build --release + run: cargo build --release --features short-block-time - name: Run tests - run: cargo test --release + run: cargo test --release --features short-block-time - name: Prepare functional tests uses: actions/setup-python@v2 with: From a2f451ad66bc62d3b53f1748f9446eddbce391b8 Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 11:15:00 +0100 Subject: [PATCH 3/9] Add test as artifacts from CI available to download on failure --- .github/workflows/build.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b92d81f..0f00a7d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -80,3 +80,9 @@ jobs: run: python -m pip install 'scalecodec == 0.11.18' - name: Run functional tests run: python test/functional/test_runner.py + - name: Save test artifacts on failure + uses: actions/upload-artifact@v2 + if: failure() + with: + name: test-artifacts + path: /tmp/mintlayer* From 217e4f599cb695e6bf27d9ad86a388f847ea8ae1 Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 13:08:30 +0100 Subject: [PATCH 4/9] Print list of tests running to simplify catching issues + reduce timeout --- test/functional/test_framework/test_node.py | 4 ++-- test/functional/test_runner.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index a457e96..67e7624 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -52,8 +52,8 @@ def __init__(self, i, dirname, extra_args, rpchost, timewait, binary, stderr, mo if timewait: self.rpc_timeout = timewait else: - # Wait for up to 600 seconds for the RPC server to respond - self.rpc_timeout = 600 + # Wait for up to 120 seconds for the RPC server to respond + self.rpc_timeout = 120 if binary is None: self.binary = os.getenv("NODEEXE", "mintlayer-core") else: diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 0ce8171..4ec72ba 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -326,6 +326,13 @@ def get_next(self): log_stderr)) if not self.jobs: raise IndexError('pop from empty list') + + # print test names that are running + running_test_names = [test_data[0] for test_data in self.jobs] + running_test_names_list = ["{}{}{}".format(BOLD[1], nm, BOLD[0]) for nm in running_test_names] + running_test_names_list = ", ".join(running_test_names_list) + logging.debug("Tests currently running: %s", running_test_names_list) + while True: # Return first proc that finishes time.sleep(.5) @@ -336,6 +343,7 @@ def get_next(self): # providing useful output. proc.send_signal(signal.SIGINT) if proc.poll() is not None: + # check if the test has finished log_out.seek(0), log_err.seek(0) [stdout, stderr] = [l.read().decode('utf-8') for l in (log_out, log_err)] log_out.close(), log_err.close() From 44eff6aa007fb1d1c31c3b5ced5ad5957abc667a Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 13:10:53 +0100 Subject: [PATCH 5/9] Disable parallelism of functional tests in CI --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f00a7d..5852630 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -79,7 +79,7 @@ jobs: - name: Install scalecodec run: python -m pip install 'scalecodec == 0.11.18' - name: Run functional tests - run: python test/functional/test_runner.py + run: python test/functional/test_runner.py --jobs 1 - name: Save test artifacts on failure uses: actions/upload-artifact@v2 if: failure() From f20d147844f348efa96df0b1b3a07d3cbf2f89b9 Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 13:16:52 +0100 Subject: [PATCH 6/9] Minor: Add plural for tests listing --- test/functional/test_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 4ec72ba..a279232 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -331,7 +331,7 @@ def get_next(self): running_test_names = [test_data[0] for test_data in self.jobs] running_test_names_list = ["{}{}{}".format(BOLD[1], nm, BOLD[0]) for nm in running_test_names] running_test_names_list = ", ".join(running_test_names_list) - logging.debug("Tests currently running: %s", running_test_names_list) + logging.debug("Test%s currently running: %s", "s" if len(running_test_names) > 1 else "", running_test_names_list) while True: # Return first proc that finishes From 61600109f60f184b9d8373dbb3e36f372b67b204 Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 15:09:45 +0100 Subject: [PATCH 7/9] Use paritydb instead of rocksdb on CI --- test/functional/test_framework/test_node.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 67e7624..e737f9a 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -65,6 +65,7 @@ def __init__(self, i, dirname, extra_args, rpchost, timewait, binary, stderr, mo port_rpc = rpc_port(i) port_p2p = p2p_port(i) self.args = [self.binary, "--dev", + "--database", "paritydb-experimental", "--base-path", self.datadir, "--log", "trace", "--name", "testnode%d" % i, From 697b9bb98f23a3e1e07aa0b83fac2d289b6dbda5 Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 15:09:58 +0100 Subject: [PATCH 8/9] Rename artifacts --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5852630..36429ed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -84,5 +84,5 @@ jobs: uses: actions/upload-artifact@v2 if: failure() with: - name: test-artifacts + name: functional-tests-logs path: /tmp/mintlayer* From e380f2d35296b185208f5454c4a0ffab3f08d537 Mon Sep 17 00:00:00 2001 From: Samer Afach Date: Tue, 16 Nov 2021 15:54:45 +0100 Subject: [PATCH 9/9] Enforce print order by flushing on WARNING print --- test/functional/test_runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index a279232..c4dd2ed 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -411,7 +411,7 @@ def check_script_list(src_dir): python_files = set([t for t in os.listdir(script_dir) if t[-3:] == ".py"]) missed_tests = list(python_files - set(map(lambda x: x.split()[0], ALL_SCRIPTS + NON_SCRIPTS))) if len(missed_tests) != 0: - print("%sWARNING!%s The following scripts are not being run: %s. Check the test lists in test_runner.py." % (BOLD[1], BOLD[0], str(missed_tests))) + print("%sWARNING!%s The following scripts are not being run: %s. Check the test lists in test_runner.py." % (BOLD[1], BOLD[0], str(missed_tests)), flush=True) if os.getenv('TRAVIS') == 'true': # On travis this warning is an error to prevent merging incomplete commits into master sys.exit(1)