Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1823 flaky acceptance tests #6

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/acceptance-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,29 @@ jobs:
- name: Build Typescript
run: npx lerna run build

- name: Install hedera local
run: npm install @hashgraph/hedera-local -g

- name: Set operator id and key env variable if CI is manual
if: ${{ inputs.operator_id }}
run: |
echo "OPERATOR_ID_MAIN=${{ inputs.operator_id }}" >> $GITHUB_ENV
echo "OPERATOR_KEY_MAIN=${{ inputs.operator_key }}" >> $GITHUB_ENV

- name: Run hedera local
run: hedera restart -d

- name: Stop relay
run: |
docker stop json-rpc-relay json-rpc-relay-ws

- name: Run acceptance tests
uses: nick-fields/retry@v2
with:
max_attempts: 3
timeout_minutes: 20
command: npm run acceptancetest:${{ inputs.testfilter }}
on_retry_command: scripts/retry_script.sh
env:
TEST_WS_SERVER: ${{ inputs.test_ws_server }}
SUBSCRIPTIONS_ENABLED: ${{ inputs.test_ws_server }}
6 changes: 2 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 1 addition & 33 deletions packages/server/tests/acceptance/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import chai from 'chai';
import dotenv from 'dotenv';
import path from 'path';
import shell from 'shelljs';
import pino from 'pino';
import chaiAsPromised from 'chai-as-promised';

Expand Down Expand Up @@ -49,7 +48,6 @@ const testLogger = pino({
});
const logger = testLogger.child({ name: 'rpc-acceptance-test' });

const USE_LOCAL_NODE = process.env.LOCAL_NODE || 'true';
const NETWORK = process.env.HEDERA_NETWORK || '';
const OPERATOR_KEY = process.env.OPERATOR_KEY_MAIN || '';
const OPERATOR_ID = process.env.OPERATOR_ID_MAIN || '';
Expand Down Expand Up @@ -86,10 +84,6 @@ describe('RPC Server Acceptance Tests', function () {
logger.info(`MIRROR_NODE_URL: ${process.env.MIRROR_NODE_URL}`);
logger.info(`E2E_RELAY_HOST: ${process.env.E2E_RELAY_HOST}`);

if (USE_LOCAL_NODE === 'true') {
runLocalHederaNetwork();
}

if (global.relayIsLocal) {
runLocalRelay();
}
Expand All @@ -103,12 +97,6 @@ describe('RPC Server Acceptance Tests', function () {
const cost = startOperatorBalance.toTinybars().subtract(endOperatorBalance.toTinybars());
logger.info(`Acceptance Tests spent ${Hbar.fromTinybars(cost)}`);

if (USE_LOCAL_NODE === 'true') {
// stop local-node
logger.info('Shutdown local node');
shell.exec('hedera stop');
}

//stop relay
logger.info('Stop relay');
if (relayServer !== undefined) {
Expand Down Expand Up @@ -138,33 +126,13 @@ describe('RPC Server Acceptance Tests', function () {
}
}

function runLocalHederaNetwork() {
// set env variables for docker images until local-node is updated
process.env['NETWORK_NODE_IMAGE_TAG'] = '0.45.0-alpha.0';
process.env['HAVEGED_IMAGE_TAG'] = '0.45.0-alpha.0';
process.env['MIRROR_IMAGE_TAG'] = '0.92.0';

console.log(
`Docker container versions, services: ${process.env['NETWORK_NODE_IMAGE_TAG']}, mirror: ${process.env['MIRROR_IMAGE_TAG']}`,
);

console.log('Installing local node...');
shell.exec(`npm install @hashgraph/hedera-local -g`);

console.log('Starting local node...');
shell.exec(`hedera start -d`);
console.log('Hedera Hashgraph local node env started');
}

function runLocalRelay() {
// start local relay, stop relay instance in local
shell.exec('docker stop json-rpc-relay');
// start local relay, relay instance in local should not be running

logger.info(`Start relay on port ${constants.RELAY_PORT}`);
relayServer = app.listen({ port: constants.RELAY_PORT });

if (process.env.TEST_WS_SERVER === 'true') {
shell.exec('docker stop json-rpc-relay-ws');
logger.info(`Start ws-server on port ${constants.WEB_SOCKET_PORT}`);
global.socketServer = wsApp.listen({ port: constants.WEB_SOCKET_PORT });
}
Expand Down
10 changes: 10 additions & 0 deletions scripts/retry_script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -v
set +e
hedera stop
sleep 5
ls -lah $(dirname $(readlink -f $(which hedera)))/../network-logs
sudo rm -rf $(dirname $(readlink -f $(which hedera)))/../network-logs
sleep 5
hedera restart -d
docker stop json-rpc-relay json-rpc-relay-ws
Loading