Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'origin/master' into nightly
  • Loading branch information
github-actions committed Nov 24, 2022
2 parents 65e2378 + 3ac2fbd commit 35314e3
Show file tree
Hide file tree
Showing 34 changed files with 445 additions and 312 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/nightly-e2e.yaml
@@ -0,0 +1,83 @@
name: nightly-e2e

on:
workflow_dispatch:
workflow_run:
workflows: [nightly-test]
types:
- completed

jobs:
fail:
name: "Fail the workflow run by exiting"
if: ${{ github.event_name != 'workflow_dispatch' && github.event.workflow_run.conclusion != 'success' }}
runs-on: ubuntu-20.04
steps:
- name: "exit 1"
run: exit 1

test:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-20.04
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3
with:
ref: nightly

- name: 🧰 Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.12.0
registry-url: 'https://registry.npmjs.org'

- name: 💽 Install dependencies
run: |
yarn install --immutable --inline-builds --mode=skip-build
- name: 🔨 Build
run: |
yarn build
- name: 🌐 Setup local test network
working-directory: packages/e2e
run: |
yarn local-network:up -d
env:
POSTGRES_PORT: '5435'
OGMIOS_PORT: '1340'
OGMIOS_URL: 'ws://cardano-node-ogmios:1340'

- name: Wait for some epochs
run: |
yarn workspace @cardano-sdk/e2e wait-for-network
env:
FAUCET_PROVIDER: 'cardano-wallet'
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
DB_SYNC_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'

- name: 🔬 Test - e2e - wallet | long-running
run: |
yarn workspace @cardano-sdk/e2e test:wallet
yarn workspace @cardano-sdk/e2e test:long-running
env:
FAUCET_PROVIDER: 'cardano-wallet'
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
KEY_MANAGEMENT_PROVIDER: 'inMemory'
KEY_MANAGEMENT_PARAMS: '{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
ASSET_PROVIDER: 'http'
ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/asset"}'
CHAIN_HISTORY_PROVIDER: 'http'
CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/chain-history"}'
DB_SYNC_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'
NETWORK_INFO_PROVIDER: 'http'
NETWORK_INFO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/network-info"}'
OGMIOS_SERVER_URL: 'ws://localhost:1340/'
REWARDS_PROVIDER: 'http'
REWARDS_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/rewards"}'
TX_SUBMIT_PROVIDER: 'http'
TX_SUBMIT_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/tx-submit"}'
UTXO_PROVIDER: 'http'
UTXO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/utxo"}'
STAKE_POOL_PROVIDER: 'http'
STAKE_POOL_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/stake-pool"}'
2 changes: 1 addition & 1 deletion .github/workflows/nightly-publish.yaml
Expand Up @@ -3,7 +3,7 @@ name: nightly-publish
on:
workflow_dispatch:
workflow_run:
workflows: [nightly-test]
workflows: [nightly-e2e]
types:
- completed

Expand Down
43 changes: 0 additions & 43 deletions .github/workflows/nightly-test.yaml
Expand Up @@ -44,51 +44,8 @@ jobs:
run: |
yarn build
- name: 🌐 Setup local test network
working-directory: packages/e2e
run: |
yarn local-network:up -d
env:
POSTGRES_PORT: '5435'
OGMIOS_PORT: '1340'
OGMIOS_URL: 'ws://cardano-node-ogmios:1340'

- name: Wait for some epochs
run: |
yarn workspace @cardano-sdk/e2e wait-for-network
env:
FAUCET_PROVIDER: 'cardano-wallet'
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
DB_SYNC_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'

