chore: Add mockserver for e2e testing (#19104)

This commit is contained in:
Mutasem Aldmour
2025-09-04 10:36:15 +02:00
committed by GitHub
parent e822cf58d0
commit ce820fc98c
12 changed files with 1027 additions and 410 deletions

View File

@@ -316,6 +316,40 @@ export async function pollContainerHttpEndpoint(
);
}
export async function setupProxyServer({
proxyServerImage,
projectName,
network,
hostname,
port,
}: {
proxyServerImage: string;
projectName: string;
network: StartedNetwork;
hostname: string;
port: number;
}): Promise<StartedTestContainer> {
const { consumer, throwWithLogs } = createSilentLogConsumer();
try {
return await new GenericContainer(proxyServerImage)
.withNetwork(network)
.withNetworkAliases(hostname)
.withExposedPorts(port)
// Wait.forListeningPorts strategy did not work here for some reason
.withWaitStrategy(Wait.forLogMessage(`INFO ${port} started on port: ${port}`))
.withLabels({
'com.docker.compose.project': projectName,
'com.docker.compose.service': 'proxyserver',
})
.withName(`${projectName}-proxyserver`)
.withReuse()
.withLogConsumer(consumer)
.start();
} catch (error) {
return throwWithLogs(error);
}
}
// TODO: Look at Ollama container?
// TODO: Look at MariaDB container?
// TODO: Look at MockServer container, could we use this for mocking out external services?