Skip to content

Commit

Permalink
automated commit
Browse files Browse the repository at this point in the history
Signed-off-by: Public copy <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] committed Oct 29, 2024
1 parent 44ba270 commit ea17b47
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 33 deletions.
1 change: 1 addition & 0 deletions images/cert-manager/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ locals {
]...)
components = toset(["acmesolver", "controller", "cainjector", "webhook"])
versions = { for k, v in module.versions.versions : k => {
eol = v.eol
is_latest = v.is_latest
suffix = replace(k, "cert-manager", "")
} }
Expand Down
1 change: 1 addition & 0 deletions images/kubernetes-csi-external-snapshotter/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ locals {
for k in local.components : k => "${local.mangled_repository}-${k}"
}
versions = { for k, v in module.versions.versions : k => {
eol = v.eol
is_latest = v.is_latest
suffix = replace(k, "kubernetes-csi-external-snapshotter", "")
} }
Expand Down
1 change: 0 additions & 1 deletion images/node/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ module "versioned" {
module "next" {
build-dev = true
config = module.config-next.config
eol = each.value.eol
extra_dev_packages = [
"yarn",
"build-base",
Expand Down
13 changes: 10 additions & 3 deletions images/postgres/config/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@ terraform {
variable "extra_packages" {
description = "The additional packages to install (e.g. postgresql-15)."
}
variable "run-as" {
description = "Passes values for run-as"
}

variable "id" {
description = "Passes values for uid and gid"
}

module "accts" {
source = "../../../tflib/accts"
run-as = 0
uid = 70
gid = 70
run-as = var.run-as
uid = var.id
gid = var.id
name = "postgres"
}

Expand Down
10 changes: 0 additions & 10 deletions images/postgres/tests/locale.sh

This file was deleted.

60 changes: 45 additions & 15 deletions images/postgres/tests/main.tf
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
terraform {
required_providers {
oci = { source = "chainguard-dev/oci" }
imagetest = { source = "chainguard-dev/imagetest" }
}
}

variable "digest" {
description = "The image digest to run tests over."
}

locals { parsed = provider::oci::parse(var.digest) }
data "imagetest_inventory" "this" {}

data "oci_exec_test" "query" {
digest = var.digest
script = "${path.module}/query.sh"
resource "imagetest_container_volume" "this" {
name = "postgresql"
inventory = data.imagetest_inventory.this
}

data "oci_exec_test" "locale" {
# Avoid name/port collision
depends_on = [data.oci_exec_test.query]
resource "imagetest_harness_docker" "this" {
name = "postgresql-test"
inventory = data.imagetest_inventory.this

digest = var.digest
script = "${path.module}/locale.sh"
}
privileged = false

data "oci_exec_test" "tls" {
digest = var.digest
script = "./tls.sh"
working_dir = path.module
envs = {
IMAGE_NAME = var.digest
VOLUME_ID = imagetest_container_volume.this.id
POSTGRES_PASSWORD = "password"
}
mounts = [
{
source = path.module
destination = "/tests"
}
]
volumes = [
{
source = imagetest_container_volume.this
destination = "/data"
}
]
}

resource "imagetest_feature" "postgres" {
name = "psql"
description = "Test Postgresql functionalities"
harness = imagetest_harness_docker.this

steps = [
{
name = "Database setup"
cmd = "/tests/query.sh"
},
{
name = "TLS enabled Postgres"
cmd = "/tests/tls.sh"
}
]

labels = { type = "container" }
}
6 changes: 4 additions & 2 deletions images/postgres/tests/query.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env bash

set -o errexit -o nounset -o errtrace -o pipefail -x

CONTAINER_NAME=${CONTAINER_NAME:-"postgres-${FREE_PORT}"}
CONTAINER_NAME=${CONTAINER_NAME:-"postgres-${RANDOM}"}

docker run -e POSTGRES_PASSWORD=password -d --name $CONTAINER_NAME $IMAGE_NAME
sleep 10
Expand Down Expand Up @@ -40,3 +39,6 @@ docker exec $CONTAINER_NAME /usr/bin/psql -U postgres -h 127.0.0.1 -c "GRANT ALL
# Drop the test database and user
docker exec $CONTAINER_NAME /usr/bin/psql -U postgres -h 127.0.0.1 -c "DROP DATABASE testdb;"
docker exec $CONTAINER_NAME /usr/bin/psql -U postgres -h 127.0.0.1 -c "DROP USER testuser;"

docker exec $CONTAINER_NAME /usr/bin/psql -U postgres -t -c "show server_encoding;" | head -n 1 | grep UTF8

4 changes: 2 additions & 2 deletions images/postgres/tests/tls.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env bash

apk add openssl-config
set -o errexit -o nounset -o errtrace -o pipefail -x

server_name="postgres_server-${RANDOM}"
client_name="postgres_client-${RANDOM}"
network_name="postgres_network-${RANDOM}"
certs_dir="certs-${RANDOM}"
certs_dir="/tmp/certs-${RANDOM}"
postgres_password="secret"

# Function to clean up resources in case of an error
Expand Down

0 comments on commit ea17b47

Please sign in to comment.