Bladeren bron

network-tests: run worker tests for all working groups, log runtime output on exit

Mokhtar Naamani 4 jaren geleden
bovenliggende
commit
a29301f125

+ 1 - 1
README.md

@@ -109,7 +109,7 @@ A step by step guide to setup a full node and validator on the Joystream testnet
 
 ```bash
 docker-compose up -d
-DEBUG=* yarn workspace network-tests scenario-full
+DEBUG=* yarn workspace network-tests test-run src/scenarios/full.ts
 docker-compose down
 ```
 

+ 1 - 1
tests/network-tests/package.json

@@ -5,7 +5,7 @@
   "scripts": {
     "build": "tsc --noEmit",
     "run-tests": "./run-tests.sh",
-    "scenario-full": "yarn db-path-setup && node -r ts-node/register --unhandled-rejections=strict src/scenarios/full.ts",
+    "test-run": "yarn db-path-setup && node -r ts-node/register --unhandled-rejections=strict",
     "lint": "eslint . --quiet --ext .ts",
     "checks": "tsc --noEmit --pretty && prettier ./ --check && yarn lint",
     "format": "prettier ./ --write ",

+ 2 - 2
tests/network-tests/run-tests.sh

@@ -50,7 +50,7 @@ CONTAINER_ID=`docker run -d -v ${DATA_PATH}:/data -p 9944:9944 joystream/node \
   --chain /data/chain-spec-raw.json`
 
 function cleanup() {
-    docker logs ${CONTAINER_ID} --tail 30
+    docker logs ${CONTAINER_ID} --tail 15
     docker stop ${CONTAINER_ID}
     docker rm ${CONTAINER_ID}
 }
@@ -58,4 +58,4 @@ function cleanup() {
 trap cleanup EXIT
 
 # Execute the tests
-time DEBUG=* yarn workspace network-tests scenario-full
+time DEBUG=* yarn workspace network-tests test-run src/scenarios/full.ts

+ 19 - 35
tests/network-tests/src/flows/workingGroup/manageWorkerAsLead.ts

@@ -22,7 +22,7 @@ import { DbService } from '../../DbService'
 import { LeaderHiringHappyCaseFixture } from '../../fixtures/leaderHiringHappyCase'
 
 // Manage worker as lead scenario
-export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db: DbService) {
+export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db: DbService, group: WorkingGroups) {
   const sudoUri: string = env.SUDO_ACCOUNT_URI!
   const keyring = new Keyring({ type: 'sr25519' })
   const sudo: KeyringPair = keyring.addFromUri(sudoUri)
@@ -43,9 +43,9 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
   // const durationInBlocks = 60
   // setTestTimeout(api, durationInBlocks)
 
-  if (db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
+  if (db.hasLeader(api.getWorkingGroupString(group))) {
     nKeyPairs = db.getMembers()
-    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))
+    leadKeyPair[0] = db.getLeader(api.getWorkingGroupString(group))
   } else {
     const leaderHiringHappyCaseFixture: LeaderHiringHappyCaseFixture = new LeaderHiringHappyCaseFixture(
       api,
@@ -59,7 +59,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
       rewardInterval,
       firstRewardInterval,
       payoutAmount,
-      WorkingGroups.StorageWorkingGroup
+      group
     )
     await leaderHiringHappyCaseFixture.runner(false)
   }
@@ -73,7 +73,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
     roleStake,
     openingActivationDelay,
     unstakingPeriod,
-    WorkingGroups.StorageWorkingGroup
+    group
   )
   // Add worker opening
   await addWorkerOpeningFixture.runner(false)
@@ -88,7 +88,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
       applicationStake,
       roleStake,
       addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
-      WorkingGroups.StorageWorkingGroup
+      group
     )
     await applyForWorkerOpeningFixture.runner(false)
   })()
@@ -101,7 +101,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
       leadKeyPair[0],
       sudo,
       addWorkerOpeningFixture.getCreatedOpeningId() as OpeningId,
-      WorkingGroups.StorageWorkingGroup
+      group
     )
     await beginApplicationReviewFixture.runner(false)
   })()
@@ -118,17 +118,12 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
-      WorkingGroups.StorageWorkingGroup
+      group
     )
     await fillOpeningFixture.runner(false)
   })()
 
