Переглянути джерело

tests - active video counters improvements IV

ondratra 3 роки тому
батько
коміт
63826fa62d

+ 1 - 7
tests/network-tests/src/Api.ts

@@ -38,7 +38,6 @@ import { ChannelCategoryMetadata, VideoCategoryMetadata } from '@joystream/metad
 import { metadataToBytes } from '../../../cli/lib/helpers/serialization'
 import { assert } from 'chai'
 import { WorkingGroups } from './WorkingGroups'
-import { v4 as uuid } from 'uuid'
 
 const workingGroupNameByGroup: { [key in WorkingGroups]: string } = {
   'distributionWorkingGroup': 'Distribution',
@@ -143,7 +142,7 @@ export class ApiFactory {
     if (isCustom) {
       this.customKeys.push(suriPath)
     }
-    const uri = isFinalPath ? suriPath : `${this.miniSecret}//testing//${suriPath}//${uuid().substring(0, 8)}`
+    const uri = isFinalPath ? suriPath : `${this.miniSecret}//testing//${suriPath}`
     const pair = this.keyring.addFromUri(uri)
     this.addressesToSuri.set(pair.address, uri)
     return pair
@@ -153,11 +152,6 @@ export class ApiFactory {
     return this.createKeyPair(customPath, true, isFinalPath)
   }
 
-  public createRawKeyPair(customPath: string): KeyringPair {
-    const pair = this.keyring.addFromUri(customPath)
-    return pair
-  }
-
   public keyGenInfo(): KeyGenInfo {
     const start = 0
     const final = this.keyId

+ 3 - 1
tests/network-tests/src/Scenario.ts

@@ -42,7 +42,7 @@ function writeOutput(api: Api, miniSecret: string) {
   fs.writeFileSync(OUTPUT_FILE_PATH, JSON.stringify(output, undefined, 2))
 }
 
-export async function scenario(scene: (props: ScenarioProps) => Promise<void>): Promise<void> {
+export async function scenario(label: string, scene: (props: ScenarioProps) => Promise<void>): Promise<void> {
   // Load env variables
   config()
   const env = process.env
@@ -87,6 +87,8 @@ export async function scenario(scene: (props: ScenarioProps) => Promise<void>):
 
   const debug = extendDebug('scenario')
 
+  debug(label)
+
   const jobs = new JobManager({ apiFactory, query, env })
 
   await scene({ env, debug, job: jobs.createJob.bind(jobs) })

+ 8 - 9
tests/network-tests/src/cli/joystream.ts

@@ -62,12 +62,6 @@ export class JoystreamCLI extends CLI {
     return super.run(command, customArgs, keyLocks || this.keys, requireSuccess)
   }
 
-  // TODO: remove
-  async createChannelOoooriginal(inputData: ChannelInputParameters, args: string[]): Promise<CommandResult> {
-    const jsonFile = this.tmpFileManager.jsonFile(inputData)
-    return this.run('content:createChannel', ['--input', jsonFile, ...args])
-  }
-
   /**
     Getter for temporary-file manager.
   */
@@ -113,9 +107,14 @@ export class JoystreamCLI extends CLI {
   async createChannel(channel: unknown): Promise<number> {
     const jsonFile = this.tmpFileManager.jsonFile(channel)
 
-    const { stdout, stderr } = await this.run('content:createChannel', ['--input', jsonFile, '--context', 'Member'])
+    const { stdout, stderr, exitCode } = await this.run('content:createChannel', [
+      '--input',
+      jsonFile,
+      '--context',
+      'Member',
+    ])
 
-    if (stderr && !this.containsWarningNoStorage(stderr)) {
+    if (exitCode && !this.containsWarningNoStorage(stderr)) {
       // ignore warnings
       throw new Error(`Unexpected CLI failure on creating channel: "${stderr}"`)
     }
@@ -157,7 +156,7 @@ export class JoystreamCLI extends CLI {
     )
 
     // prevent error from CLI that create
-    if (canOmitUpload && exitCode > 0 && !this.containsWarningNoStorage(stderr)) {
+    if (canOmitUpload && exitCode && !this.containsWarningNoStorage(stderr)) {
       // ignore warnings
       throw new Error(`Unexpected CLI failure on creating video: "${stderr}"`)
     }

+ 4 - 7
tests/network-tests/src/flows/clis/createChannel.ts

@@ -19,6 +19,7 @@ export default async function createChannel({ api, env, query }: FlowProps): Pro
   const paidTermId = api.createPaidTermId(new BN(+(env.MEMBERSHIP_PAID_TERMS || 0)))
   const buyMembershipFixture = new BuyMembershipHappyCaseFixture(api, [channelOwnerKeypair.key.address], paidTermId)
   await new FixtureRunner(buyMembershipFixture).run()
+  const memberId = buyMembershipFixture.getCreatedMembers()[0]
 
   // Send some funds to pay the deletion_prize
   const channelOwnerBalance = api.consts.storage.dataObjectDeletionPrize.muln(2)
@@ -30,6 +31,7 @@ export default async function createChannel({ api, env, query }: FlowProps): Pro
   // Import & select channel owner key
   await joystreamCli.init()
   await joystreamCli.importAccount(channelOwnerKeypair.key)
+  await joystreamCli.chooseMemberAccount(memberId)
 
   // Create channel
   const avatarPhotoPath = joystreamCli.getTmpFileManager().randomImgFile(300, 300)
@@ -43,16 +45,11 @@ export default async function createChannel({ api, env, query }: FlowProps): Pro
     language: 'en',
     rewardAccount: channelOwnerKeypair.key.address,
   }
-  const { out: createChannelOut } = await joystreamCli.createChannelOoooriginal(channelInput, ['--context', 'Member'])
 
-  const channelIdMatch = /Channel with id ([0-9]+) successfully created/.exec(createChannelOut)
-  if (!channelIdMatch) {
-    throw new Error(`No channel id found in output:\n${createChannelOut}`)
-  }
-  const [, channelId] = channelIdMatch
+  const channelId = await joystreamCli.createChannel(channelInput)
 
   await query.tryQueryWithTimeout(
-    () => query.channelById(channelId),
+    () => query.channelById(channelId.toString()),
     (channel) => {
       Utils.assert(channel, 'Channel not found')
       assert.equal(channel.title, channelInput.title)

+ 7 - 5
tests/network-tests/src/scenarios/combined.ts

@@ -10,7 +10,7 @@ import createChannel from '../flows/clis/createChannel'
 import { scenario } from '../Scenario'
 import { WorkingGroups } from '../WorkingGroups'
 
-scenario(async ({ job }) => {
+scenario('Combined', async ({ job }) => {
   // These tests assume:
   // - storage setup (including hired lead)
   // - existing council
@@ -37,8 +37,10 @@ scenario(async ({ job }) => {
     manageWorkerAsWorker.distribution,
   ]).requires(leadSetupJob)
 
-  const createChannelJob = job('create channel via CLI', createChannel)
-  job('init storage and distribution buckets via CLI', [initDistributionBucket, initStorageBucket]).after(
-    createChannelJob
-  )
+  const initBucketsJob = job('init storage and distribution buckets via CLI', [
+    initDistributionBucket,
+    initStorageBucket,
+  ]).requires(leadSetupJob)
+
+  const createChannelJob = job('create channel via CLI', createChannel).requires(initBucketsJob)
 })

+ 1 - 1
tests/network-tests/src/scenarios/content-directory.ts

@@ -5,7 +5,7 @@ import initStorage, { singleBucketConfig as storageConfig } from '../flows/stora
 import { WorkingGroups } from '../WorkingGroups'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Content directory', async ({ job }) => {
   const leadSetupJob = job('setup working group leads', [
     leaderSetup(WorkingGroups.Content, true),
     leaderSetup(WorkingGroups.Storage, true),

+ 1 - 1
tests/network-tests/src/scenarios/giza-issue-reproduction-setup.ts

@@ -6,7 +6,7 @@ import initStorage, { doubleBucketConfig as storageConfig } from '../flows/stora
 import { WorkingGroups } from '../WorkingGroups'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Giza issue reproduction setup', async ({ job }) => {
   job('Make Alice a member', makeAliceMember)
 
   const leads = job('Set Storage Lead', leaderSetup(WorkingGroups.Storage))

+ 1 - 1
tests/network-tests/src/scenarios/init-storage-and-distribution.ts

@@ -5,7 +5,7 @@ import { scenario } from '../Scenario'
 import { WorkingGroups } from '../WorkingGroups'
 import updateAccountsFlow from '../misc/updateAllWorkerRoleAccountsFlow'
 
-scenario(async ({ job }) => {
+scenario('Init storage and distribution', async ({ job }) => {
   const setupLead = job('setup leads', [
     leaderSetup(WorkingGroups.Distribution, true),
     leaderSetup(WorkingGroups.Storage, true),

+ 1 - 1
tests/network-tests/src/scenarios/post-migration.ts

@@ -1,6 +1,6 @@
 import postMigrationAssertions from '../misc/postMigrationAssertionsFlow'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Post migration', async ({ job }) => {
   job('Verify post-migration chain state', postMigrationAssertions)
 })

+ 1 - 1
tests/network-tests/src/scenarios/proposals.ts

@@ -8,7 +8,7 @@ import validatorCountProposal from '../flows/proposals/validatorCountProposal'
 import wgMintCapacityProposal from '../flows/proposals/workingGroupMintCapacityProposal'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Proposals', async ({ job }) => {
   job('creating members', creatingMemberships)
 
   const councilJob = job('council setup', councilSetup)

+ 1 - 1
tests/network-tests/src/scenarios/setup-new-chain.ts

@@ -7,7 +7,7 @@ import initDistribution, { singleBucketConfig as defaultDistributionConfig } fro
 import { AllWorkingGroups } from '../WorkingGroups'
 import { scenario } from '../Scenario'
 
-scenario(async ({ job }) => {
+scenario('Setup new chain', async ({ job }) => {
   const COUNCIL_SIZE = 1
   job('Create Council', assignCouncil(COUNCIL_SIZE))
 

+ 1 - 1
tests/network-tests/src/scenarios/tests/resource-locks-1.ts

@@ -6,6 +6,6 @@ async function flow1({ lock }: FlowProps) {
   await lock(Resource.Council)
 }
 
-scenario(async ({ job }) => {
+scenario('Resource locks 1', async ({ job }) => {
   job('test', [flow1, flow1])
 })

+ 1 - 1
tests/network-tests/src/scenarios/tests/resource-locks-2.ts

@@ -6,7 +6,7 @@ async function flow({ lock }: FlowProps) {
   await lock(Resource.Proposals)
 }
 
-scenario(async ({ job }) => {
+scenario('Resource locks 2', async ({ job }) => {
   // Runtime is configured for MaxActiveProposalLimit = 5
   // So we should ensure we don't exceed that number of active proposals
   // which limits the number of concurrent tests that create proposals