Skip to content

Commit

Permalink
Add remote integration test workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Antony1060 committed Feb 13, 2024
1 parent 2cf6d9f commit 88092fd
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 75 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/prod_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
on:
schedule:
- cron: "0 0 * * *"
workflow_call:

jobs:
test:
name: Test ENState 🚀
runs-on: arc-runner-set
strategy:
fail-fast: false
matrix:
suite: [enstate.rs, worker.enstate.rs]
steps:
- run: bun install
working-directory: test

- name: Test
run: bun test remote --rerun-each 2
env:
REMOTE_URL: https://${{ matrix.suite }}
working-directory: test
36 changes: 35 additions & 1 deletion test/src/test_implementation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { describe, expect, test } from 'bun:test';

import { Dataset } from '../data';
import {
Dataset,
dataset_address_bulk,
dataset_address_single,
dataset_name_bulk,
dataset_name_single,
dataset_universal_bulk,
dataset_universal_single,
} from '../data';
import { http_fetch } from './http_fetch';

export const test_implementation = <DataSet extends Dataset<DataType>, DataType extends {}>(
function_name: string,
Expand All @@ -17,3 +26,28 @@ export const test_implementation = <DataSet extends Dataset<DataType>, DataType
}
});
};

export const describe_for = (prefix: string, base_url: string) => {
test_implementation(`${prefix}/name`, http_fetch(`${base_url}/n/`), dataset_name_single);
test_implementation(`${prefix}/address`, http_fetch(`${base_url}/a/`), dataset_address_single);
test_implementation(
`${prefix}/universal`,
http_fetch(`${base_url}/u/`),
dataset_universal_single
);
test_implementation(
`${prefix}/bulk/name`,
http_fetch(`${base_url}/bulk/n?`),
dataset_name_bulk
);
test_implementation(
`${prefix}/bulk/address`,
http_fetch(`${base_url}/bulk/a?`),
dataset_address_bulk
);
test_implementation(
`${prefix}/bulk/universal`,
http_fetch(`${base_url}/bulk/u?`),
dataset_universal_bulk
);
};
5 changes: 5 additions & 0 deletions test/tests/remote.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { describe_for } from '../src/test_implementation';

const url = process.env.REMOTE_URL ?? 'https://enstate.rs';

describe_for(`remote (${url})`, url);
39 changes: 2 additions & 37 deletions test/tests/server.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Subprocess } from 'bun';
import { afterAll, beforeAll } from 'bun:test';

import { dataset_address_bulk, dataset_name_bulk, dataset_universal_bulk } from '../data';
import {
dataset_address_single,
dataset_name_single,
dataset_universal_single,
} from '../data/single';
import { http_fetch } from '../src/http_fetch';
import { test_implementation } from '../src/test_implementation';
import { describe_for } from '../src/test_implementation';

const TEST_RELEASE = true;

Expand Down Expand Up @@ -57,32 +50,4 @@ afterAll(async () => {
server?.kill();
});

const PREFIX = 'server';

test_implementation(`${PREFIX}/name`, http_fetch('http://0.0.0.0:3000/n/'), dataset_name_single);
test_implementation(
`${PREFIX}/address`,
http_fetch('http://0.0.0.0:3000/a/'),
dataset_address_single
);
test_implementation(
`${PREFIX}/universal`,
http_fetch('http://0.0.0.0:3000/u/'),
dataset_universal_single
);

test_implementation(
`${PREFIX}/bulk/name`,
http_fetch('http://0.0.0.0:3000/bulk/n?'),
dataset_name_bulk
);
test_implementation(
`${PREFIX}/bulk/address`,
http_fetch('http://0.0.0.0:3000/bulk/a?'),
dataset_address_bulk
);
test_implementation(
`${PREFIX}/bulk/universal`,
http_fetch('http://0.0.0.0:3000/bulk/u?'),
dataset_universal_bulk
);
describe_for('server', 'http://127.0.0.1:3000');
39 changes: 2 additions & 37 deletions test/tests/worker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import { Subprocess } from 'bun';
import { afterAll, beforeAll } from 'bun:test';

import { dataset_address_bulk, dataset_name_bulk, dataset_universal_bulk } from '../data';
import {
dataset_address_single,
dataset_name_single,
dataset_universal_single,
} from '../data/single';
import { http_fetch } from '../src/http_fetch';
import { test_implementation } from '../src/test_implementation';
import { describe_for } from '../src/test_implementation';

let server: Subprocess<'ignore', 'pipe', 'inherit'> | undefined;

Expand Down Expand Up @@ -44,32 +37,4 @@ afterAll(async () => {
await server?.exited;
});

const PREFIX = 'worker';

test_implementation(`${PREFIX}/name`, http_fetch('http://0.0.0.0:3000/n/'), dataset_name_single);
test_implementation(
`${PREFIX}/address`,
http_fetch('http://0.0.0.0:3000/a/'),
dataset_address_single
);
test_implementation(
`${PREFIX}/universal`,
http_fetch('http://0.0.0.0:3000/u/'),
dataset_universal_single
);

test_implementation(
`${PREFIX}/bulk/name`,
http_fetch('http://0.0.0.0:3000/bulk/n?'),
dataset_name_bulk
);
test_implementation(
`${PREFIX}/bulk/address`,
http_fetch('http://0.0.0.0:3000/bulk/a?'),
dataset_address_bulk
);
test_implementation(
`${PREFIX}/bulk/universal`,
http_fetch('http://0.0.0.0:3000/bulk/u?'),
dataset_universal_bulk
);
describe_for('worker', 'http://127.0.0.1:3000');

0 comments on commit 88092fd

Please sign in to comment.