Skip to content

Commit

Permalink
pass the registration and work images to e2e
Browse files Browse the repository at this point in the history
Signed-off-by: zhujian <[email protected]>
  • Loading branch information
zhujian7 committed Nov 15, 2023
1 parent 39a9930 commit 4300604
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
path: go/src/open-cluster-management.io/registration-operator
- name: add permisson to docker.sock
run: sudo chown runner:docker /var/run/docker.sock
if: ${{ env.ACT }}
if: ${{ env.ACT }} # this step only runs locally when using the https://github.com/nektos/act to debug the e2e
- name: install Go
uses: actions/setup-go@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ test-e2e: deploy-hub deploy-spoke-operator run-e2e

run-e2e: cluster-ip bootstrap-secret
go test -c ./test/e2e
./e2e.test -test.v -ginkgo.v
./e2e.test -test.v -ginkgo.vv -registration-image=$(REGISTRATION_IMAGE) -work-image=$(WORK_IMAGE)

clean-e2e:
$(RM) ./e2e.test
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/addon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ var _ = Describe("Manage the managed cluster addons", func() {
It("Create one managed cluster addon and make sure it is available", func() {
var err error
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeDefault)
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeDefault,
registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName))
Expand Down Expand Up @@ -68,7 +69,8 @@ var _ = Describe("Manage the managed cluster addons", func() {
It("Create one managed cluster addon and make sure it is available in Hosted mode", func() {
var err error
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeHosted)
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeHosted,
registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName))
Expand Down
14 changes: 8 additions & 6 deletions test/e2e/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ func (t *Tester) SetBootstrapHubSecret(bootstrapHubSecret string) error {
return nil
}

func (t *Tester) CreateKlusterlet(name, clusterName, klusterletNamespace string, mode operatorapiv1.InstallMode) (*operatorapiv1.Klusterlet, error) {
func (t *Tester) CreateKlusterlet(name, clusterName, klusterletNamespace string, mode operatorapiv1.InstallMode,
registrationImage, workImage string) (*operatorapiv1.Klusterlet, error) {
if name == "" {
return nil, fmt.Errorf("the name should not be null")
}
Expand All @@ -165,8 +166,8 @@ func (t *Tester) CreateKlusterlet(name, clusterName, klusterletNamespace string,
Name: name,
},
Spec: operatorapiv1.KlusterletSpec{
RegistrationImagePullSpec: "quay.io/open-cluster-management/registration:latest",
WorkImagePullSpec: "quay.io/open-cluster-management/work:latest",
RegistrationImagePullSpec: registrationImage,
WorkImagePullSpec: workImage,
ExternalServerURLs: []operatorapiv1.ServerURL{
{
URL: "https://localhost",
Expand Down Expand Up @@ -245,7 +246,8 @@ func (t *Tester) CreateKlusterlet(name, clusterName, klusterletNamespace string,
return realKlusterlet, nil
}

func (t *Tester) CreatePureHostedKlusterlet(name, clusterName string) (*operatorapiv1.Klusterlet, error) {
func (t *Tester) CreatePureHostedKlusterlet(name, clusterName,
registrationImage, workImage string) (*operatorapiv1.Klusterlet, error) {
if name == "" {
return nil, fmt.Errorf("the name should not be null")
}
Expand All @@ -255,8 +257,8 @@ func (t *Tester) CreatePureHostedKlusterlet(name, clusterName string) (*operator
Name: name,
},
Spec: operatorapiv1.KlusterletSpec{
RegistrationImagePullSpec: "quay.io/open-cluster-management/registration:latest",
WorkImagePullSpec: "quay.io/open-cluster-management/work:latest",
RegistrationImagePullSpec: registrationImage,
WorkImagePullSpec: workImage,
ExternalServerURLs: []operatorapiv1.ServerURL{
{
URL: "https://localhost",
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package e2e

import (
"flag"
"testing"

. "github.com/onsi/ginkgo/v2"
Expand All @@ -9,6 +10,16 @@ import (

var t *Tester

var (
registrationImage string
workImage string
)

func init() {
flag.StringVar(&registrationImage, "registration-image", "quay.io/open-cluster-management/registration:latest", "The image of the registration")
flag.StringVar(&workImage, "work-image", "quay.io/open-cluster-management/work:latest", "The image of the work")
}

func TestE2E(tt *testing.T) {
t = NewTester("")

Expand Down
13 changes: 8 additions & 5 deletions test/e2e/klusterlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var _ = Describe("Create klusterlet CR", func() {
It("Create klusterlet CR with install mode empty", func() {
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))
// Set install mode empty
_, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, "")
_, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, "", registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName))
Expand Down Expand Up @@ -72,7 +72,8 @@ var _ = Describe("Create klusterlet CR", func() {

It("Create klusterlet CR with managed cluster name", func() {
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))
_, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeDefault)
_, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeDefault,
registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName))
Expand Down Expand Up @@ -114,7 +115,8 @@ var _ = Describe("Create klusterlet CR", func() {
klusterletNamespace = ""
var err error
By(fmt.Sprintf("create klusterlet %v without managed cluster name", klusterletName))
_, err = t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeDefault)
_, err = t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeDefault,
registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By("waiting for the managed cluster to be created")
Expand Down Expand Up @@ -153,7 +155,8 @@ var _ = Describe("Create klusterlet CR", func() {

It("Create klusterlet CR in Hosted mode", func() {
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))
_, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeHosted)
_, err := t.CreateKlusterlet(klusterletName, clusterName, klusterletNamespace, operatorapiv1.InstallModeHosted,
registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName))
Expand Down Expand Up @@ -202,7 +205,7 @@ var _ = Describe("Delete klusterlet CR", func() {

It("Delete klusterlet CR in Hosted mode without external managed kubeconfig", func() {
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v in Hosted mode", klusterletName, clusterName))
_, err := t.CreatePureHostedKlusterlet(klusterletName, clusterName)
_, err := t.CreatePureHostedKlusterlet(klusterletName, clusterName, registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("check klusterlet %s status", klusterletName))
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/work_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ var _ = Describe("Create klusterlet and then create a configmap by manifestwork"
It("Create configmap using manifestwork and then delete klusterlet", func() {
var err error
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeDefault)
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeDefault,
registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName))
Expand Down Expand Up @@ -81,7 +82,8 @@ var _ = Describe("Create klusterlet and then create a configmap by manifestwork"
It("Create configmap using manifestwork and then delete klusterlet in Hosted mode", func() {
var err error
By(fmt.Sprintf("create klusterlet %v with managed cluster name %v", klusterletName, clusterName))
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeHosted)
_, err = t.CreateKlusterlet(klusterletName, clusterName, agentNamespace, operatorapiv1.InstallModeHosted,
registrationImage, workImage)
Expect(err).ToNot(HaveOccurred())

By(fmt.Sprintf("waiting for the managed cluster %v to be created", clusterName))
Expand Down

0 comments on commit 4300604

Please sign in to comment.