diff --git a/.github/actions/prepare-tests/action.yml b/.github/actions/prepare-tests/action.yml index 76d700a05..22a38f172 100644 --- a/.github/actions/prepare-tests/action.yml +++ b/.github/actions/prepare-tests/action.yml @@ -51,7 +51,7 @@ runs: shell: bash run: | echo "Going to build the SDK on the requestor" - docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i && npm run build" + docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && npm i --no-progress && npm run build" echo "Successfully built the SDK on the requestor" - name: Install Cypress @@ -59,3 +59,18 @@ runs: shell: bash run: | docker exec -t docker-requestor-1 /bin/sh -c "cd /golem-js && ./node_modules/.bin/cypress install" + + - name: Run a preliminary scan of offers + shell: bash + run: | + docker exec -t docker-requestor-1 /bin/sh -c "npm install --no-progress -g @prekucki/wait-for-n && wait-for-n --limit=6 --appkey=try_golem --subnet=$YAGNA_SUBNET" + + - name: List down sessions seen on that requestor + shell: bash + run: | + docker exec docker-requestor-1 /bin/sh -c "yagna net sessions" + + - name: Run a secondary scan of offers + shell: bash + run: | + docker exec -t docker-requestor-1 /bin/sh -c "npx --no-progress --yes @golem-sdk/cli market scan -k try_golem --subnet-tag $YAGNA_SUBNET --payment-network $PAYMENT_NETWORK" diff --git a/examples/web/hello.html b/examples/web/hello.html index 0e022139d..9b3af5e5b 100644 --- a/examples/web/hello.html +++ b/examples/web/hello.html @@ -115,11 +115,13 @@

Results

