فهرست منبع

Merge branch 'babylon' into query-node-types

Leszek Wiesner 4 سال پیش
والد
کامیت
da8d0825e5

+ 14 - 5
.github/workflows/run-network-tests.yml

@@ -205,8 +205,17 @@ jobs:
         run: docker-compose --file docker-compose-with-storage.yml up -d
       - name: Add development storage node and initialize content directory
         run: DEBUG=* yarn storage-cli dev-init
-      - name: Wait for storage-node to publish identity
-        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
+      - name: Try uploading
+        run: |
+          WAIT_TIME=90
+          export DEBUG=joystream:*
+          for i in {1..4}; do
+            [ "$i" == "4" ] && exit -1
+            echo "Waiting for ipfs name registration"
+            sleep ${WAIT_TIME}
+            if yarn storage-cli upload ./pioneer/packages/apps/public/images/default-thumbnail.png 1 0; then
+              break
+            else
+              echo "Upload test failed, will retry"
+            fi
+          done

+ 2 - 2
cli/src/commands/media/uploadVideo.ts

@@ -120,7 +120,7 @@ export default class UploadVideoCommand extends ContentDirectoryCommandBase {
       this.error('No bootstrap endpoints available', { exit: ExitCodes.ApiError })
     }
     this.log('Bootstrap endpoint:', bootstrapEndpoint)
-    const discoveryEndpoint = new URL(`/discover/v0/${storageProviderId}`, bootstrapEndpoint).toString()
+    const discoveryEndpoint = new URL(`discover/v0/${storageProviderId}`, bootstrapEndpoint).toString()
     try {
       const data = (await axios.get(discoveryEndpoint)).data
       return data
@@ -135,7 +135,7 @@ export default class UploadVideoCommand extends ContentDirectoryCommandBase {
     if (typeof data === 'object' && data !== null && data.serialized) {
       const unserialized = JSON.parse(data.serialized)
       if (unserialized.asset && unserialized.asset.endpoint && typeof unserialized.asset.endpoint === 'string') {
-        return new URL(`/asset/v0/${contentId.encode()}`, unserialized.asset.endpoint).toString()
+        return new URL(`asset/v0/${contentId.encode()}`, unserialized.asset.endpoint).toString()
       }
     }
     this.error(`Unexpected discovery data: ${JSON.stringify(data)}`)

+ 2 - 1
package.json

@@ -33,7 +33,8 @@
     "@polkadot/wasm-crypto": "^1.2.1",
     "babel-core": "^7.0.0-bridge.0",
     "typescript": "^3.9.7",
-    "bn.js": "^5.1.2"
+    "bn.js": "^5.1.2",
+    "@dzlzv/hydra-indexer-lib": "0.0.19-legacy.1.26.1"
   },
   "devDependencies": {
     "husky": "^4.2.5",

+ 1 - 1
query-node/package.json

@@ -3,7 +3,7 @@
 	"version": "1.0.0",
 	"description": "GraphQL server and Substrate indexer. Generated with ♥ by Hydra-CLI",
 	"scripts": {
-		"build": "yarn codegen:all && tsc --build tsconfig.json",
+		"build": "yarn codegen:all && (ln -s ../../../../../node_modules/typeorm/cli.js generated/graphql-server/node_modules/.bin/typeorm || :) && tsc --build tsconfig.json",
 		"test": "echo \"Error: no test specified\" && exit 1",
 		"clean": "rm -rf ./generated",
 		"processor:start": "(cd ./generated/indexer && yarn && DEBUG=${DEBUG} yarn start:processor)",

+ 5 - 1
query-node/run-tests.sh

@@ -17,7 +17,11 @@ trap cleanup EXIT
 export WS_PROVIDER_ENDPOINT_URI=ws://joystream-node:9944/
 
 # Only run codegen if no generated files found
-[ ! -d "generated/" ] && yarn codegen:all
+[ ! -d "generated/" ] && yarn build
+
+# Make sure typeorm is available.. it get removed again when yarn is run again
+# typeorm commandline is used by db:migrate step below.
+ln -s ../../../../../node_modules/typeorm/cli.js generated/graphql-server/node_modules/.bin/typeorm || :
 
 yarn db:up
 yarn db:migrate

+ 1 - 1
storage-node/packages/cli/src/cli.ts

@@ -104,7 +104,7 @@ const commands = {
 
 // Entry point.
 export async function main() {
-  const api = await RuntimeApi.create()
+  const api = await RuntimeApi.create({ retries: 3 })
 
   // Simple CLI commands
   const command = cli.input[0]

+ 8 - 2
storage-node/packages/runtime-api/index.js

@@ -55,14 +55,20 @@ class RuntimeApi {
     options = options || {}
 
     const provider = new WsProvider(options.provider_url || 'ws://localhost:9944')
-
+    let attempts = 0
     // Create the API instrance
     while (true) {
+      attempts++
+
+      if (options.retries && attempts > options.retries) {
+        throw new Error('Timeout trying to connect to node')
+      }
+
       try {
         this.api = await ApiPromise.create({ provider, types: types })
         break
       } catch (err) {
-        debug('connecting to node failed, will retry..')
+        debug('Connecting to node failed, will retry..')
       }
       await sleep(5000)
     }

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 515 - 19
yarn.lock


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است