-  const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-    api,
-    leadKeyPair,
-    sudo,
-    WorkingGroups.StorageWorkingGroup
-  )
+  const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(api, leadKeyPair, sudo, group)
   // Leaving lead role
   await leaveRoleFixture.runner(false)
 
@@ -137,7 +132,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
     nKeyPairs,
     leadKeyPair[0],
     sudo,
-    WorkingGroups.StorageWorkingGroup
+    group
   )
   // Decrease worker stake, expect failure
   await decreaseStakeFailureFixture.runner(true)
@@ -149,7 +144,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
     applicationStake,
     roleStake,
     openingActivationDelay,
-    WorkingGroups.StorageWorkingGroup
+    group
   )
   // Add lead opening
   await addNewLeaderOpeningFixture.runner(false)
@@ -164,7 +159,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
       applicationStake,
       roleStake,
       addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
-      WorkingGroups.StorageWorkingGroup
+      group
     )
     await applyForNewLeaderOpeningFixture.runner(false)
   })()
@@ -176,7 +171,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
       api,
       sudo,
       addNewLeaderOpeningFixture.getCreatedOpeningId() as OpeningId,
-      WorkingGroups.StorageWorkingGroup
+      group
     )
     await beginNewLeaderApplicationReviewFixture.runner(false)
   })()
@@ -192,7 +187,7 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
       firstRewardInterval,
       rewardInterval,
       payoutAmount,
-      WorkingGroups.StorageWorkingGroup
+      group
     )
     await fillNewLeaderOpeningFixture.runner(false)
   })()
@@ -202,18 +197,12 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
     nKeyPairs,
     leadKeyPair[0],
     sudo,
-    WorkingGroups.StorageWorkingGroup
+    group
   )
   // Decrease worker stake
   await decreaseStakeFixture.runner(false)
 
-  const slashFixture: SlashFixture = new SlashFixture(
-    api,
-    nKeyPairs,
-    leadKeyPair[0],
-    sudo,
-    WorkingGroups.StorageWorkingGroup
-  )
+  const slashFixture: SlashFixture = new SlashFixture(api, nKeyPairs, leadKeyPair[0], sudo, group)
   // Slash worker
   await slashFixture.runner(false)
 
@@ -222,18 +211,13 @@ export default async function manageWorker(api: Api, env: NodeJS.ProcessEnv, db:
     nKeyPairs,
     leadKeyPair[0],
     sudo,
-    WorkingGroups.StorageWorkingGroup
+    group
   )
   // Terminate worker role
   await terminateRoleFixture.runner(false)
 
-  if (!db.hasLeader(api.getWorkingGroupString(WorkingGroups.StorageWorkingGroup))) {
-    const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(
-      api,
-      leadKeyPair,
-      sudo,
-      WorkingGroups.StorageWorkingGroup
-    )
+  if (!db.hasLeader(api.getWorkingGroupString(group))) {
+    const leaveRoleFixture: LeaveRoleFixture = new LeaveRoleFixture(api, leadKeyPair, sudo, group)
     // Leaving lead role
     await leaveRoleFixture.runner(false)
   }

+ 9 - 4
tests/network-tests/src/scenarios/full.ts

@@ -73,13 +73,18 @@ const scenario = async () => {
 
   debug('Lead Setup (Storage)')
   await leaderSetup(api, env, db, WorkingGroups.StorageWorkingGroup)
+  await atLeastValueBug(api, env, db)
+  debug('Storage Worker Tests')
+  await manageWorkerAsLead(api, env, db, WorkingGroups.StorageWorkingGroup)
+  await manageWorkerAsWorker(api, env, db)
+  await workerApplicaionHappyCase(api, env, db)
+  await workerApplicationRejectionCase(api, env, db)
+  await workerPayout(api, env, db)
 
   debug('Lead Setup (Content)')
   await leaderSetup(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
-
-  debug('Worker Tests')
-  await atLeastValueBug(api, env, db)
-  await manageWorkerAsLead(api, env, db)
+  debug('Content Worker Tests')
+  await manageWorkerAsLead(api, env, db, WorkingGroups.ContentDirectoryWorkingGroup)
   await manageWorkerAsWorker(api, env, db)
   await workerApplicaionHappyCase(api, env, db)
   await workerApplicationRejectionCase(api, env, db)