From 2f248dd91f6edcdb31dc2b1cbf2aae0e9b9450b8 Mon Sep 17 00:00:00 2001 From: Stephen Kirby Date: Tue, 10 Oct 2023 17:40:43 +0000 Subject: [PATCH] placeholder test for jupyterlab with pip --- code-server/main.test.ts | 15 +++++++++++++++ jupyterlab/main.test.ts | 20 ++++++++++++++------ personalize/main.test.ts | 31 ------------------------------- 3 files changed, 29 insertions(+), 37 deletions(-) create mode 100644 code-server/main.test.ts diff --git a/code-server/main.test.ts b/code-server/main.test.ts new file mode 100644 index 0000000..6afbd5b --- /dev/null +++ b/code-server/main.test.ts @@ -0,0 +1,15 @@ +import { describe, expect, it } from "bun:test"; +import { + executeScriptInContainer, + runTerraformApply, + runTerraformInit, + testRequiredVariables, +} from "../test"; + +describe("code-server", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "foo", + }); +}); diff --git a/jupyterlab/main.test.ts b/jupyterlab/main.test.ts index 15fb487..97e6329 100644 --- a/jupyterlab/main.test.ts +++ b/jupyterlab/main.test.ts @@ -6,9 +6,13 @@ import { testRequiredVariables, findResourceInstance, runContainer, + TerraformState, + execContainer, } from "../test"; -const executeScriptInContainer = async ( + +// executes the coder script after installing pip +const executeScriptInContainerWithPip = async ( state: TerraformState, image: string, shell: string = "sh", @@ -19,6 +23,7 @@ const executeScriptInContainer = async ( }> => { const instance = findResourceInstance(state, "coder_script"); 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 stdout = resp.stdout.trim().split("\n"); const stderr = resp.stderr.trim().split("\n"); @@ -40,9 +45,6 @@ describe("jupyterlab", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "foo", }); - - const instance = findResourceInstance(state, "coder_script"); - const id = await runContainer("alpine"); const output = await executeScriptInContainer(state, "alpine"); expect(output.exitCode).toBe(1); expect(output.stdout).toEqual([ @@ -52,6 +54,12 @@ describe("jupyterlab", async () => { ]); }); - // TODO: Add test that runs with pip - // May be best to use dockerfile + // TODO: Add faster test to run with pip3. + // currently times out. + // it("runs with pip3", async () => { + // ... + // const output = await executeScriptInContainerWithPip(state, "alpine"); + // ... + // }); + }); diff --git a/personalize/main.test.ts b/personalize/main.test.ts index 96b1e2e..cb31a9b 100644 --- a/personalize/main.test.ts +++ b/personalize/main.test.ts @@ -31,35 +31,4 @@ describe("personalize", async () => { ]); }); - // it("runs with personalize script", async () => { - // const state = await runTerraformApply(import.meta.dir, { - // agent_id: "foo", - // }); - // const instance = findResourceInstance(state, "coder_script"); - // const id = await runContainer("alpine"); - // const respInit = await execContainer(id, [ - // "sh", - // "-c", - // 'touch ~/personalize && echo "echo test" > ~/personalize && chmod +x ~/personalize && echo "completed touch cmds"', - // ]); - - // console.log("\n id = ", id, "\n"); - - // console.log("\n====== init ==== stdout (", respInit.exitCode, "):"); - // console.log(respInit.stdout); - // console.log("====== init ==== stderr:"); - // console.log(respInit.stderr); - // console.log("======"); - // const resp = await execContainer(id, ["sh", "-c", instance.script]); - // console.log("====== resp ==== stdout (", resp.exitCode, "):"); - // console.log(resp.stdout); - // console.log("====== resp ==== stderr:"); - // console.log(resp.stderr); - // console.log("======"); - // // await new Promise((resolve) => setTimeout(resolve, 100000000000)); - // const stdout = resp.stdout.trim().split("\n"); - // const stderr = resp.stderr.trim().split("\n"); - // expect(resp.exitCode).toBe(0); - // expect(stdout).toEqual([""]); - // }); });