Browse Source

tests: factor out query-node start script

Mokhtar Naamani 3 years ago
parent
commit
b58d180250
5 changed files with 32 additions and 75 deletions
  1. 0 35
      query-node/run-tests.sh
  2. 8 22
      query-node/start.sh
  3. 4 0
      setup.sh
  4. 1 17
      start.sh
  5. 19 1
      tests/network-tests/run-tests.sh

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

@@ -1,35 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
-cd $SCRIPT_PATH
-
-set -a
-. ../.env
-set +a
-
-function cleanup() {
-    # Show tail end of logs for the processor and indexer containers to
-    # see any possible errors
-    (echo "## Processor Logs ##" && docker logs joystream_processor_1 --tail 50) || :
-    (echo "## Indexer Logs ##" && docker logs joystream_indexer_1 --tail 50) || :
-    (echo "## Indexer API Gateway Logs ##" && docker logs joystream_hydra-indexer-gateway_1 --tail 50) || :
-    (echo "## Graphql Server Logs ##" && docker logs joystream_graphql-server_1 --tail 50) || :
-    docker-compose down -v
-}
-
-trap cleanup EXIT
-
-# Bring up db
-docker-compose up -d db
-
-# Migrate the databases
-yarn workspace query-node-root db:prepare
-yarn workspace query-node-root db:migrate
-
-docker-compose up -d graphql-server
-
-# Starting up processor will bring up all services it depends on
-docker-compose up -d processor
-
-time yarn workspace network-tests run-test-scenario content-directory

+ 8 - 22
query-node/start.sh

@@ -4,37 +4,23 @@ set -e
 SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
 cd $SCRIPT_PATH
 
-set -a
-. ../.env
-set +a
-
-# Start the joystream-node first to allow fetching Olympia metadata during build (typegen)
-docker-compose up -d joystream-node
-
 # Only run codegen if no generated files found
 [ ! -d "generated/" ] && yarn build
 
 # Bring up db
-docker-compose up -d db
-
-# Override DB_HOST for db setup
-export DB_HOST=localhost
+docker-compose -f ../docker-compose.yml up -d db
 
 # Make sure we use dev config for db migrations (prevents "Cannot create database..." and some other errors)
-yarn workspace query-node config:dev
-
+docker-compose -f ../docker-compose.yml run --rm --entrypoint sh graphql-server -c "yarn workspace query-node config:dev"
 # Migrate the databases
-yarn workspace query-node-root db:prepare
-yarn workspace query-node-root db:migrate
-
-# Set DB_HOST back to docker-service one
-export DB_HOST=db
+docker-compose -f ../docker-compose.yml run --rm --entrypoint sh graphql-server -c "yarn workspace query-node-root db:prepare"
+docker-compose -f ../docker-compose.yml run --rm --entrypoint sh graphql-server -c "yarn workspace query-node-root db:migrate"
 
 # Start indexer and gateway
-docker-compose up -d indexer
-docker-compose up -d hydra-indexer-gateway
+docker-compose -f ../docker-compose.yml up -d indexer
+docker-compose -f ../docker-compose.yml up -d hydra-indexer-gateway
 
 # Start processor and graphql server
-docker-compose up -d processor
-docker-compose up -d graphql-server
+docker-compose -f ../docker-compose.yml up -d processor
+docker-compose -f ../docker-compose.yml up -d graphql-server
 

+ 4 - 0
setup.sh

@@ -34,6 +34,10 @@ rustup target add wasm32-unknown-unknown --toolchain nightly-2021-03-24
 
 rustup component add rustfmt clippy
 
+# Install substrate keychain tool - install doesn't seem to work lately.
+# cargo install --force subkey --git https://github.com/paritytech/substrate --version 2.0.1 --locked
+# You can use docker instead https://github.com/paritytech/substrate/tree/master/bin/utils/subkey#run-in-a-container
+
 # Volta nodejs, npm, yarn tools manager
 curl https://get.volta.sh | bash
 

+ 1 - 17
start.sh

@@ -26,23 +26,7 @@ SKIP_MOCK_CONTENT=true ./tests/network-tests/run-test-scenario.sh setup-new-chai
 yarn workspace api-scripts set-sudo-as-screening-auth
 
 ## Query Node Infrastructure
-
-# Initialize a new database for the query node infrastructure
-docker-compose up -d db
-
-# Make sure we use dev config for db migrations (prevents "Cannot create database..." and some other errors)
-docker-compose run --rm --entrypoint sh graphql-server -c "yarn workspace query-node config:dev"
-# Migrate the databases
-docker-compose run --rm --entrypoint sh graphql-server -c "yarn workspace query-node-root db:prepare"
-docker-compose run --rm --entrypoint sh graphql-server -c "yarn workspace query-node-root db:migrate"
-
-# Start indexer and gateway
-docker-compose up -d indexer
-docker-compose up -d hydra-indexer-gateway
-
-# Start processor and graphql server
-docker-compose up -d processor
-docker-compose up -d graphql-server
+./query-node/start.sh
 
 ## Storage Infrastructure
 docker-compose up -d colossus-1

+ 19 - 1
tests/network-tests/run-tests.sh

@@ -65,7 +65,7 @@ function cleanup() {
     docker logs ${CONTAINER_ID} --tail 15
     docker stop ${CONTAINER_ID}
     docker rm ${CONTAINER_ID}
-    # docker-compose -f ../../docker-compose.yml down -v
+    docker-compose -f ../../docker-compose.yml down -v
 }
 
 trap cleanup EXIT
@@ -78,5 +78,23 @@ yarn workspace api-scripts tsnode-strict src/status.ts | grep Runtime
 # Start any other services we want
 # docker-compose -f ../../docker-compose.yml up -d colossus-1
 
+# Start a query-node
+../../query-node/start.sh
+
 # Execute tests
+
+# We can load env config used to start docker services and pass them on to the
+# tests. This could be useful to capture keys used or URLs.
+# We just have to watchout for clashing env var names.
+#set -a
+#. ../../.env
+#set +a
+
+# First scenario..
 ./run-test-scenario.sh $1
+
+# In between pickup generated keys from first scenario or bootstrap scene will all well known
+# keys for roles and members..
+
+# Second scenario..
+# ./run-test-scenario.sh $2