Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Update test scripts and CI #657

Merged
merged 14 commits into from
Oct 21, 2021
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ jobs:
test-solidity:
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
batch: ['1-3', '2-3', '3-3']
steps:
- uses: actions/[email protected]
- uses: technote-space/get-diff-action@v5
Expand All @@ -93,7 +97,7 @@ jobs:
go.sum
- name: test-solidity
run: |
make test-solidity
./scripts/run-solidity-tests.sh --batch=${{ matrix.batch }}
if: "env.GIT_DIFF != ''"

liveness-test:
Expand Down
2 changes: 1 addition & 1 deletion scripts/run-solidity-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ else
yarn install
fi

yarn test --network ethermint
yarn test --network ethermint $@
41 changes: 39 additions & 2 deletions tests/solidity/test-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function checkTestEnv() {
.example('$0 --network ethermint test1 test2', 'run only test1 and test2 using ethermint network')
.help('h').alias('h', 'help')
.describe('network', 'set which network to use: ganache|ethermint')
.describe('batch', 'set the test batch in parallelized testing. Format: %d-%d')
.boolean('verbose-log').describe('verbose-log', 'print ethermintd output, default false')
.argv;

Expand All @@ -45,6 +46,29 @@ function checkTestEnv() {
}
}

if (argv.batch) {

const [toRunBatch, allBatches] = argv.batch.split('-').map(e => Number(e));

console.log([toRunBatch, allBatches]);
if (!toRunBatch || !allBatches) {
panic('bad batch input format');
}

if (toRunBatch > allBatches) {
panic('test batch number is larger than batch counts');
}

if (toRunBatch <= 0 || allBatches <=0 ) {
panic('test batch number or batch counts must be non-zero values');
}

runConfig.batch = {};
runConfig.batch.this = toRunBatch;
runConfig.batch.all = allBatches;

}

// only test
runConfig.onlyTest = argv['_'];
runConfig.verboseLog = !!argv['verbose-log'];
Expand All @@ -54,7 +78,7 @@ function checkTestEnv() {

}

function loadTests() {
function loadTests(runConfig) {
const validTests = [];
fs.readdirSync(path.join(__dirname, 'suites')).forEach(dirname => {
const dirStat = fs.statSync(path.join(__dirname, 'suites', dirname));
Expand Down Expand Up @@ -88,7 +112,18 @@ function loadTests() {
}
validTests.push(dirname);
})
return validTests;

if (runConfig.batch) {
const chunkSize = Math.ceil(validTests.length / runConfig.batch.all);
const toRunTests = validTests.slice(
(runConfig.batch.this - 1) * chunkSize,
runConfig.batch.this === runConfig.batch.all ? undefined : runConfig.batch.this * chunkSize
);
return toRunTests;
}
else {
return validTests;
}
}

function performTestSuite({ testName, network }) {
Expand Down Expand Up @@ -175,6 +210,8 @@ async function main() {
const runConfig = checkTestEnv();
const allTests = loadTests(runConfig);

console.log(`Running Tests: ${allTests.join()}`);

const proc = await setupNetwork({ runConfig, timeout: 50000 });
await performTests({ allTests, runConfig });

Expand Down