Skip to content

Commit

Permalink
fix integration testing
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <[email protected]>
  • Loading branch information
alexandreLamarre committed Jan 14, 2025
1 parent 50a263a commit 0f88ce6
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 40 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ jobs:
- name : Package helm-project-operator
run : |
BUILD_TARGET=helm-project-operator ./scripts/package
source ./scripts/version
BUILD_TARGET=helm-project-operator source ./scripts/version
k3d image import -c test-cluster $IMAGE
- name : Debug k3d images
run : docker exec k3d-test-cluster-server-0 crictl images
- name : Run e2e tests
run : |
KUBECONFIG=$KUBECONFIG ./scripts/integration
Expand Down
5 changes: 5 additions & 0 deletions internal/helm-locker/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"
"time"

"github.com/google/uuid"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
lockerv1alpha1 "github.com/rancher/prometheus-federator/internal/helm-locker/pkg/apis/helm.cattle.io/v1alpha1"
Expand Down Expand Up @@ -40,6 +41,10 @@ var (
clientCmdCfg clientcmd.ClientConfig
)

var (
operatorName = "helm-locker-" + uuid.New().String()
)

type TestSpec struct {
Kubeconfig string `env:"KUBECONFIG,required"`
}
Expand Down
4 changes: 2 additions & 2 deletions internal/helm-locker/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var _ = Describe("E2E helm locker operator tests", Ordered, Label("kubernetes"),
operator.ControllerOptions{
ClientConfig: clientCmdCfg,
Namespace: ns,
ControllerName: "helmlocker",
ControllerName: operatorName,
NodeName: "node1",
PprofEnabled: false,
},
Expand Down Expand Up @@ -164,7 +164,7 @@ var _ = Describe("E2E helm locker operator tests", Ordered, Label("kubernetes"),
Eventually(Object(release)).Should(
ExistAnd(
HaveAnnotations(
"helmreleases.cattle.io/managed-by", "helmlocker",
"helmreleases.cattle.io/managed-by", operatorName,
),
HaveFinalizers("wrangler.cattle.io/on-helm-release-remove"),
),
Expand Down
2 changes: 1 addition & 1 deletion internal/helm-project-operator/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

func TestE2e(t *testing.T) {
SetDefaultEventuallyTimeout(60 * time.Second)
SetDefaultEventuallyTimeout(30 * time.Second)
SetDefaultEventuallyPollingInterval(50 * time.Millisecond)
SetDefaultConsistentlyDuration(1 * time.Second)
SetDefaultConsistentlyPollingInterval(50 * time.Millisecond)
Expand Down
7 changes: 5 additions & 2 deletions internal/helm-project-operator/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,16 @@ var _ = Describe("E2E helm project operator tests", Ordered, Label("kubernetes")
// }()
ctxT, ca := context.WithTimeout(testCtx, 5*time.Minute)
defer ca()

image := strings.TrimPrefix(ts.image.Repository(), "docker.io/")
helmInstaller := newHelmInstaller(
WithContext(ctxT),
WithCreateNamespace(),
WithNamespace(chartNs),
WithReleaseName("helm-project-operator"),
WithChartRegistry("../../packages/helm-project-operator/charts"),
WithValue("image.repository", ts.image.Repository()),
WithValue("image.registry", "docker.io"),
WithValue("image.repository", image),
WithValue("image.tag", ts.image.Tag()),
WithValue("helmController.enabled", "true"),
)
Expand All @@ -251,7 +254,7 @@ var _ = Describe("E2E helm project operator tests", Ordered, Label("kubernetes")
Eventually(Object(deploy)).Should(ExistAnd(
HaveMatchingContainer(And(
HaveName("helm-project-operator"),
HaveImage(fmt.Sprintf("%s:%s", ts.image.Registry(), ts.image.Tag())),
HaveImage(fmt.Sprintf("%s:%s", ts.image.Repository(), ts.image.Tag())),
)),
))

Expand Down
1 change: 0 additions & 1 deletion package/Dockerfile-helm-project-operator
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
FROM --platform=$BUILDPLATFORM rancher/mirrored-tonistiigi-xx:1.3.0 AS xx

FROM --platform=$BUILDPLATFORM registry.suse.com/bci/golang:1.23 AS builder
FROM registry.suse.com/bci/golang:1.23 AS builder
ARG TARGETARCH
ENV BUILD_TARGET="helm-project-operator"
WORKDIR /usr/src/app
Expand Down
56 changes: 28 additions & 28 deletions pkg/chart/build/example-chart.tgz.base64
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
H4sIFAAAAAAA/ykAK2FIUjBjSE02THk5NWIzVjBkUzVpWlM5Nk9WVjZNV2xqYW5keVRRbz1IZWxt
AOwaXW/btjbP/hUH6UPuBSJVdhz7QvfiDmlSrN3QrkiLAsOwB0o8tthQpEpSdr00/30gKckfkeOk
9Zx19XmIHfLwfPB8kjR+InnBMUgzoszTc/s3nJGcH2wRoiiKBv2++4yiaPUzOj09Pej2hyfD095g
MBgeRN2T4enwAKJtCrEOSm2IOoi+mteqct8IECGkIYZJoeMOQEoM4XIcpsQYjiGTT1NUho0Y0hgU
EWmGqhUtY5SiiOHQqBIPW1GkjoEzUX46njJB5VS3YhWocmZ0cD9shRyJxkCQHGNYcuYOKdh7VJpJ
EcOk1yFFMf83CqMwCihOwm7QS0hCaa9DUaeKFcZhPPek4AXyHN4o+QFTA78UqIiRCjyDNqaTmkUb
h8c2dgssx/+E8BL1thPAhvjvDXqDlfjv97qDffzvAsZcJoRXoW842m8AKS+1QfXyIobDQzdS+BC4
PfKa5KgLkqKO4bffW2feIsfUSBXD9Y1DqKL2zS2aeqYN5hc4IiU3lzhm2qhZM1sqXn1XCUm9pE+e
wLlCYhAun52dg0ItS5WihpFU8BbVhKV4lqayFEYDERRKjUpXS72ubnkMNnF1PB+N6lJy1J7FIhPq
RXMo4HDAZMSAydaliinjHEhpZE4MSwnns4qjW/6MCcrE2InbMJtzfSGnQKVjwjRMpbr6oQXrXYYg
l/hNiUkztwWEc9BlYmXSkMhSUDASkKQZ/FwmqAQa1I1a597uVjJgwmlVGROUt4YrFSBq086FmGao
0K2otsBuh+sn/A5RLLicIfWquHQDCXJplTfyv8BGwAzIRKOaoAZSSz0X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XE6grHSpDJl4H7D/M+jG/8fKbb2Su/0JwLb4Pxmerb7/Dwf7+H8WaC0e
Gsopao4j12e7+ukLtS/aru63I53fzbydw1UzYeclpWCsbh4nNX2suCa29J42cc1wGta8tPJ72MMe
9vAdw38DAAD///QYY1sALAAA
9 changes: 7 additions & 2 deletions scripts/build-chart
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,16 @@ elif [ "$BUILD_TARGET" == "helm-project-operator" ]; then
cp -rf "examples/${BUILD_TARGET}/${CHART}" build/charts/

# Update the chart placeholders
edit-charts "build/charts/${CHART}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
# FIXME: causes a git diff because we add git tagged versions to the helm-chart metadata. I think we can omit this
# from builds since the helm-project-operator is a sub-chart and end-users shouldn't look to
# this metadata for clarifying information since the version of the prometheus-federator version chart is the one
# indicating changes from now on

# edit-charts "build/charts/${CHART}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
package-charts "./build/charts/${CHART}" ./build/charts

# Prepare chart for embedding location
base64 -i "./build/charts/${CHART}-${HELM_CHART_VERSION}.tgz" > "pkg/chart/build/${CHART}.tgz.base64"
base64 -i "./build/charts/${CHART}-0.0.0.tgz" > "pkg/chart/build/${CHART}.tgz.base64"
fi

echo "Completed ${CHART} (ver: ${HELM_CHART_VERSION:-"n/a"}) build process."
13 changes: 11 additions & 2 deletions scripts/integration
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
#!/usr/bin/env bash
set -e

# harcode since we expect to run integration tests against the helm-project-operator image
BUILD_TARGET=helm-project-operator

source $(dirname $0)/version
cd $(dirname $0)/..

echo "Starting integration tests"
# we separate these two test suites since the embedded helm-locker in helm-project-operator can cause a race
# condition that causes the helm-locker tests to fail, because either controller can acquire and harden a helm-release.

echo "Running helm-locker integration tests"
KUBECONFIG=$KUBECONFIG go test -cover ./internal/helm-locker --ginkgo.label-filter='kubernetes'

echo "Running integration tests for $BUILD_TARGET"
KUBECONFIG=$KUBECONFIG IMAGE=$IMAGE go test -cover ./... --ginkgo.label-filter 'kubernetes'
# expects the dev image $IMAGE to be available to the cluster pointed to by $KUBECONFIG
echo "Running helm-project-operator integration tests with image : $IMAGE"
KUBECONFIG=$KUBECONFIG IMAGE=$IMAGE go test -cover ./internal/helm-project-operator --ginkgo.label-filter 'kubernetes'
7 changes: 6 additions & 1 deletion scripts/package-helm
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ fi
clean-old-chart "$BUILD_TARGET"
cp -rf "${DEFAULT_CHART_SOURCE}" "./build/charts/${BUILD_TARGET}"

edit-charts "./build/charts/${BUILD_TARGET}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"
# FIXME: causes a git diff because we add git tagged versions to the helm-chart metadata. I think we can omit this
# from builds since the helm-project-operator is a sub-chart and end-users shouldn't look to
# this metadata for clarifying information since the version of the prometheus-federator version chart is the one
# indicating changes from now on
# edit-charts "./build/charts/${BUILD_TARGET}/Chart.yaml" "${HELM_CHART_VERSION}" "${HELM_IMAGE_TAG}"

package-charts "./build/charts/${BUILD_TARGET}"

0 comments on commit 0f88ce6

Please sign in to comment.