Skip to content

Commit

Permalink
getting closer with istio imagetest harness
Browse files Browse the repository at this point in the history
Signed-off-by: Jamon <[email protected]>
  • Loading branch information
jamonation committed Apr 12, 2024
1 parent 2e26e5f commit 4836dbb
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 23 deletions.
2 changes: 1 addition & 1 deletion images/istio/tests/gateway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
variable "values" {
type = any
default = {
revision = "istio"
revision = "istio-system"
service = {
type = "ClusterIP"
}
Expand Down
2 changes: 1 addition & 1 deletion images/istio/tests/install-cni/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ terraform {
variable "values" {
type = any
default = {
revision = "istio"
revision = "istio-system"
cni = {
image = "cgr.dev/chainguard/istio-install-cni"
tag = "latest"
Expand Down
27 changes: 10 additions & 17 deletions images/istio/tests/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,6 @@ data "oci_string" "ref" {
input = each.value
}

data "oci_exec_test" "proxy-version" {
digest = var.digests.proxy
script = "docker run --rm $IMAGE_NAME --version"
}

data "oci_exec_test" "pilot-version" {
digest = var.digests.pilot
script = "docker run --rm $IMAGE_NAME --version"
}

data "oci_exec_test" "operator-version" {
digest = var.digests.operator
script = "docker run --rm $IMAGE_NAME version"
}

data "imagetest_inventory" "this" {}

resource "imagetest_harness_k3s" "this" {
Expand Down Expand Up @@ -88,7 +73,8 @@ module "helm_istiod" {
# will be managed.
revision = local.namespace
pilot = {
image = data.oci_string.ref["pilot"].registry_repo
hub = dirname(data.oci_string.ref["pilot"].registry_repo)
image = basename(data.oci_string.ref["pilot"].registry_repo)
tag = data.oci_string.ref["pilot"].pseudo_tag
}
global = {
Expand Down Expand Up @@ -121,6 +107,7 @@ module "helm_gateway" {
service = {
type = "ClusterIP"
}
# this isn't part of the gateway chart, is it used?
global = {
istioNamespace = local.namespace
# These Helm charts do not like slashes in the image param.
Expand Down Expand Up @@ -155,7 +142,8 @@ module "helm_install-cni" {
tag = data.oci_string.ref["install-cni"].registry_repo
}
cni = {
image = data.oci_string.ref["install-cni"].registry_repo
hub = dirname(data.oci_string.ref["install-cni"].registry_repo)
image = basename(data.oci_string.ref["install-cni"].registry_repo)
tag = data.oci_string.ref["install-cni"].pseudo_tag

# These two settings are highly dependent on the K8s cluster setup.
Expand All @@ -178,6 +166,7 @@ resource "imagetest_feature" "this" {
name = "Create istio-system namespace"
cmd = <<EOF
kubectl create ns ${local.namespace}
kubectl create ns ${local.namespace}-users
EOF
},
{
Expand Down Expand Up @@ -207,6 +196,10 @@ resource "imagetest_feature" "this" {
EOF
retry = { attempts = 5, delay = "10s" }
},
{
name = "Install curl",
cmd = "apk add curl"
},
{
name = "Test injection",
cmd = "/tests/test-injection.sh"
Expand Down
4 changes: 2 additions & 2 deletions images/istio/tests/test-gateway.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ EOF
sed "s/ISTIO_NAMESPACE/$ISTIO_NAMESPACE/g" $SCRIPT_DIR/virtualservice.yaml \
| kubectl apply -f- -n $NAMESPACE

kubectl port-forward -n $ISTIO_NAMESPACE svc/$ISTIO_NAMESPACE-gateway "${FREE_PORT}:80" &
kubectl port-forward -n $ISTIO_NAMESPACE svc/$ISTIO_NAMESPACE-gateway "8080:80" &
pid=$!
trap "kill -9 $pid" EXIT

set +o errexit
for i in {1..10}; do
curl --retry 10 localhost:$FREE_PORT -H "Host: ingress.test.foo" && s=0 && break
curl --retry 10 localhost:8080 -H "Host: ingress.test.foo" && s=0 && break
s=$?
sleep 15
done
Expand Down
4 changes: 2 additions & 2 deletions images/istio/tests/virtualservice.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apiVersion: networking.istio.io/v1alpha3
apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
name: test-gateway
Expand All @@ -11,7 +11,7 @@ spec:
hosts:
- "ingress.test.foo"
---
apiVersion: networking.istio.io/v1alpha3
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: test-virtual-service
Expand Down

0 comments on commit 4836dbb

Please sign in to comment.