Skip to content

Commit

Permalink
fix: local integration testing setup/timeouts (#1705)
Browse files Browse the repository at this point in the history
## Description

In support of #1661, this PR fixes issues with test setup for
integration tests.

End to End Test:  <!-- if applicable -->  
(See [Pepr Excellent
Examples](https://github.com/defenseunicorns/pepr-excellent-examples))

## Related Issue

Relates to #1661

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Other (security config, docs update, etc)

## Checklist before merging
- [x] Unit,
[Journey](https://github.com/defenseunicorns/pepr/tree/main/journey),
[E2E Tests](https://github.com/defenseunicorns/pepr-excellent-examples),
[docs](https://github.com/defenseunicorns/pepr/tree/main/docs),
[adr](https://github.com/defenseunicorns/pepr/tree/main/adr) added or
updated as needed
- [x] [Contributor Guide
Steps](https://docs.pepr.dev/main/contribute/#submitting-a-pull-request)
followed

---------

Co-authored-by: Barrett <[email protected]>
  • Loading branch information
samayer12 and btlghrants authored Jan 22, 2025
1 parent 1bb73c5 commit 045c299
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion integration/cli/build.defaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe("build", () => {

beforeAll(async () => {
await workdir.recreate();
});
}, time.toMs("60s"));

describe("builds a module", () => {
const id = FILE.split(".").at(1);
Expand Down
4 changes: 2 additions & 2 deletions integration/cli/build.help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("build", () => {

beforeAll(async () => {
await workdir.recreate();
});
}, time.toMs("60s"));

it(
"gives command line help",
Expand All @@ -26,6 +26,6 @@ describe("build", () => {
expect(result.stderr.join("").trim()).toBe("");
expect(result.stdout.at(0)).toMatch("Usage: pepr build");
},
time.toMs("30s"),
time.toMs("60s"),
);
});
2 changes: 1 addition & 1 deletion integration/cli/build.noembed.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("build", () => {

beforeAll(async () => {
await workdir.recreate();
});
}, time.toMs("60s"));

describe("builds a module", () => {
const id = FILE.split(".").at(1);
Expand Down
2 changes: 1 addition & 1 deletion integration/cli/build.nonconflict.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe("build", () => {

beforeAll(async () => {
await workdir.recreate();
});
}, time.toMs("60s"));

describe("builds a module", () => {
const id = FILE.split(".").at(1);
Expand Down
2 changes: 1 addition & 1 deletion integration/cli/build.registryinfo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("build", () => {

beforeAll(async () => {
await workdir.recreate();
});
}, time.toMs("60s"));

describe("builds a module", () => {
const id = FILE.split(".").at(1);
Expand Down
2 changes: 1 addition & 1 deletion integration/cli/build.version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe("build", () => {

beforeAll(async () => {
await workdir.recreate();
});
}, time.toMs("60s"));

describe("builds a module", () => {
const id = FILE.split(".").at(1);
Expand Down
5 changes: 4 additions & 1 deletion integration/helpers/pepr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { resolve } from "node:path";
import { readFile, writeFile } from "node:fs/promises";
import { Spec, Cmd, Result } from "./cmd";
import { clone } from "ramda";
import * as time from "./time";

const HERE = __dirname;

Expand Down Expand Up @@ -33,5 +34,7 @@ export async function cli(workdir: string, spec: Spec): Promise<Result> {
_spec.env = { ..._spec.env, NPM_CONFIG_CACHE: `${root}/integration/testroot/.npm` };

const cmd = new Cmd(_spec);
return await cmd.runRaw();
const result = await cmd.runRaw();
await time.nap(time.toMs("5s")); // Let filesystem settle after I/O operations
return result;
}
8 changes: 6 additions & 2 deletions integration/prep.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#!/bin/sh
#!/bin/bash
# This script makes a version of the npm cache for local use to avoid installing test artifacts into the global npm cache.
# This isn't an issue in CI where environments are ephemeral, but is useful for local testing.

set -euo pipefail

ME="$(readlink -f "$0")"
HERE="$(dirname "$ME")"
ROOT="$(dirname "$HERE")"

export NPM_CONFIG_CACHE="${HERE}/testroot/.npm"
mkdir --parents "$NPM_CONFIG_CACHE"
# ubuntu supports "--parents" long opt but macOS does not, so using "-p" short opt
mkdir -p "$NPM_CONFIG_CACHE"

npm run build
npx --yes file://${ROOT}/pepr-0.0.0-development.tgz

0 comments on commit 045c299

Please sign in to comment.