await glm.connect(); appendResults("Request for renting a provider machine"); const rental = await glm.oneOf({ order }); + appendResults("Rented resources from", rental.agreement.provider.name); await rental .getExeUnit() .then(async (exe) => appendResults("Reply: " + (await exe.run(`echo 'Hello Golem! 👋 from ${exe.provider.name}!'`)).stdout), ); + appendResults("Finished all work with the resources"); await rental.stopAndFinalize(); appendResults("Finalized renting process"); } catch (err) { diff --git a/package-lock.json b/package-lock.json index f48876470..c812c221d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "examples/" ], "dependencies": { + "@golem-sdk/pino-logger": "^1.1.0", "async-lock": "^1.4.1", "async-retry": "^1.3.3", "axios": "^1.6.7", @@ -33,7 +34,7 @@ "devDependencies": { "@commitlint/cli": "^19.0.3", "@commitlint/config-conventional": "^19.0.3", - "@johanblumenberg/ts-mockito": "^1.0.41", + "@johanblumenberg/ts-mockito": "^1.0.43", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-json": "^6.1.0", @@ -1459,9 +1460,9 @@ "link": true }, "node_modules/@golem-sdk/pino-logger": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@golem-sdk/pino-logger/-/pino-logger-1.0.3.tgz", - "integrity": "sha512-P9BMJ+QUlWx7C+4iku/SOnNnjzGGBEhaHtOf4IDXrtvpEg8zqxEuyw5mM7PXpAr7HU/5C/f2BcBG39i7QYfwsw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@golem-sdk/pino-logger/-/pino-logger-1.1.0.tgz", + "integrity": "sha512-FxVqTnx7ToKPCABzfEHhwXT2x/B4PWez6y6AG9AeMjH9DA/itY8kclv0DUgWPPRTW4jr1Qrf6ovZYLhPZ5o3Dw==", "dependencies": { "pino": "^8.20.0", "pino-pretty": "^11.0.0" @@ -2340,9 +2341,10 @@ } }, "node_modules/@johanblumenberg/ts-mockito": { - "version": "1.0.41", + "version": "1.0.43", + "resolved": "https://registry.npmjs.org/@johanblumenberg/ts-mockito/-/ts-mockito-1.0.43.tgz", + "integrity": "sha512-7C1JMJzYPLmW4/nFZHTQTog/wRnB45UUU3hEur1p7HJDlpQpybQWAbE8yA+mBk+95mOEfuIVNcebSAB/KGrE0w==", "dev": true, - "license": "MIT", "dependencies": { "lodash": "^4.17.20" } diff --git a/package.json b/package.json index ec712d9e5..72ca267f1 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "node": ">=18.0.0" }, "dependencies": { + "@golem-sdk/pino-logger": "^1.1.0", "async-lock": "^1.4.1", "async-retry": "^1.3.3", "axios": "^1.6.7", @@ -84,7 +85,7 @@ "devDependencies": { "@commitlint/cli": "^19.0.3", "@commitlint/config-conventional": "^19.0.3", - "@johanblumenberg/ts-mockito": "^1.0.41", + "@johanblumenberg/ts-mockito": "^1.0.43", "@rollup/plugin-alias": "^5.1.0", "@rollup/plugin-commonjs": "^25.0.7", "@rollup/plugin-json": "^6.1.0", diff --git a/src/golem-network/golem-network.ts b/src/golem-network/golem-network.ts index 1e40d30f8..6c00f5908 100644 --- a/src/golem-network/golem-network.ts +++ b/src/golem-network/golem-network.ts @@ -646,10 +646,12 @@ export class GolemNetwork { if (typeof this.options.dataTransferProtocol === "string") { switch (this.options.dataTransferProtocol) { case "ws": - return new WebSocketBrowserStorageProvider(this.yagna, {}); + return new WebSocketBrowserStorageProvider(this.yagna, { + logger: this.logger, + }); case "gftp": default: - return new GftpStorageProvider(); + return new GftpStorageProvider(this.logger); } } else if (this.options.dataTransferProtocol !== undefined) { return this.options.dataTransferProtocol; diff --git a/src/market/market.module.test.ts b/src/market/market.module.test.ts index 6414159ab..c91634fa0 100644 --- a/src/market/market.module.test.ts +++ b/src/market/market.module.test.ts @@ -439,6 +439,7 @@ describe("Market module", () => { const badProposal0 = {} as OfferProposal; const badProposal1 = {} as OfferProposal; const goodProposal = {} as OfferProposal; + const mockPool = mock(DraftOfferProposalPool); when(mockPool.acquire(_)).thenResolve(badProposal0).thenResolve(badProposal1).thenResolve(goodProposal); const goodAgreement = {} as Agreement; @@ -497,15 +498,11 @@ describe("Market module", () => { ); }); it("respects the timeout on draft proposal pool acquire and forwards the error", async () => { - const mockAcquire: DraftOfferProposalPool["acquire"] = jest - .fn() - .mockImplementation( - () => new Promise((_, reject) => setTimeout(() => reject(new Error("Failed to acquire")), 10)), - ); - const mockPool = { - acquire: mockAcquire, - } as DraftOfferProposalPool; - expect(marketModule.signAgreementFromPool(mockPool)).rejects.toThrow("Failed to acquire"); + const mockPool = mock(DraftOfferProposalPool); + when(mockPool.acquire(_)).thenCall( + () => new Promise((_, reject) => setTimeout(() => reject(new Error("Failed to acquire")), 10)), + ); + expect(marketModule.signAgreementFromPool(instance(mockPool))).rejects.toThrow("Failed to acquire"); }); }); diff --git a/src/market/market.module.ts b/src/market/market.module.ts index 2fab19229..3ed0d2277 100644 --- a/src/market/market.module.ts +++ b/src/market/market.module.ts @@ -530,13 +530,20 @@ export class MarketModuleImpl implements MarketModule { agreementOptions?: AgreementOptions, signalOrTimeout?: number | AbortSignal, ): Promise { - this.logger.info("Trying to sign an agreement ..."); + this.logger.info("Trying to sign an agreement..."); const signal = createAbortSignalFromTimeout(signalOrTimeout); const getProposal = async () => { try { signal.throwIfAborted(); + this.logger.debug("Acquiring proposal from draft proposal pool", { + draftPoolCounters: { + total: draftProposalPool.count(), + available: draftProposalPool.availableCount(), + }, + }); const proposal = await draftProposalPool.acquire(signal); + this.logger.debug("Acquired proposal from the pool", { proposal }); if (signal.aborted) { draftProposalPool.release(proposal); signal.throwIfAborted(); @@ -597,7 +604,6 @@ export class MarketModuleImpl implements MarketModule { if (isCancelled) { return; } - this.logger.debug("Waiting for reduced proposals..."); try { await proposalsBatch.waitForProposals(); const proposals = await proposalsBatch.getProposals(); diff --git a/tests/docker/docker-compose.yml b/tests/docker/docker-compose.yml index 5c945eae3..a41a888d5 100644 --- a/tests/docker/docker-compose.yml +++ b/tests/docker/docker-compose.yml @@ -20,9 +20,11 @@ services: retries: 1 start_period: 40s environment: - - YA_NET_BROADCAST_SIZE=30 + - YA_NET_BROADCAST_SIZE=10 - NODE_NAME=provider-1 - SUBNET=${YAGNA_SUBNET:-golemjstest} + - YA_NET_BIND_URL=udp://0.0.0.0:0 + - YA_NET_RELAY_HOST=63.34.24.27:7477 provider-2: build: context: . @@ -43,9 +45,11 @@ services: retries: 1 start_period: 40s environment: - - YA_NET_BROADCAST_SIZE=30 + - YA_NET_BROADCAST_SIZE=10 - NODE_NAME=provider-2 - SUBNET=${YAGNA_SUBNET:-golemjstest} + - YA_NET_BIND_URL=udp://0.0.0.0:0 + - YA_NET_RELAY_HOST=63.34.24.27:7477 requestor: build: context: . @@ -57,14 +61,15 @@ services: - /root/.local/share/yagna/ - ../../:/golem-js environment: - - YA_NET_BROADCAST_SIZE=30 + - YA_NET_BROADCAST_SIZE=10 - YAGNA_AUTOCONF_APPKEY=try_golem - YAGNA_API_URL=http://0.0.0.0:7465 - GSB_URL=tcp://0.0.0.0:7464 - YAGNA_SUBNET=${YAGNA_SUBNET:-golemjstest} - YAGNA_APPKEY=try_golem - PAYMENT_NETWORK=${PAYMENT_NETWORK} - + - YA_NET_BIND_URL=udp://0.0.0.0:0 + - YA_NET_RELAY_HOST=63.34.24.27:7477 healthcheck: test: ["CMD-SHELL", "curl -s -o /dev/null -w '%{http_code}' http://localhost:7465 | grep -q 401"] interval: 10s