run-migration-tests.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env bash
  2. set -e
  3. SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
  4. cd $SCRIPT_PATH
  5. # Location to store runtime WASM for runtime upgrade
  6. DATA_PATH=${DATA_PATH:=$(pwd)/data}
  7. # The djoystream/node ocker image tag to start chain
  8. export RUNTIME=${RUNTIME:=latest}
  9. # The joystream/node docker image tag which contains WASM runtime to upgrade chain with
  10. TARGET_RUNTIME=${TARGET_RUNTIME:=latest}
  11. # Prevent joystream cli from prompting
  12. export AUTO_CONFIRM=true
  13. CONTAINER_ID=`MAKE_SUDO_MEMBER=true ./run-test-node-docker.sh`
  14. function cleanup() {
  15. docker logs ${CONTAINER_ID} --tail 15
  16. docker-compose -f ../../docker-compose.yml down -v
  17. rm ./assets/TestChannel__rejectedContent.json || true
  18. rm ./assets/TestVideo__rejectedContent.json || true
  19. }
  20. function pre_migration_hook() {
  21. sleep 10 # needed otherwise docker image won't be ready yet
  22. # Display runtime version
  23. yarn workspace api-scripts tsnode-strict src/status.ts | grep Runtime
  24. yarn joystream-cli account:choose --address 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY # Alice
  25. echo "creating 1 channel"
  26. yarn joystream-cli content:createChannel --input=./assets/TestChannel.json --context=Member || true
  27. echo "adding 1 video to the above channel"
  28. yarn joystream-cli content:createVideo -c 1 --input=./assets/TestVideo.json || true
  29. }
  30. function post_migration_hook() {
  31. echo "*** verify existence of the 5 new groups ***"
  32. yarn joystream-cli working-groups:overview --group=operationsAlpha
  33. yarn joystream-cli working-groups:overview --group=operationsBeta
  34. yarn joystream-cli working-groups:overview --group=operationsGamma
  35. yarn joystream-cli working-groups:overview --group=curators
  36. yarn joystream-cli working-groups:overview --group=distributors
  37. echo "*** verify previously created channel and video are cleared ***"
  38. # FIXME: assert these fail as expected
  39. yarn joystream-cli content:videos 1 || true
  40. yarn joystream-cli content:channel 1 || true
  41. }
  42. trap cleanup EXIT
  43. if [ "$TARGET_RUNTIME" == "$RUNTIME" ]; then
  44. echo "Not Performing a runtime upgrade."
  45. else
  46. # FIXME: code against old runtime will fail running from newer runtime code
  47. pre_migration_hook
  48. # Copy new runtime wasm file from target joystream/node image
  49. echo "Extracting wasm blob from target joystream/node image."
  50. id=$(docker create joystream/node:${TARGET_RUNTIME})
  51. docker cp $id:/joystream/runtime.compact.wasm ${DATA_PATH}
  52. docker rm $id
  53. # Display runtime version before runtime upgrade
  54. yarn workspace api-scripts tsnode-strict src/status.ts | grep Runtime
  55. echo "Performing runtime upgrade."
  56. yarn workspace api-scripts tsnode-strict \
  57. src/dev-set-runtime-code.ts -- ${DATA_PATH}/runtime.compact.wasm
  58. echo "Runtime upgraded."
  59. echo "Performing migration tests"
  60. # post migration hook
  61. post_migration_hook
  62. echo "Done with migrations tests"
  63. fi
  64. # Display runtime version
  65. yarn workspace api-scripts tsnode-strict src/status.ts | grep Runtime