- name: 🔬 Test - unit | integration
run: |
yarn lint
yarn test:build:verify
yarn test --forceExit
- name: 🔬 Test - e2e - wallet | long-running
run: |
yarn workspace @cardano-sdk/e2e test:wallet
yarn workspace @cardano-sdk/e2e test:long-running
env:
FAUCET_PROVIDER: 'cardano-wallet'
FAUCET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'
KEY_MANAGEMENT_PROVIDER: 'inMemory'
KEY_MANAGEMENT_PARAMS: '{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
ASSET_PROVIDER: 'http'
ASSET_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/asset"}'
CHAIN_HISTORY_PROVIDER: 'http'
CHAIN_HISTORY_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/chain-history"}'
DB_SYNC_CONNECTION_STRING: 'postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'
NETWORK_INFO_PROVIDER: 'http'
NETWORK_INFO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/network-info"}'
OGMIOS_SERVER_URL: 'ws://localhost:1340/'
REWARDS_PROVIDER: 'http'
REWARDS_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/rewards"}'
TX_SUBMIT_PROVIDER: 'http'
TX_SUBMIT_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/tx-submit"}'
UTXO_PROVIDER: 'http'
UTXO_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/utxo"}'
STAKE_POOL_PROVIDER: 'http'
STAKE_POOL_PROVIDER_PARAMS: '{"baseUrl":"http://localhost:4000/stake-pool"}'
2 changes: 1 addition & 1 deletion .yarn/plugins/yarn-plugin-nixify.cjs

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions .yarnrc.yml
@@ -1,15 +1,15 @@
nodeLinker: node-modules

packageExtensions:
ts-node@*:
peerDependenciesMeta:
"@types/node":
optional: true

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/yarn-plugin-nixify.cjs
spec: "https://raw.githubusercontent.com/stephank/yarn-plugin-nixify/main/dist/yarn-plugin-nixify.js"

yarnPath: .yarn/releases/yarn-3.2.1.cjs

packageExtensions:
ts-node@*:
peerDependenciesMeta:
"@types/node":
"optional": true
13 changes: 12 additions & 1 deletion flake.nix
Expand Up @@ -50,6 +50,17 @@
PYTHON = "${pkgs.python3}/bin/python3";
# node-hid uses pkg-config to find sources
buildInputs = oldAttrs.buildInputs ++ [pkgs.pkg-config pkgs.libusb1];

