Skip to content

Commit

Permalink
chore: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobench committed Oct 2, 2023
1 parent ee9bc18 commit 883adc1
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 26 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"test:e2e:no-goth": "jest tests/e2e/**.spec.ts --testTimeout=180000 --runInBand --forceExit",
"test:cypress": "cypress run",
"test:examples": "ts-node --project tsconfig.spec.json tests/examples/examples.test.ts",
"test:examples:no-goth": "ts-node --project tsconfig.spec.json tests/examples/examples.test.ts --no-goth",
"lint": "npm run lint:ts && npm run lint:ts:tests && npm run lint:eslint",
"lint:ts": "tsc --project tsconfig.json --noEmit",
"lint:ts:tests": "tsc --project tests/tsconfig.json --noEmit",
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/Requestor.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN apt-get update -q \
ca-certificates \
xz-utils \
curl \
sshpass \
python3 \
&& apt-get remove --purge -y \
&& apt-get clean -y \
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/data-node/ya-provider/presets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"exeunit-name": "wasmtime",
"pricing-model": "linear",
"usage-coeffs": {
"cpu": 3.000000001,
"cpu": 0.500000001,
"duration": 0.0,
"initial": 0.0
}
Expand All @@ -16,7 +16,7 @@
"exeunit-name": "vm",
"pricing-model": "linear",
"usage-coeffs": {
"cpu": 3.000000001,
"cpu": 0.500000001,
"duration": 0.0,
"initial": 0.0
}
Expand All @@ -26,7 +26,7 @@
"exeunit-name": "wasmtime",
"pricing-model": "linear",
"usage-coeffs": {
"cpu": 3.000000001,
"cpu": 0.500000001,
"duration": 0.0,
"initial": 0.0
}
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ services:
- /root/.local/share/yagna/
- ../../:/golem-js
environment:
- YAGNA_AUTOCONF_APPKEY=e2e-test
- 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=e2e-test
- YAGNA_APPKEY=try_golem

healthcheck:
test: ["CMD-SHELL", "curl -s -o /dev/null -w '%{http_code}' http://localhost:7465 | grep -q 401"]
Expand Down
21 changes: 1 addition & 20 deletions tests/examples/examples.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import { spawn } from "child_process";
import { dirname, basename, resolve } from "path";
import { Goth } from "../goth/goth";
import chalk from "chalk";
import testExamples from "./examples.json";

const noGoth = process.argv[2] === "--no-goth";
const gothConfig = resolve("../goth/assets/goth-config.yml");
const gothStartingTimeout = 180;
const goth = new Goth(gothConfig);

const examples = !noGoth ? testExamples.filter((e) => !e?.noGoth) : testExamples;
const criticalLogsRegExp = [/Task *. timeot/, /Task *. has been rejected/, /ERROR: TypeError/, /ERROR: Error/gim];

type Example = {
cmd: string;
path: string;
args?: string[];
timeout?: number;
noGoth?: boolean;
skip?: boolean;
};

Expand Down Expand Up @@ -62,16 +54,6 @@ async function test(cmd: string, path: string, args: string[] = [], timeout = 18
async function testAll(examples: Example[]) {
const failedTests = new Set<string>();
const skippedTests = new Set<string>();
if (!noGoth)
await Promise.race([
goth.start(),
new Promise((res, rej) =>
setTimeout(
() => rej(new Error(`The Goth starting timeout was reached after ${gothStartingTimeout} seconds`)),
gothStartingTimeout * 1000,
),
),
]);
for (const example of examples) {
try {
console.log(chalk.yellow(`\n---- Starting test: "${example.path}" ----\n`));
Expand All @@ -87,7 +69,6 @@ async function testAll(examples: Example[]) {
failedTests.add(example.path);
}
}
if (!noGoth) await goth.end().catch((error) => console.error(error));
console.log(
chalk.bold.yellow("\n\nTESTS RESULTS: "),
chalk.bgGreen.black(` ${examples.length - failedTests.size - skippedTests.size} passed `),
Expand All @@ -102,4 +83,4 @@ async function testAll(examples: Example[]) {
process.exit(failedTests.size > 0 ? 1 : 0);
}

testAll(examples).then();
testAll(testExamples).then();

0 comments on commit 883adc1

Please sign in to comment.