Skip to content

Commit

Permalink
WIP 2
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwade committed Aug 5, 2024
1 parent 3871fe8 commit 9a8905f
Show file tree
Hide file tree
Showing 10 changed files with 1,146 additions and 18 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/load-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,33 @@ jobs:
- service: common
steps:
- uses: actions/checkout@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
registry-url: 'https://registry.npmjs.org'
cache-dependency-path: tooks/ci-k6/package-lock.json
- name: Install dependencies
working-directory: tooks/ci-k6
run: npm ci

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Start Docker Compose
- name: Start Frequency
run: |
docker compose -f services/${{ matrix.service }}/docker-compose.yaml --build up -d
# docker compose -f services/account/docker-compose.yaml -f services/account/docker-compose-k6.yaml --build up -d
docker compose -f docker-compose.yaml -f tools/ci-k6/docker-compose-k6.${{ matrix.service }}.yaml up -d frequency
sleep 20
- name: Generate Provider and Capacity
working-directory: tooks/ci-k6
run: npm run main

# Just start the services we need...
- name: Start All Services
run: docker compose -f docker-compose.yaml -f tools/ci-k6/docker-compose-k6.${{ matrix.service }}.yaml up -d

- name: Setup K6
uses: grafana/setup-k6-action@v1
- name: Run k6 Tests
Expand All @@ -72,5 +92,4 @@ jobs:
- name: Stop Docker Compose
if: always()
run: docker compose -f services/${{ matrix.service }}/docker-compose.yaml down
# docker compose -f services/account/docker-compose.yaml down
run: docker compose -f docker-compose.yaml -f tools/ci-k6/docker-compose-k6.${{ matrix.service }}.yaml down
12 changes: 0 additions & 12 deletions docker-compose-k6.yaml

This file was deleted.

