@celilo/e2e 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,7 +58,7 @@ export async function ensureSharedInfra(): Promise<void> {
58
58
  // Verify DNS is still healthy
59
59
  try {
60
60
  const result = run(
61
- `docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} exec -T comcast-resolver dig @127.0.0.1 iamtheinternet.org NS +short +timeout=2`,
61
+ `docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} exec -T namecheap-dns dig @127.0.0.1 iamtheinternet.org SOA +short +timeout=2`,
62
62
  { cwd: getE2eDir(), timeout: 10_000 },
63
63
  );
64
64
  if (result.trim().length > 0) {
@@ -66,7 +66,7 @@ export async function ensureSharedInfra(): Promise<void> {
66
66
  }
67
67
  } catch {
68
68
  // DNS check failed — restart shared infra
69
- console.log('[e2e] Shared infra DNS check failed, restarting...');
69
+ console.log('[progress:start] shared infra DNS check failed, restarting | shared infra restarted');
70
70
  await stopSharedInfra();
71
71
  }
72
72
  }
@@ -74,7 +74,7 @@ export async function ensureSharedInfra(): Promise<void> {
74
74
  const e2eDir = getE2eDir();
75
75
 
76
76
  // Clean up any stale shared infra resources
77
- console.log('[e2e] Cleaning up stale shared infrastructure...');
77
+ console.log('[progress:start] cleaning up stale shared infrastructure | shared infra cleanup complete');
78
78
  try {
79
79
  run(`docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} down --volumes --remove-orphans`,
80
80
  { cwd: e2eDir, timeout: 30_000 });
@@ -94,33 +94,44 @@ export async function ensureSharedInfra(): Promise<void> {
94
94
  } catch {}
95
95
 
96
96
  try { run('docker network prune -f', { timeout: 10_000 }); } catch {}
97
+ try { run('docker volume prune -f', { timeout: 10_000 }); } catch {}
98
+
99
+ // Force-remove any leftover networks by name
100
+ try {
101
+ const staleNets = run('docker network ls --format "{{.Name}}"')
102
+ .split('\n')
103
+ .filter(n => n.startsWith('celilo-e2e'));
104
+ for (const net of staleNets) {
105
+ try { run(`docker network rm ${net}`, { timeout: 5_000 }); } catch {}
106
+ }
107
+ } catch {}
97
108
 
98
109
  // Generate and write compose file
99
110
  const yaml = generateSharedInfraYaml();
100
111
  writeFileSync(join(e2eDir, SHARED_COMPOSE_FILE), yaml);
101
112
 
102
113
  // Build and start
103
- console.log('[e2e] Building shared infrastructure images...');
114
+ console.log('[progress:start] building shared infrastructure images | shared images built');
104
115
  run(`docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} build`,
105
116
  { cwd: e2eDir, timeout: 300_000 });
106
117
 
107
- console.log('[e2e] Starting shared infrastructure...');
118
+ console.log('[progress:start] starting shared infrastructure | shared infra started');
108
119
  run(`docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} up -d`,
109
120
  { cwd: e2eDir, timeout: 120_000 });
110
121
 
111
122
  // Wait for DNS convergence
112
- console.log('[e2e] Waiting for DNS convergence...');
123
+ console.log('[progress:start] waiting for DNS convergence | DNS converged');
113
124
  const start = Date.now();
114
125
  const timeout = 60_000;
115
126
  while (Date.now() - start < timeout) {
116
127
  try {
117
128
  const result = run(
118
- `docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} exec -T comcast-resolver dig @127.0.0.1 iamtheinternet.org NS +short +timeout=2`,
129
+ `docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} exec -T namecheap-dns dig @127.0.0.1 iamtheinternet.org SOA +short +timeout=2`,
119
130
  { cwd: e2eDir, timeout: 10_000 },
120
131
  );
121
132
  if (result.trim().length > 0) {
122
133
  sharedInfraRunning = true;
123
- console.log('[e2e] Shared infrastructure ready');
134
+ console.log('[progress:done] shared infrastructure ready');
124
135
  return;
125
136
  }
126
137
  } catch {
@@ -135,7 +146,7 @@ export async function ensureSharedInfra(): Promise<void> {
135
146
  * Stop the shared infrastructure. Called once at the end of the test suite.
136
147
  */
137
148
  export async function stopSharedInfra(): Promise<void> {
138
- console.log('[e2e] Stopping shared infrastructure...');
149
+ console.log('[progress:start] stopping shared infrastructure | shared infra stopped');
139
150
  const e2eDir = getE2eDir();
140
151
  try {
141
152
  run(`docker compose -f ${SHARED_COMPOSE_FILE} -p ${SHARED_PROJECT_NAME} down --volumes --remove-orphans`,
package/src/types.ts CHANGED
@@ -35,13 +35,38 @@ export interface ExecResult {
35
35
  exitCode: number;
36
36
  }
37
37
 
38
+ /** Error thrown when a celilo CLI command exits non-zero */
39
+ export class CeliloCommandError extends Error {
40
+ constructor(
41
+ public readonly cmd: string,
42
+ public readonly result: ExecResult,
43
+ ) {
44
+ const tail = result.stdout.slice(-500) + result.stderr.slice(-200);
45
+ super(`celilo ${cmd} failed (exit ${result.exitCode}):\n${tail}`);
46
+ this.name = 'CeliloCommandError';
47
+ }
48
+ }
49
+
38
50
  export interface NetworkHandle {
39
- /** Run a celilo CLI command on the management machine */
51
+ /**
52
+ * Run a celilo CLI command on the management machine.
53
+ * Throws CeliloCommandError on non-zero exit.
54
+ * Pass `{ check: false }` to get the raw ExecResult instead.
55
+ */
40
56
  celilo(cmd: string, timeoutMs?: number): Promise<ExecResult>;
57
+ celilo(cmd: string, opts: { check: false; timeoutMs?: number }): Promise<ExecResult>;
41
58
 
42
59
  /** Execute an arbitrary command in any container */
43
60
  exec(container: string, cmd: string, timeoutMs?: number): Promise<ExecResult>;
44
61
 
62
+ /**
63
+ * Pause the test and drop into an interactive shell for debugging.
64
+ * The test resumes when you exit the shell.
65
+ *
66
+ * @param container - Which container to shell into (default: 'management')
67
+ */
68
+ debug(container?: string): Promise<void>;
69
+
45
70
  /** Resolve a DNS name from the management machine */
46
71
  dig(name: string): Promise<string>;
47
72