Skip to content

Commit

Permalink
fix: debug tests WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Aug 17, 2021
1 parent 9b39a40 commit fc066c0
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ jobs:
# - Need to run with sudo to work with microk8s, because CircleCI doesn't allow us to log out
# and back in to add the circleci user to the microk8s group.
# - We currently don't support in-cluster building on microk8s.
sudo -E npm run integ-microk8s
sudo -E GARDEN_SKIP_TESTS="cluster-docker kaniko remote-only" npm run _integ
- run:
name: Plugin tests
command: sudo -E npm run test:plugins
Expand Down
1 change: 0 additions & 1 deletion core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@
"fix-format": "prettier --write \"{src,test}/**/*.ts\"",
"lint": "tslint -p .",
"migration:generate": "typeorm migration:generate --config ormconfig.js -n",
"integ-microk8s": "GARDEN_SKIP_TESTS=\"cluster-docker kaniko remote-only\" yarn run _integ",
"integ-kind": "GARDEN_INTEG_TEST_MODE=local GARDEN_SKIP_TESTS=\"cluster-docker cluster-buildkit cluster-buildkit-rootless kaniko remote-only\" yarn run _integ",
"integ-local": "GARDEN_LOGGER_TYPE=basic GARDEN_LOG_LEVEL=debug GARDEN_INTEG_TEST_MODE=local GARDEN_SKIP_TESTS=\"cluster-docker\" yarn run _integ",
"integ-minikube": "GARDEN_INTEG_TEST_MODE=local GARDEN_SKIP_TESTS=remote-only yarn run _integ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,9 @@ async function runRegistryGarbageCollection(ctx: KubernetesPluginContext, api: K
},
{
retries: 3,
onFailedAttempt: async () => {
log.warn("Failed to patch deployment, retrying in 5 seconds...")
await sleep(5)
minTimeout: 2000,
onFailedAttempt: async (err) => {
log.warn(`Failed to patch deployment. ${err.retriesLeft} attempts left.`)
},
}
)
Expand Down
12 changes: 11 additions & 1 deletion core/src/plugins/kubernetes/mutagen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { registerCleanupFunction, sleep } from "../../util/util"
import { GardenBaseError } from "../../exceptions"
import { prepareConnectionOpts } from "./kubectl"
import { KubernetesPluginContext } from "./config"
import pRetry from "p-retry"

const maxRestarts = 10
const monitorDelay = 2000
Expand Down Expand Up @@ -427,7 +428,16 @@ export async function ensureMutagenSync({
params.push("--default-directory-mode", modeToString(defaultDirectoryMode))
}

await execMutagenCommand(log, ["sync", "create", ...params])
// Might need to retry
await pRetry(() => execMutagenCommand(log, ["sync", "create", ...params]), {
retries: 5,
minTimeout: 1000,
onFailedAttempt: (err) => {
log.warn(
`Failed to start sync from ${sourceDescription} to ${targetDescription}. ${err.retriesLeft} attempts left.`
)
},
})

activeSyncs[key] = {
sourceDescription,
Expand Down
12 changes: 6 additions & 6 deletions core/test/integ/src/plugins/kubernetes/commands/pull-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ describe("pull-image plugin command", () => {
expect(imageHash.stdout.trim()).to.equal("ok")
}

grouped("cluster-docker", "remote-only").context("using an external cluster registry", () => {
grouped("kaniko", "remote-only").context("using an external cluster registry with kaniko", () => {
let module: GardenModule

before(async () => {
await init("cluster-docker-remote-registry")
await init("kaniko-remote-registry")

module = graph.getModule("remote-registry-test")

Expand All @@ -88,11 +88,11 @@ describe("pull-image plugin command", () => {
})
})

grouped("cluster-docker").context("using the in cluster registry", () => {
grouped("kaniko").context("using the in cluster registry with kaniko", () => {
let module: GardenModule

before(async () => {
await init("cluster-docker")
await init("kaniko")

module = graph.getModule("simple-service")

Expand All @@ -113,7 +113,7 @@ describe("pull-image plugin command", () => {
})
})

grouped("cluster-buildkit", "remote-only").context("using an external cluster registry", () => {
grouped("cluster-buildkit", "remote-only").context("using an external cluster registry with buildkit", () => {
let module: GardenModule

before(async () => {
Expand All @@ -138,7 +138,7 @@ describe("pull-image plugin command", () => {
})
})

grouped("cluster-buildkit").context("using the in cluster registry", () => {
grouped("cluster-buildkit").context("using the in cluster registry with buildkit", () => {
let module: GardenModule

before(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ describe("kubernetes build flow", () => {
module,
}),
(err) => {
console.log(err)
expect(err.message).to.include("pull access denied")
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { clusterInit } from "../../../../../../src/plugins/kubernetes/commands/c
import { testFromConfig, testFromModule } from "../../../../../../src/types/test"

const root = getDataDir("test-projects", "container")
const defaultEnvironment = process.env.GARDEN_INTEG_TEST_MODE === "remote" ? "cluster-docker" : "local"
const defaultEnvironment = process.env.GARDEN_INTEG_TEST_MODE === "remote" ? "kaniko" : "local"
const initializedEnvs: string[] = []
let localInstance: Garden

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,15 +247,15 @@ describe("kubernetes-module handlers", () => {
readFromSrcDir: true,
})

// // Deploy without dev mode
// Deploy without dev mode
await deployKubernetesService(deployParams)
const res1 = await findDeployedResources(manifests, log)

// Deploy with dev mode
await deployKubernetesService({ ...deployParams, devMode: true })
const res2 = await findDeployedResources(manifests, log)

// // Deploy without hot reload again
// Deploy without dev mode again
await deployKubernetesService(deployParams)
const res3 = await findDeployedResources(manifests, log)

Expand Down

0 comments on commit fc066c0

Please sign in to comment.