Skip to content

Commit b0e4cb5

Browse files
committed
Integration tests spring cleaning
Changes: * Removed old fixtures as they arent used * Restructured fixtures dir: it now has only a php folder * Restructured tests to have one directory per domain * Updated readme to explain domain-specific tests
1 parent a2476ab commit b0e4cb5

28 files changed

Lines changed: 32 additions & 1302 deletions

File tree

.github/workflows/integration-test-workflow.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ jobs:
4444
env:
4545
WASMER_REGISTRY: https://registry.wasmer.wtf/graphql
4646
WASMER_TOKEN: ${{ secrets.token }}
47-
run:
48-
deno test --allow-all ./tests/test.ts ./tests/volumes.test.ts --quiet
47+
run: deno test --allow-all --parallel --quiet ./tests/general/
4948
- name: Notify failure in Slack
5049
env:
5150
TEST_FAILURE_WEBHOOK: ${{ secrets.test_failure_webhook }}
@@ -79,7 +78,7 @@ jobs:
7978
deno test --filter "Log test: Check fetch is logged on simple logging app" --allow-all --quiet
8079
# ... and then the tests which depend on logging for validation. Doesn't make any
8180
# sense to run these if we know that logging doesn't work: just a waste of resources
82-
deno test --allow-all ./tests/job.test.ts --quiet
81+
deno test --allow-all --parallel --quiet ./tests/job
8382
- name: Notify failure in Slack
8483
env:
8584
TEST_FAILURE_WEBHOOK: ${{ secrets.test_failure_webhook }}
@@ -110,7 +109,7 @@ jobs:
110109
WASMER_TOKEN: ${{ secrets.token }}
111110
run: |
112111
deno test --filter "Log test: Check fetch is logged on simple logging app" --allow-all --quiet
113-
deno test --allow-all ./tests/wordpress.test.ts --quiet
112+
deno test --allow-all --parallel --quiet ./tests/wordpress
114113
- name: Notify failure in Slack
115114
env:
116115
TEST_FAILURE_WEBHOOK: ${{ secrets.test_failure_webhook }}
@@ -140,7 +139,7 @@ jobs:
140139
WASMER_REGISTRY: https://registry.wasmer.wtf/graphql
141140
WASMER_TOKEN: ${{ secrets.token }}
142141
run: |
143-
deno test --allow-all ./tests/wordpress.test.ts --quiet
142+
deno test --allow-all --parallel --quiet ./tests/autobuild
144143
- name: Notify failure in Slack
145144
env:
146145
TEST_FAILURE_WEBHOOK: ${{ secrets.test_failure_webhook }}

README.md

Lines changed: 15 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -60,78 +60,18 @@ HTTP requests to Edge.
6060
NOTE: **You must use the TestEnv helpers to run CLI commands and to send
6161
requests to Edge to ensure test environment settings are respected.**
6262

63-
The following code shows an example test with commentary:
64-
65-
```
66-
// Register a test with the Deno test runner.
67-
Deno.test('app-create-from-package', async () => {
68-
// Determine the test environment.
69-
const env = TestEnv.fromEnv();
70-
71-
// An app definition is a structured object that describes app configration
72-
// with an optional package definition.
73-
// This can be created and deployed with TestEnv.deployApp().
74-
const spec: AppDefinition = {
75-
// app.yaml config.
76-
appYaml: {
77-
kind: 'wasmer.io/App.v0',
78-
name: randomAppName(),
79-
package: '.',
80-
},
81-
82-
// Package definition (wasmer.toml)
83-
wasmerToml: {
84-
dependencies: {
85-
"wasmer/static-web-server": "1",
86-
},
87-
fs: {
88-
"/public": "public",
89-
// "/settings": "settings",
90-
},
91-
command: [{
92-
name: "script",
93-
module: "wasmer/static-web-server:webserver",
94-
runner: "https://webc.org/runner/wasi",
95-
}],
96-
},
97-
98-
// Files that should be present in the package.
99-
files: {
100-
'public': {
101-
'index.html': `<html><body>Hello!</body></html>`,
102-
},
103-
}
104-
};
105-
106-
107-
// Create a directory with the package contents and app.yaml.
108-
// Then use the `wasmer deploy` command to deploy the app.
109-
const info = await env.deployApp(spec);
110-
111-
// Send an HTTP request to the app running on Edge
112-
// `fetchApp` is the same as the regular Javascript `fetch()`, but it
113-
// ensures that requests are sent to the right target.
114-
const res = await env.fetchApp(info, '/', {headers: {...})
115-
const body = await res.text();
116-
117-
// Assert that the response is as expected.
118-
assertEquals(res.status, 200);
119-
assertEquals(body.trim(), '<html><body>Hello!</body></html>');
120-
121-
// NOTE: you can use a full url instead of a path as well, in which case
122-
// the wrapper will make sure the request is sent to the Edge target server
123-
// if EDGE_SERVER is specified.
124-
const res = await env.fetchApp(info, 'https://....', {headers: {...})
125-
126-
// You can also run custom wasmer CLI commands like this:
127-
// This will throw an exception if the command fails.
128-
const output = await env.runWasmerCommand({
129-
args: [...],
130-
// Use the app directory as the working directory.
131-
cwd: info.dir
132-
env: {...},
133-
});
134-
assertEquals(output.stdout, 'my stdout...');
135-
assertEquals(output.stderr, 'my stderr');
136-
});
137-
```
63+
### Test UATs and project structure
64+
65+
Each area of functionality is intended to have its own directory and pipeline step, correlating roughly with the [QA UATs](https://linear.app/wasmer/settings/teams/QA/templates).
66+
This is to optimize each suite (allow failing fast) and to quickly highlight issue in pipeline, as well as reruns on periodic tests.
67+
68+
So, please place tests within the feature's respective domain.
69+
Example: If additional functionality is added to app-jobs, either modify [the main job test file](./tests/job/job.test.ts), or write a new test file in the same directory.
70+
71+
If writing tests for a features within a new domain, create a new directory and be sure to add it to the [workflow](./.github/workflows/integration-test-workflow.yaml).
72+
What constitutes a new domain?
73+
[Noone knows!](https://redis.io/glossary/domain-driven-design-ddd/#:~:text=At%20its%20core%2C%20DDD%20is,within%20which%20the%20software%20operates.)
74+
It's all very fluffy.
75+
But if it feels radically different to other features (such as, Agentic Workloads vs php webserver), perhaps it's a new domain.
76+
77+
If you're unsure where to place a test, simply write the test as a new file and place it under `./tests/general` with a name describing the functionality (for example `volumes.test.ts`).

0 commit comments

Comments
 (0)