test(integration): properly waited for the image pulls to complete (#2842)
This commit is contained in:
		
							parent
							
								
									39d2a05014
								
							
						
					
					
						commit
						e39ae90ae2
					
				@ -1,5 +1,4 @@
 | 
				
			|||||||
import Docker from "dockerode";
 | 
					import Docker from "dockerode";
 | 
				
			||||||
import getStream from "get-stream";
 | 
					 | 
				
			||||||
import pRetry from "p-retry";
 | 
					import pRetry from "p-retry";
 | 
				
			||||||
import { gitShallowClone, initBareRepo } from "./git-utils.js";
 | 
					import { gitShallowClone, initBareRepo } from "./git-utils.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -15,11 +14,20 @@ let container;
 | 
				
			|||||||
export const gitCredential = `${GIT_USERNAME}:${GIT_PASSWORD}`;
 | 
					export const gitCredential = `${GIT_USERNAME}:${GIT_PASSWORD}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Download the `gitbox` Docker image, create a new container and start it.
 | 
					 * Download the `gitbox` Docker image
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export function pull() {
 | 
				
			||||||
 | 
					  return docker.pull(IMAGE).then((stream) => {
 | 
				
			||||||
 | 
					    return new Promise((resolve, reject) => {
 | 
				
			||||||
 | 
					      docker.modem.followProgress(stream, (err, res) => (err ? reject(err) : resolve(res)));
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * create a new container and start it.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export async function start() {
 | 
					export async function start() {
 | 
				
			||||||
  await getStream(await docker.pull(IMAGE));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  container = await docker.createContainer({
 | 
					  container = await docker.createContainer({
 | 
				
			||||||
    Tty: true,
 | 
					    Tty: true,
 | 
				
			||||||
    Image: IMAGE,
 | 
					    Image: IMAGE,
 | 
				
			||||||
 | 
				
			|||||||
@ -1,5 +1,4 @@
 | 
				
			|||||||
import Docker from "dockerode";
 | 
					import Docker from "dockerode";
 | 
				
			||||||
import getStream from "get-stream";
 | 
					 | 
				
			||||||
import got from "got";
 | 
					import got from "got";
 | 
				
			||||||
import pRetry from "p-retry";
 | 
					import pRetry from "p-retry";
 | 
				
			||||||
import { mockServerClient } from "mockserver-client";
 | 
					import { mockServerClient } from "mockserver-client";
 | 
				
			||||||
@ -11,11 +10,20 @@ const docker = new Docker();
 | 
				
			|||||||
let container;
 | 
					let container;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Download the `mockserver` Docker image, create a new container and start it.
 | 
					 * Download the `mockserver` Docker image,
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export function pull() {
 | 
				
			||||||
 | 
					  return docker.pull(IMAGE).then((stream) => {
 | 
				
			||||||
 | 
					    return new Promise((resolve, reject) => {
 | 
				
			||||||
 | 
					      docker.modem.followProgress(stream, (err, res) => (err ? reject(err) : resolve(res)));
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * create a new container and start it.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export async function start() {
 | 
					export async function start() {
 | 
				
			||||||
  await getStream(await docker.pull(IMAGE));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  container = await docker.createContainer({
 | 
					  container = await docker.createContainer({
 | 
				
			||||||
    Tty: true,
 | 
					    Tty: true,
 | 
				
			||||||
    Image: IMAGE,
 | 
					    Image: IMAGE,
 | 
				
			||||||
 | 
				
			|||||||
@ -2,7 +2,6 @@ import path, { dirname } from "node:path";
 | 
				
			|||||||
import { fileURLToPath } from "node:url";
 | 
					import { fileURLToPath } from "node:url";
 | 
				
			||||||
import { setTimeout } from "node:timers/promises";
 | 
					import { setTimeout } from "node:timers/promises";
 | 
				
			||||||
import Docker from "dockerode";
 | 
					import Docker from "dockerode";
 | 
				
			||||||
import getStream from "get-stream";
 | 
					 | 
				
			||||||
import got from "got";
 | 
					import got from "got";
 | 
				
			||||||
import pRetry from "p-retry";
 | 
					import pRetry from "p-retry";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -17,11 +16,20 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
 | 
				
			|||||||
let container, npmToken;
 | 
					let container, npmToken;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Download the `npm-registry-docker` Docker image, create a new container and start it.
 | 
					 * Download the `npm-registry-docker` Docker image
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					export function pull() {
 | 
				
			||||||
 | 
					  return docker.pull(IMAGE).then((stream) => {
 | 
				
			||||||
 | 
					    return new Promise((resolve, reject) => {
 | 
				
			||||||
 | 
					      docker.modem.followProgress(stream, (err, res) => (err ? reject(err) : resolve(res)));
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * create a new container and start it.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export async function start() {
 | 
					export async function start() {
 | 
				
			||||||
  await getStream(await docker.pull(IMAGE));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  container = await docker.createContainer({
 | 
					  container = await docker.createContainer({
 | 
				
			||||||
    Tty: true,
 | 
					    Tty: true,
 | 
				
			||||||
    Image: IMAGE,
 | 
					    Image: IMAGE,
 | 
				
			||||||
 | 
				
			|||||||
@ -47,6 +47,7 @@ const pluginLogEnv = path.resolve("./test/fixtures/plugin-log-env");
 | 
				
			|||||||
const pluginEsmNamedExports = path.resolve("./test/fixtures/plugin-esm-named-exports");
 | 
					const pluginEsmNamedExports = path.resolve("./test/fixtures/plugin-esm-named-exports");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
test.before(async () => {
 | 
					test.before(async () => {
 | 
				
			||||||
 | 
					  await Promise.all([gitbox.pull(), npmRegistry.pull(), mockServer.pull()]);
 | 
				
			||||||
  await Promise.all([gitbox.start(), npmRegistry.start(), mockServer.start()]);
 | 
					  await Promise.all([gitbox.start(), npmRegistry.start(), mockServer.start()]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  env = {
 | 
					  env = {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user