Skip to content

Commit

Permalink
Merge pull request #1033 from golemfactory/e2e-test-troubleshooting
Browse files Browse the repository at this point in the history
E2e test troubleshooting
  • Loading branch information
grisha87 authored Jul 17, 2024
2 parents e3b6361 + f399bca commit b14e8d6
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 25 deletions.
17 changes: 16 additions & 1 deletion .github/actions/prepare-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,26 @@ 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
if: ${{ inputs.type == 'cypress' }}
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"
2 changes: 2 additions & 0 deletions examples/web/hello.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ <h3>Results</h3>
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) {
Expand Down
14 changes: 8 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/golem-network/golem-network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 6 additions & 9 deletions src/market/market.module.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
});
});

Expand Down
10 changes: 8 additions & 2 deletions src/market/market.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,13 +530,20 @@ export class MarketModuleImpl implements MarketModule {
agreementOptions?: AgreementOptions,
signalOrTimeout?: number | AbortSignal,
): Promise<Agreement> {
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();
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 9 additions & 4 deletions tests/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: .
Expand All @@ -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: .
Expand All @@ -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
Expand Down

0 comments on commit b14e8d6

Please sign in to comment.