diff --git a/images/haproxy/main.tf b/images/haproxy/main.tf index c94caec8df..c4245f7808 100644 --- a/images/haproxy/main.tf +++ b/images/haproxy/main.tf @@ -21,8 +21,9 @@ module "latest" { } module "test-latest" { - source = "./tests" - digest = module.latest.image_ref + source = "./tests" + digest = module.latest.image_ref + target_repository = var.target_repository } resource "oci_tag" "latest" { diff --git a/images/haproxy/tests/main.tf b/images/haproxy/tests/main.tf index 96fcc25d5f..3fab647d45 100644 --- a/images/haproxy/tests/main.tf +++ b/images/haproxy/tests/main.tf @@ -1,43 +1,75 @@ terraform { required_providers { - oci = { source = "chainguard-dev/oci" } + oci = { source = "chainguard-dev/oci" } + imagetest = { source = "chainguard-dev/imagetest" } } } +variable "target_repository" {} + variable "digest" { description = "The image digest to run tests over." } locals { parsed = provider::oci::parse(var.digest) } -resource "random_pet" "suffix" {} +data "imagetest_inventory" "this" {} + +module "cluster_harness" { + source = "../../../tflib/imagetest/harnesses/k3s/" + + inventory = data.imagetest_inventory.this + name = basename(path.module) + target_repository = var.target_repository + cwd = path.module +} + +module "helm" { + source = "../../../tflib/imagetest/helm" -resource "helm_release" "redis-ha" { - name = "haproxy-redis-${random_pet.suffix.id}" - namespace = "haproxy-system-${random_pet.suffix.id}" - repository = "https://dandydeveloper.github.io/charts" - chart = "redis-ha" - create_namespace = true - timeout = 300 + name = "haproxy-redis" + namespace = "haproxy-system" + repo = "https://dandydeveloper.github.io/charts" + chart = "redis-ha" - values = [ - jsonencode({ + values = { + image = { + registry = "cgr.dev/chainguard/redis" + tag = "latest" + } + hardAntiAffinity = false + haproxy = { + enabled = true + hardAntiAffinity = false image = { - registry = "cgr.dev/chainguard/redis" - tag = "latest" + repository = local.parsed.registry_repo + tag = local.parsed.pseudo_tag } - hardAntiAffinity = false - haproxy = { - enabled = true - hardAntiAffinity = false - image = { - repository = local.parsed.registry_repo - tag = local.parsed.pseudo_tag - } - containerSecurityContext = { - capabilities = { add = ["NET_BIND_SERVICE"] } - } + containerSecurityContext = { + capabilities = { add = ["NET_BIND_SERVICE"] } } - }) + } + } +} + +resource "imagetest_feature" "basic" { + name = "basic" + description = "Basic installation test" + harness = module.cluster_harness.harness + + steps = [ + { + name = "Install with helm" + cmd = module.helm.install_cmd + }, ] + + labels = { + type = "k8s" + } + + timeouts = { + # The redis-ha rollout is painfully slow and prone to fruitless polling + create = "15m" + } }