installPhase = ''
runHook preInstall
mkdir -p $out/libexec $out/bin
# Move the entire project to the output directory.
mv $PWD "$out/libexec/$sourceRoot"
cd "$out/libexec/$sourceRoot"
# Invoke a plugin internal command to setup binaries.
yarn nixify install-bin $out/bin
runHook postInstall
'';
});
in
project.overrideAttrs (oldAttrs: {
Expand All @@ -69,7 +80,7 @@
mkdir -p $out/libexec/$sourceRoot $out/bin
cp -r ${production-deps}/libexec/$sourceRoot/node_modules $out/libexec/$sourceRoot/node_modules
test -f ${production-deps}/libexec/$sourceRoot/packages/cardano-services/node_modules && cp -r ${production-deps}/libexec/$sourceRoot/node_modules $out/libexec/$sourceRoot/node_modules
cp -r scripts $out/libexec/$sourceRoot/scripts
for p in cardano-services core ogmios util; do
mkdir -p $out/libexec/$sourceRoot/packages/$p
Expand Down
20 changes: 14 additions & 6 deletions packages/e2e/env/.env.load-testing → packages/e2e/.env.example
@@ -1,11 +1,19 @@
# Logger
LOGGER_MIN_SEVERITY=info

# Providers setup
# Faucet configuration
FAUCET_PROVIDER=cardano-wallet
FAUCET_PROVIDER_PARAMS='{"baseUrl":"http://localhost:8090/v2","mnemonic":"fire method repair aware foot tray accuse brother popular olive find account sick rocket next"}'

# Key management setup - required by getWallet
KEY_MANAGEMENT_PROVIDER=inMemory
KEY_MANAGEMENT_PARAMS='{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
#KEY_MANAGEMENT_PARAMS='{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"slab gorilla reflect display cage aim silver add own arrange crew start female bitter menu inner combine exit swallow bamboo midnight wealth culture picnic"}'
#KEY_MANAGEMENT_PARAMS='{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"decorate survey empower stairs pledge humble social leisure baby wrap grief exact monster rug dash kiss perfect select science light frame play swallow day"}'
#KEY_MANAGEMENT_PARAMS='{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"phrase raw learn suspect inmate powder combine apology regular hero gain chronic fruit ritual short screen goddess odor keen creek brand today kit machine"}'
#KEY_MANAGEMENT_PARAMS='{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"salon zoo engage submit smile frost later decide wing sight chaos renew lizard rely canal coral scene hobby scare step bus leaf tobacco slice"}'

# Providers setup - required by getWallet
ASSET_PROVIDER=http
ASSET_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/asset"}'
CHAIN_HISTORY_PROVIDER=http
Expand All @@ -15,19 +23,19 @@ NETWORK_INFO_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/network-info"}'
REWARDS_PROVIDER=http
REWARDS_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/rewards"}'
TX_SUBMIT_PROVIDER=http
TX_SUBMIT_PROVIDER_PARAMS='{"baseUrl":"http://localhost:3456/tx-submit"}'
TX_SUBMIT_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/tx-submit"}'
UTXO_PROVIDER=http
UTXO_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/utxo"}'
STAKE_POOL_PROVIDER=http
STAKE_POOL_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/stake-pool"}'

# Ogmios interactions
# Required by test:ogmios
DB_SYNC_CONNECTION_STRING='postgresql://postgres:doNoUseThisSecret!@localhost:5435/cexplorer'
OGMIOS_SERVER_URL='ws://localhost:1340/'
OGMIOS_SERVER_URL=ws://localhost:1340/

# Test Parameters
# Required by test:load-testing
OGMIOS_URL=ws://localhost:1340
TX_SUBMIT_HTTP_URL=http://localhost:3456/tx-submit
TRANSACTIONS_NUMBER=50
TRANSACTIONS_NUMBER=10
START_LOCAL_HTTP_SERVER=true
WORKER_PARALLEL_TRANSACTION=3
93 changes: 39 additions & 54 deletions packages/e2e/README.md
Expand Up @@ -42,11 +42,13 @@ $ ts-node ./src/util/mnemonic.ts

Done in 5.44s.
```

To add funds to your newly created wallet, copy the address displayed in the console and go to [Public Testnet Faucet](https://testnets.cardano.org/en/testnets/cardano/tools/faucet/). You can request 1000 tADA every 24h.

> :information_source: tADA is a limited resource, so if you are no longer using the address, return the tADA to the faucet for others to use.
## Local Test Network

<a name="local_test_network"></a>

Some end-to-end tests can be run using the local test network, this network can be started as follows:
Expand All @@ -60,17 +62,19 @@ $ yarn workspace @cardano-sdk/e2e local-network:up
```bash
$ yarn workspace @cardano-sdk/e2e local-network:down
```

Instead of CTRL-C, since some resources need to be clear before you can set up the environment again, if you don't stop the containers with the proper command, you may run into issues restarting it.

There are two ways of obtaining tADA on this network, first we have the faucet:

```javascript
let faucetProvider = await faucetProviderFactory.create(
env.FAUCET_PROVIDER,
env.FAUCET_PROVIDER_PARAMS,
getLogger(env.LOGGER_MIN_SEVERITY));
let faucetProvider = await faucetProviderFactory.create(
env.FAUCET_PROVIDER,
env.FAUCET_PROVIDER_PARAMS,
getLogger(env.LOGGER_MIN_SEVERITY)
);

await faucetProvider.request(address, amountFromFaucet, blockConfirmations);
await faucetProvider.request(address, amountFromFaucet, blockConfirmations);
```

The faucet allows you to request an arbitrary amount of tADA to a given address. The faucet will make sure the transaction is in a block before returning, which means you can access the funds immediately after.
Expand Down Expand Up @@ -123,55 +127,6 @@ You can override this port mapping by setting the `FILE_SERVER_PORT` environment

`FILE_SERVER_PORT=9874 docker compose -p local-network-e2e up`

## Load Testing

Cardano services end to end load tests. Please note that you must have several services up before executing the test, to start the environment(from the root):

```bash
$ cd packages/cardano-services
$ yarn preview:up
```

Once your environment is synced up, in a different terminal you can proceed to run the test, this is an example of the configuration you may need:

```
# Logger
LOGGER_MIN_SEVERITY=info
# Providers setup
KEY_MANAGEMENT_PROVIDER=inMemory
KEY_MANAGEMENT_PARAMS='{"accountIndex": 0, "networkId": 0, "password":"some_password","mnemonic":"vacant violin soft weird deliver render brief always monitor general maid smart jelly core drastic erode echo there clump dizzy card filter option defense"}'
ASSET_PROVIDER=http
ASSET_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/asset"}'
CHAIN_HISTORY_PROVIDER=http
CHAIN_HISTORY_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/chain-history"}'
NETWORK_INFO_PROVIDER=http
NETWORK_INFO_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/network-info"}'
REWARDS_PROVIDER=http
REWARDS_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/rewards"}'
TX_SUBMIT_PROVIDER=http
TX_SUBMIT_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/tx-submit"}'
UTXO_PROVIDER=http
UTXO_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/utxo"}'
STAKE_POOL_PROVIDER=http
STAKE_POOL_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/stake-pool"}'
# Test Parameters
OGMIOS_URL=ws://localhost:1340
TX_SUBMIT_HTTP_URL=http://localhost:5001/tx-submit
TRANSACTIONS_NUMBER=10
START_LOCAL_HTTP_SERVER=true
WORKER_PARALLEL_TRANSACTION=3
```
> :information_source: Remember to use a wallet with enough funds to carry out transactions (see [here](#generate_wallet)).
To execute the test:

```bash
$ yarn workspace @cardano-sdk/e2e test:load-testing
```

## Local Network

The end-to-end local network test are meant to showcase the use of the local test network. The local network end-to-end test shows how we can fund wallets with local test network tADA so we can run the end-to-end tests. For the local network end-to-end test to run, we must first start our local test network environment (see [here](#local_test_network)).
Expand Down Expand Up @@ -211,6 +166,35 @@ Then to run the local network tests, run:
$ yarn workspace @cardano-sdk/e2e test:local-network
```

## RabbitMQ Load Testing

**RabbitMQ** end to end load tests. Please note that this requires an _Ogmios_ server for submitting the txs.
The default configuration matches the **local-network** host mapping (just leaving the `.env` file untouched)
or we can configure the test to run against another system.

```
# Required by test:load-testing
OGMIOS_URL=ws://localhost:1340
TX_SUBMIT_HTTP_URL=http://localhost:3456/tx-submit
TRANSACTIONS_NUMBER=10
START_LOCAL_HTTP_SERVER=true
WORKER_PARALLEL_TRANSACTION=3
```

> :information_source: Ensure the configured wallet has sufficient funds for the test transactions (see [here](#generate_wallet)).
Before executing the test, start the *local-network*:

```bash
$ yarn workspace @cardano-sdk/e2e test:local-network
```

To execute the test:

```bash
$ yarn workspace @cardano-sdk/e2e test:load-testing
```

## Wallet

The wallet end-to-end tests showcase the use of different providers to create, sign, send and keep track of transactions on the blockchain, query assets and their metadata, delegate to pools and keep track of rewards (among others):
Expand Down Expand Up @@ -240,6 +224,7 @@ STAKE_POOL_PROVIDER=http
STAKE_POOL_PROVIDER_PARAMS='{"baseUrl":"http://localhost:4000/stake-pool"}'
```

> :information_source: Remember to use a wallet with enough funds to carry out transactions (see [here](#generate_wallet)).
Then to run the wallet tests, run:
Expand Down

0 comments on commit 35314e3

Please sign in to comment.