Browse Source

network-tests: query node setup with content dir integration tests job

Mokhtar Naamani 4 years ago
parent
commit
6a13491d17

+ 11 - 9
.github/workflows/run-network-tests.yml

@@ -78,7 +78,7 @@ jobs:
           name: ${{ steps.compute_shasum.outputs.shasum }}-joystream-node-docker-image.tar.gz
           path: joystream-node-docker-image.tar.gz
   
-  network_tests_1:
+  basic_runtime_with_upgrade:
     name: Integration Tests (Runtime Upgrade)
     needs: build_images
     runs-on: ubuntu-latest
@@ -102,7 +102,7 @@ jobs:
       - name: Execute network tests
         run: RUNTIME=alexandria tests/network-tests/run-tests.sh full
 
-  network_tests_2:
+  basic_runtime:
     name: Integration Tests (New Chain)
     needs: build_images
     runs-on: ubuntu-latest
@@ -126,7 +126,7 @@ jobs:
       - name: Execute network tests
         run: tests/network-tests/run-tests.sh full
 
-  network_tests_3:
+  content_dir_init:
     name: Content Directory Initialization
     needs: build_images
     runs-on: ubuntu-latest
@@ -152,8 +152,8 @@ jobs:
       - name: Initialize the content directory
         run: yarn workspace cd-schemas initialize:dev
 
-  network_tests_4:
-    name: Content Direcotry Integration Tests
+  query_node:
+    name: Query Node Integration Tests
     needs: build_images
     runs-on: ubuntu-latest
     steps:
@@ -173,10 +173,12 @@ jobs:
         run: yarn install --frozen-lockfile
       - name: Ensure tests are runnable
         run: yarn workspace network-tests build
-      - name: Execute network tests
-        run: tests/network-tests/run-tests.sh content-directory
+      # Bring up hydra query-node development instance, then run content directory
+      # integration tests
+      - name: Execute Tests
+        run: tests/query-node/run-tests.sh
   
-  network_tests_5:
+  storage_node:
     name: Storage Node Tests
     needs: build_images
     runs-on: ubuntu-latest
@@ -205,4 +207,4 @@ jobs:
         run: sleep 90
         # Better would be poll `http://localhost:3001/discover/v0/1` until we get 200 Response
       - name: Upload a file
-        run: DEBUG=joystream:* yarn storage-cli upload ./pioneer/packages/apps/public/images/default-thumbnail.png 1 0
+        run: DEBUG=joystream:* yarn storage-cli upload ./pioneer/packages/apps/public/images/default-thumbnail.png 1 0

+ 11 - 4
tests/network-tests/run-tests.sh

@@ -1,6 +1,9 @@
 #!/usr/bin/env bash
 set -e
 
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
 # Location that will be mounted as the /data volume in containers
 # This is how we access the initial members and balances files from
 # the containers and where generated chainspec files will be located.
@@ -51,9 +54,14 @@ docker run --rm -v ${DATA_PATH}:/data joystream/node:${RUNTIME} build-spec \
   --raw --disable-default-bootnode \
   --chain /data/chain-spec.json > ~/tmp/chain-spec-raw.json
 
+NETWORK_ARG=
+if [ "$ATTACH_TO_NETWORK" != "" ]; then
+  NETWORK_ARG="--network ${ATTACH_TO_NETWORK}"
+fi
+
 # Start a chain with generated chain spec
 # Add "-l ws=trace,ws::handler=info" to get websocket trace logs
-CONTAINER_ID=`docker run -d -v ${DATA_PATH}:/data -p 9944:9944 joystream/node:${RUNTIME} \
+CONTAINER_ID=`docker run -d -v ${DATA_PATH}:/data -p 9944:9944 ${NETWORK_ARG} --name joystream-node joystream/node:${RUNTIME} \
   --validator --alice --unsafe-ws-external --rpc-cors=all -l runtime \
   --chain /data/chain-spec-raw.json`
 
@@ -77,9 +85,8 @@ if [ "$TARGET_RUNTIME" == "$RUNTIME" ]; then
 else
   # Copy new runtime wasm file from target joystream/node image
   echo "Extracting wasm blob from target joystream/node image."
-  mkdir -p .tmp/
   id=`docker create joystream/node:${TARGET_RUNTIME}`
-  docker cp $id:/joystream/runtime.compact.wasm .tmp/
+  docker cp $id:/joystream/runtime.compact.wasm ${DATA_PATH}
   docker rm $id
 
   # Display runtime version before runtime upgrade
@@ -87,7 +94,7 @@ else
 
   echo "Performing runtime upgrade."
   DEBUG=* yarn workspace api-scripts tsnode-strict \
-    src/dev-set-runtime-code.ts -- `pwd`/.tmp/runtime.compact.wasm
+    src/dev-set-runtime-code.ts -- ${DATA_PATH}/runtime.compact.wasm
 
   echo "Runtime upgraded."
 fi

+ 1 - 0
tests/query-node/.gitignore

@@ -0,0 +1 @@
+hydra-test

+ 41 - 0
tests/query-node/run-tests.sh

@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+set -e
+
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+mkdir -p hydra-test/
+cd hydra-test
+
+npx @dzlzv/hydra-cli scaffold --wsProviderUrl=ws://joystream-node:9944/ --projectName=Test
+
+cp ../../../types/augment/all/defs.json ./mappings/typedefs.json
+# cp ../../../query-node/mappings/* ./mappings/
+# cp ../../../query-node/schema.graphql ./
+
+# might be good idea to add a typedefs.json as empty `{}` json at root, in hydra scaffold templates
+# Add a line in Dockerfile to copy typedefs into image (there are no volumes config in compose file)
+#   COPY typedefs.json /home/hydra
+
+# Sneak the typedefs file into this location to avoid need to modify the Dockerfile ;)
+export TYPES_JSON=../../mappings/typedefs.json
+
+npx @dzlzv/hydra-cli codegen
+
+# Setup the postgres database
+docker-compose up $1 -d db
+
+function cleanup() {
+    docker-compose down -v
+}
+
+trap cleanup EXIT
+
+yarn db:migrate
+
+# Bring up remaining services
+docker-compose up $1 -d
+
+# Run tests
+ATTACH_TO_NETWORK=hydra-test_default ../../network-tests/run-tests.sh content-directory
+
+