[Colossus] CLI command for updating multiple bags#4812
[Colossus] CLI command for updating multiple bags#4812mnaamani merged 3 commits intoJoystream:masterfrom
Conversation
mnaamani
left a comment
There was a problem hiding this comment.
Looks good, tested and works. Left a minor comment.
The integration test is failing in the flows/clis/initStorageBucket.ts where the command is used and it has not been renamed.
| this.exit(ExitCodes.InvalidParameters) | ||
| } | ||
|
|
||
| if (_.isEmpty(uniqueBagIds)) { |
There was a problem hiding this comment.
Is this check necessary? Since flag is required?
| api, | ||
| uniqueBagIds, | ||
| account, | ||
| flags.add, |
There was a problem hiding this comment.
I realize that this does work, and runtime handles it safely if there are repeated buckets, but we might as well use the "unique" add and remove arrays instead. It would reduce size of extrinsic if there were duplicates.
|
To test this I played around with the integrations tests const { stderr: output1 } = await cli.run('leader:update-bags', [
'--add',
bucketId,
'--bagIds',
'static:council',
'static:council',
'static:council',
'--bagIds',
'static:wg:app',
'-s',
'atomic',
])
debug(output1)
const { stderr: output2 } = await cli.run('leader:update-bags', [
'--remove',
bucketId,
'--bagIds',
'static:council',
'static:wg:storage',
'static:wg:storage',
'--updateStrategy',
'force',
])
debug(output2)
await cli.run('leader:update-bags', [
'--remove',
bucketId,
'--bagIds',
'static:wg:app',
'--updateStrategy',
'force'
])I found it very useful to run a single flow repeatedly after starting the local dev playground. So I added a simple "scenario" for running a single flow, (with a small change to import { scenario } from '../Scenario'
import path from 'path'
// eslint-disable-next-line @typescript-eslint/no-floating-promises
scenario('Single Flow', async ({ job }) => {
const pathToFlow = path.join('../flows', process.argv[2])
// eslint-disable-next-line @typescript-eslint/no-var-requires
const flows = require(pathToFlow)
const flow = flows.default || flows
job('single-flow', flow)
})REUSE_KEYS=true DEBUG=* ./run-test-scenario.sh flow clis/initStorageBucket
yarn workspace v1.22.19
yarn run v1.22.19
$ node -r ts-node/register --unhandled-rejections=strict src/scenarios/flow.ts clis/initStorageBucket
integration-tests:api-factory Connecting to chain, attempt 1.. +0ms
Runtime Version: 12.2001.0
integration-tests:scenario Single Flow +0ms
integration-tests:job:single-flow Running +0ms
integration-tests:flow:initStorageBucketViaCLI Started +0ms
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 info: Initializing runtime connection to: ws://localhost:9944
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 info: Waiting for chain to be synced before proceeding.
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 info: Updating the bag...
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:13:1913 debug: Sending utility.batchAll extrinsic...
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:14:1914 debug: Extrinsic successful!
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:14:1914 info: All extrinsic calls in the batch Tx succeeded!
integration-tests:flow:initStorageBucketViaCLI +14s
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 info: Initializing runtime connection to: ws://localhost:9944
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 info: Waiting for chain to be synced before proceeding.
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 info: Updating the bag...
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:15:1915 debug: Sending utility.forceBatch extrinsic...
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:16:1916 debug: Extrinsic successful!
integration-tests:flow:initStorageBucketViaCLI 2023-07-28 00:19:16:1916 error: Following extrinsic calls in the batch Tx failed:
integration-tests:flow:initStorageBucketViaCLI [
integration-tests:flow:initStorageBucketViaCLI {
integration-tests:flow:initStorageBucketViaCLI "args": "{\"static\":{\"workingGroup\":\"Storage\"}},[],[19]",
integration-tests:flow:initStorageBucketViaCLI "error": "StorageBucketIsNotBoundToBag (The requested storage bucket is not bound to a bag.)"
integration-tests:flow:initStorageBucketViaCLI }
integration-tests:flow:initStorageBucketViaCLI ]}
integration-tests:flow:initStorageBucketViaCLI +2s
integration-tests:flow:initStorageBucketViaCLI Done +9s
integration-tests:job:single-flow [Succeeded] +25s
Job Results:
single-flow: Succeeded
Writing generated account to output.json
✨ Done in 35.33s.
✨ Done in 35.52s.Maybe I'll open a PR with this simple addition. |
addresses #4591
based on #4796