3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json
x-common-environment: &common-environment
FREQUENCY_URL: ${FREQUENCY_URL:-ws://frequency:9944}
FREQUENCY_HTTP_URL: ${FREQUENCY_HTTP_URL:-http://localhost:9944}
Expand Down Expand Up @@ -55,7 +56,7 @@ services:
- redis_data:/data/redis

frequency:
image: dsnp/instant-seal-node-with-deployed-schemas:latest
image: frequencychain/standalone-node:v1.13.0-rc3
# We need to specify the platform because it's the only image
# built by Frequency at the moment, and auto-pull won't work otherwise
platform: linux/amd64
Expand Down
45 changes: 45 additions & 0 deletions tools/ci-k6/docker-compose-k6.account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json

services:
account-service-api:
pull_policy: never
build:
context: ../../
dockerfile: ../../Docker/Dockerfile.account
command: ['api']
ports:
- 3000:3000
volumes: !reset []
depends_on: !override
- redis
- ipfs

account-service-worker:
pull_policy: never
build:
context: ../../
dockerfile: ../../Docker/Dockerfile.account
command: ['worker']
volumes: !reset []
depends_on: !override
- redis
- ipfs

gateway-base:
profiles:
- skip
content-publishing-service-worker:
profiles:
- skip
content-publishing-service-api:
profiles:
- skip
content-watcher-service:
profiles:
- skip
graph-service-api:
profiles:
- skip
graph-service-worker:
profiles:
- skip
76 changes: 76 additions & 0 deletions tools/ci-k6/docker-compose-k6.content-publishing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json

services:
content-publishing-service-api:
pull_policy: never
build:
context: ../../
dockerfile: ../../Docker/Dockerfile.content-publishing
command: ['api']
ports:
- 3000:3000
volumes: !reset []
depends_on: !override
- redis
- ipfs

content-publishing-service-worker:
pull_policy: never
build:
context: ../../
dockerfile: ../../Docker/Dockerfile.content-publishing
command: ['worker']
volumes: !reset []
depends_on: !override
- redis
- ipfs

gateway-base:
profiles:
- skip
account-service-worker:
profiles:
- skip
account-service-api:
profiles:
- skip
content-watcher-service:
profiles:
- skip
graph-service-api:
profiles:
- skip
graph-service-worker:
profiles:
- skip



# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json
services:
account-service-api: !reset null
account-service-worker: !reset null
graph-service-api: !reset null
graph-service-worker: !reset null

content-watcher-service: !reset null

content-publishing-service-api:
pull_policy: build
build:
dockerfile: Docker/Dockerfile.content-publishing
tags:
- content-publishing-base:latest
image: content-publishing-base:latest
volumes: !reset []
command: !reset null

content-publishing-service-worker:
pull_policy: build
build:
dockerfile: Docker/Dockerfile.content-publishing
tags:
- content-publishing-base:latest
image: content-publishing-base:latest
volumes: !reset []
command: !reset null
36 changes: 36 additions & 0 deletions tools/ci-k6/docker-compose-k6.content-watcher.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json

services:
content-watcher:
pull_policy: never
build:
context: ../../
dockerfile: ../../Docker/Dockerfile.content-watcher
ports:
- 3000:3000
volumes: !reset []
depends_on: !override
- redis
- ipfs

gateway-base:
profiles:
- skip
content-publishing-service-worker:
profiles:
- skip
content-publishing-service-api:
profiles:
- skip
account-service-worker:
profiles:
- skip
account-service-api:
profiles:
- skip
graph-service-api:
profiles:
- skip
graph-service-worker:
profiles:
- skip
43 changes: 43 additions & 0 deletions tools/ci-k6/docker-compose-k6.graph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json

services:
graph-service-api:
pull_policy: never
build:
context: ../../
dockerfile: ../../Docker/Dockerfile.graph
command: ['api']
ports:
- 3000:3000
volumes: !reset []
depends_on: !override
- redis

graph-service-worker:
pull_policy: never
build:
context: ../../
dockerfile: ../../Docker/Dockerfile.graph
command: ['worker']
volumes: !reset []
depends_on: !override
- redis

gateway-base:
profiles:
- skip
content-publishing-service-worker:
profiles:
- skip
content-publishing-service-api:
profiles:
- skip
content-watcher-service:
profiles:
- skip
account-service-api:
profiles:
- skip
account-service-worker:
profiles:
- skip
52 changes: 52 additions & 0 deletions tools/ci-k6/main.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { ApiPromise, WsProvider } from '@polkadot/api';
import { Keyring } from '@polkadot/keyring';

const keyring = new Keyring({ type: 'sr25519' });

export async function createAndStake(providerUrl, keyUri) {
const api = await ApiPromise.create({ provider: new WsProvider(providerUrl) });

console.log('Connected...');

const account = keyring.createFromUri(keyUri);

const call = api.tx.utility.batchAll([
api.tx.msa.create(),
api.tx.msa.createProvider('alice'),
api.tx.capacity.stake(1, 10_000_000_000_000),
]);

console.log('Submitting call...');
await new Promise(async (resolve, reject) => {
const unsub = await call.signAndSend(account, ({ status, events }) => {
if (status.isInBlock || status.isFinalized) {
console.log(
`Block hash: ${(status.isInBlock && status.asInBlock) || (status.isFinalized && status.asFinalized)}`,
);
if (events)
console.log(
'All Events',
events.map((x) => x.toHuman()),
);
const success = events.find((x) => api.events.system.ExtrinsicSuccess.is(x.event));
const failure = events.find((x) => api.events.system.ExtrinsicFailed.is(x.event));
unsub();
if (success && !failure) {
console.log('Success!');
resolve();
} else {
console.error('FAILED!');
reject();
}
}
});
});
}

try {
await createAndStake('ws://localhost:9944', '//Alice');
process.exit(0);
} catch (error) {
console.error('Error:', error);
process.exit(1);
}
Loading

0 comments on commit 9a8905f

Please sign in to comment.