Skip to content

Commit

Permalink
[WIP] importing images for integration CI
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <[email protected]>
  • Loading branch information
alexandreLamarre committed Jan 13, 2025
1 parent 8a4d7e8 commit ccd3fcd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,12 @@ jobs:
- name : Validate build
run : ./scripts/validate-ci
- name : Package helm-project-operator
run : BUILD_TARGET=helm-project-operator ./scripts/package
run : |
BUILD_TARGET=helm-project-operator ./scripts/package
source ./scripts/version
k3d image import -c test-cluster $IMAGE
- name : Run e2e tests
run : |
./scripts/integration
KUBECONFIG=$KUBECONFIG ./scripts/integration
env:
KUBECONFIG: ${{ github.workspace }}/kubeconfig.yaml
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/k3s-io/helm-controller v0.16.6-0.20241210112214-b40937ee695b
github.com/kralicky/kmatch v0.0.0-20240603031752-4aaff7842056
github.com/novln/docker-parser v1.0.0
github.com/onsi/ginkgo/v2 v2.22.2
github.com/onsi/gomega v1.36.2
github.com/rancher/lasso v0.0.0-20241202185148-04649f379358
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/novln/docker-parser v1.0.0 h1:PjEBd9QnKixcWczNGyEdfUrP6GR0YUilAqG7Wksg3uc=
github.com/novln/docker-parser v1.0.0/go.mod h1:oCeM32fsoUwkwByB5wVjsrsVQySzPWkl3JdlTn1txpE=
github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU=
github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk=
github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8=
Expand Down Expand Up @@ -216,6 +218,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
Expand Down
19 changes: 13 additions & 6 deletions internal/helm-project-operator/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

k3shelmv1 "github.com/k3s-io/helm-controller/pkg/apis/helm.cattle.io/v1"
dockerparse "github.com/novln/docker-parser"
. "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 @@ -44,14 +45,18 @@ var (

type TestSpec struct {
Kubeconfig string `env:"KUBECONFIG,required"`
// HpoImage string `env:"IMAGE,required"`
HpoImage string `env:"IMAGE,required"`

image *dockerparse.Reference
}

func (t *TestSpec) Validate() error {
var errs []error
// if _, err := dockerparser.Parse(t.HpoImage); err != nil {
// errs = append(errs, err)
// }
im, err := dockerparse.Parse(t.HpoImage)
if err != nil {
errs = append(errs, err)
}
t.image = im
if _, err := os.Stat(t.Kubeconfig); err != nil {
errs = append(errs, err)
}
Expand All @@ -62,11 +67,13 @@ func (t *TestSpec) Validate() error {
return nil
}

var (
ts = TestSpec{}
)

var _ = BeforeSuite(func() {
ts := TestSpec{}
Expect(env.Parse(&ts)).To(Succeed(), "Could not parse test spec from environment variables")
Expect(ts.Validate()).To(Succeed(), "Invalid input e2e test spec")

ctxCa, ca := context.WithCancel(context.Background())
DeferCleanup(func() {
ca()
Expand Down
9 changes: 4 additions & 5 deletions internal/helm-project-operator/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ func newHelmInstaller(opts ...helmInstallerOption) *helmInstaller {
opt(&h.helmInstallOptions)
}
return h

}

func helmInstallerDefaultOptions() helmInstallOptions {
Expand Down Expand Up @@ -228,9 +227,9 @@ var _ = Describe("E2E helm project operator tests", Ordered, Label("kubernetes")
WithCreateNamespace(),
WithNamespace(chartNs),
WithReleaseName("helm-project-operator"),
WithChartRegistry("./charts/helm-project-operator"),
WithValue("image.repository", "rancher/helm-project-operator"),
WithValue("image.tag", "dev"),
WithChartRegistry("../../packages/helm-project-operator/charts"),
WithValue("image.repository", ts.image.Repository()),
WithValue("image.tag", ts.image.Tag()),
WithValue("helmController.enabled", "true"),
)
cmd, err := helmInstaller.build()
Expand All @@ -252,7 +251,7 @@ var _ = Describe("E2E helm project operator tests", Ordered, Label("kubernetes")
Eventually(Object(deploy)).Should(ExistAnd(
HaveMatchingContainer(And(
HaveName("helm-project-operator"),
HaveImage("rancher/helm-project-operator:dev"),
HaveImage(fmt.Sprintf("%s:%s", ts.image.Registry(), ts.image.Tag())),
)),
))

Expand Down
2 changes: 1 addition & 1 deletion scripts/integration
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ cd $(dirname $0)/..
echo "Starting integration tests"

echo "Running integration tests for $BUILD_TARGET"
KUBECONFIG=$KUBECONFIG go test -cover ./... --ginkgo.label-filter 'kubernetes'
KUBECONFIG=$KUBECONFIG IMAGE=$IMAGE go test -cover ./... --ginkgo.label-filter 'kubernetes'

0 comments on commit ccd3fcd

Please sign in to comment.