Skip to content

Commit

Permalink
test: re-enable e2e test for hot reloading
Browse files Browse the repository at this point in the history
Also added an e2e test for hot reloading with a post-sync callback.
  • Loading branch information
thsig committed Sep 25, 2019
1 parent 011a16a commit 635cfba
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/tasks/hello/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const knex = require("knex")({
port: 5432,
database: "postgres",
user: "postgres",
password: "postgres",
},
pool: {
min: 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/tasks/postgres/garden.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion garden-service/test/e2e/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
41 changes: 35 additions & 6 deletions garden-service/test/e2e/src/pre-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { examplesDir } from "../../helpers"
import {
changeFileStep,
commandReloadedStep,
dashboardUpStep,
GardenWatch,
runGarden,
taskCompletedStep,
Expand Down Expand Up @@ -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")
Expand All @@ -152,35 +152,64 @@ 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",
})
},
},
{
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/)
},
},
]

await gardenWatch.run({ testSteps })
})
})

}

if (project === "vote-helm") {
Expand Down

0 comments on commit 635cfba

Please sign in to comment.