|
|
@ -6,9 +6,13 @@ import {
|
|
|
|
testRequiredVariables,
|
|
|
|
testRequiredVariables,
|
|
|
|
findResourceInstance,
|
|
|
|
findResourceInstance,
|
|
|
|
runContainer,
|
|
|
|
runContainer,
|
|
|
|
|
|
|
|
TerraformState,
|
|
|
|
|
|
|
|
execContainer,
|
|
|
|
} from "../test";
|
|
|
|
} from "../test";
|
|
|
|
|
|
|
|
|
|
|
|
const executeScriptInContainer = async (
|
|
|
|
|
|
|
|
|
|
|
|
// executes the coder script after installing pip
|
|
|
|
|
|
|
|
const executeScriptInContainerWithPip = async (
|
|
|
|
state: TerraformState,
|
|
|
|
state: TerraformState,
|
|
|
|
image: string,
|
|
|
|
image: string,
|
|
|
|
shell: string = "sh",
|
|
|
|
shell: string = "sh",
|
|
|
@ -19,6 +23,7 @@ const executeScriptInContainer = async (
|
|
|
|
}> => {
|
|
|
|
}> => {
|
|
|
|
const instance = findResourceInstance(state, "coder_script");
|
|
|
|
const instance = findResourceInstance(state, "coder_script");
|
|
|
|
const id = await runContainer(image);
|
|
|
|
const id = await runContainer(image);
|
|
|
|
|
|
|
|
const respPip = await execContainer(id, [shell, "-c", "apk add py3-pip"]);
|
|
|
|
const resp = await execContainer(id, [shell, "-c", instance.script]);
|
|
|
|
const resp = await execContainer(id, [shell, "-c", instance.script]);
|
|
|
|
const stdout = resp.stdout.trim().split("\n");
|
|
|
|
const stdout = resp.stdout.trim().split("\n");
|
|
|
|
const stderr = resp.stderr.trim().split("\n");
|
|
|
|
const stderr = resp.stderr.trim().split("\n");
|
|
|
@ -40,9 +45,6 @@ describe("jupyterlab", async () => {
|
|
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
|
|
const state = await runTerraformApply(import.meta.dir, {
|
|
|
|
agent_id: "foo",
|
|
|
|
agent_id: "foo",
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const instance = findResourceInstance(state, "coder_script");
|
|
|
|
|
|
|
|
const id = await runContainer("alpine");
|
|
|
|
|
|
|
|
const output = await executeScriptInContainer(state, "alpine");
|
|
|
|
const output = await executeScriptInContainer(state, "alpine");
|
|
|
|
expect(output.exitCode).toBe(1);
|
|
|
|
expect(output.exitCode).toBe(1);
|
|
|
|
expect(output.stdout).toEqual([
|
|
|
|
expect(output.stdout).toEqual([
|
|
|
@ -52,6 +54,12 @@ describe("jupyterlab", async () => {
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Add test that runs with pip
|
|
|
|
// TODO: Add faster test to run with pip3.
|
|
|
|
// May be best to use dockerfile
|
|
|
|
// currently times out.
|
|
|
|
|
|
|
|
// it("runs with pip3", async () => {
|
|
|
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
// const output = await executeScriptInContainerWithPip(state, "alpine");
|
|
|
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|