From 635cfba844ee88ab3368d524501d46870e3a0ce4 Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson Date: Wed, 7 Aug 2019 16:48:36 +0200 Subject: [PATCH] test: re-enable e2e test for hot reloading Also added an e2e test for hot reloading with a post-sync callback. --- examples/tasks/hello/app.js | 1 + examples/tasks/postgres/garden.yml | 2 +- garden-service/test/e2e/garden.yml | 2 +- garden-service/test/e2e/src/pre-release.ts | 41 ++++++++++++++++++---- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/examples/tasks/hello/app.js b/examples/tasks/hello/app.js index d3604a14d7..cfe2d2cd48 100644 --- a/examples/tasks/hello/app.js +++ b/examples/tasks/hello/app.js @@ -6,6 +6,7 @@ const knex = require("knex")({ port: 5432, database: "postgres", user: "postgres", + password: "postgres", }, pool: { min: 4, diff --git a/examples/tasks/postgres/garden.yml b/examples/tasks/postgres/garden.yml index 7e172c3010..399e3790a7 100644 --- a/examples/tasks/postgres/garden.yml +++ b/examples/tasks/postgres/garden.yml @@ -1,5 +1,5 @@ kind: Module -description: Postgres database for storing voting results +description: Postgres database for storing user names type: helm name: postgres chart: stable/postgresql diff --git a/garden-service/test/e2e/garden.yml b/garden-service/test/e2e/garden.yml index b9a170fdff..db693e3752 100644 --- a/garden-service/test/e2e/garden.yml +++ b/garden-service/test/e2e/garden.yml @@ -31,7 +31,7 @@ tests: - name: tasks # Tests for tasks are currently being skipped command: [npm, run, e2e-full, --, --project=tasks, "--showlog=${var.show-log}", "--env=${environment.name}"] timeout: ${var.timeout} - - name: hot-reload # Tests for hot-reload are currently being skipped + - name: hot-reload command: [npm, run, e2e-full, --, --project=hot-reload, "--showlog=${var.show-log}", "--env=${environment.name}"] timeout: ${var.timeout} # Disabling until https://github.com/garden-io/garden/issues/1045 is fixed diff --git a/garden-service/test/e2e/src/pre-release.ts b/garden-service/test/e2e/src/pre-release.ts index 69f7af2419..31916a85b3 100644 --- a/garden-service/test/e2e/src/pre-release.ts +++ b/garden-service/test/e2e/src/pre-release.ts @@ -7,7 +7,6 @@ import { examplesDir } from "../../helpers" import { changeFileStep, commandReloadedStep, - dashboardUpStep, GardenWatch, runGarden, taskCompletedStep, @@ -138,6 +137,7 @@ describe("PreReleaseTests", () => { * Verify that the output includes the usernames populated by the ruby-migration task. * The users table was created by the node-migration task. */ + await runWithEnv(["deploy"]) const logEntries = await runWithEnv(["call", "hello"]) expect(searchLog(logEntries, /John, Paul, George, Ringo/), "expected to find populated usernames in log output") .to.eql("passed") @@ -152,20 +152,20 @@ describe("PreReleaseTests", () => { * Got error from Kubernetes API - a container name must be specified for pod node-service-85f48587df-lvjlp, * choose one of: [node-service garden-rsync] or one of the init containers: [garden-sync-init] */ - describe.skip("hot-reload", () => { + describe("hot-reload", () => { it("runs the dev command with hot reloading enabled", async () => { const hotReloadProjectPath = resolve(examplesDir, "hot-reload") const gardenWatch = watchWithEnv(["dev", "--hot=node-service"]) const testSteps = [ - dashboardUpStep(), + waitingForChangesStep(), { - description: "change 'Node' -> 'Edge' in node-service/app.js", + description: "change 'Node' -> 'foo' in node-service/app.js", action: async () => { await replace({ files: resolve(hotReloadProjectPath, "node-service/app.js"), from: /Hello from Node/, - to: "Hello from Edge", + to: "Hello from foo", }) }, }, @@ -173,7 +173,35 @@ describe("PreReleaseTests", () => { description: "node-service returns the updated response text", condition: async () => { const callLogEntries = await runWithEnv(["call", "node-service"]) - return searchLog(callLogEntries, /Hello from Edge/) + return searchLog(callLogEntries, /Hello from foo/) + }, + }, + ] + + await gardenWatch.run({ testSteps }) + }) + + it("runs the dev command with hot reloading enabled, using a post-sync command", async () => { + const hotReloadProjectPath = resolve(examplesDir, "hot-reload-post-sync-command") + const gardenWatch = watchWithEnv(["dev", "--hot=node-service"]) + + const testSteps = [ + waitingForChangesStep(), + { + description: "change 'Node' -> 'foo' in node-service/app.js", + action: async () => { + await replace({ + files: resolve(hotReloadProjectPath, "node-service/app.js"), + from: /Hello from Node/, + to: "Hello from foo", + }) + }, + }, + { + description: "node-service returns the updated response text", + condition: async () => { + const callLogEntries = await runWithEnv(["call", "node-service"]) + return searchLog(callLogEntries, /Hello from foo/) }, }, ] @@ -181,6 +209,7 @@ describe("PreReleaseTests", () => { await gardenWatch.run({ testSteps }) }) }) + } if (project === "vote-helm") {