Skip to content

Commit

Permalink
Add plan crd
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Mazzotti <andrea.mazzotti@suse.com>
  • Loading branch information
anmazzotti committed Sep 25, 2024
1 parent b8b14a4 commit bfb4123
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
13 changes: 13 additions & 0 deletions tests/e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type E2EConfig struct {

SystemUpgradeControllerVersion string `yaml:"systemUpgradeControllerVersion"`
SystemUpgradeControllerURL string `yaml:"systemUpgradeControllerURL"`
SystemUpgradeControllerCRDsURL string `yaml:"systemUpgradeControllerCRDsURL"`
}

// ReadE2EConfig read config from yaml and substitute variables using envsubst.
Expand Down Expand Up @@ -139,6 +140,10 @@ func ReadE2EConfig(configPath string) (*E2EConfig, error) { //nolint:gocyclo
config.SystemUpgradeControllerVersion = sysUpgradeControllerURL
}

if sysUpgradeControllerCRDsURL := os.Getenv("SYSTEM_UPGRADE_CONTROLLER_CRDS_URL"); sysUpgradeControllerCRDsURL != "" {
config.SystemUpgradeControllerCRDsURL = sysUpgradeControllerCRDsURL
}

if err := substituteVersions(config); err != nil {
return nil, err
}
Expand Down Expand Up @@ -179,5 +184,13 @@ func substituteVersions(config *E2EConfig) error {
}
config.SystemUpgradeControllerURL = sysUpgradeControllerURL

sysUpgradeControllerCRDsURL, err := envsubst.Eval(config.SystemUpgradeControllerCRDsURL, func(_ string) string {
return config.SystemUpgradeControllerVersion
})
if err != nil {
return fmt.Errorf("failed to substiture system upgrade controller url: %w", err)
}
config.SystemUpgradeControllerCRDsURL = sysUpgradeControllerCRDsURL

return nil
}
1 change: 1 addition & 0 deletions tests/e2e/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ rancherChartURL: https://releases.rancher.com/server-charts/latest/rancher-${RAN

systemUpgradeControllerVersion: v0.13.4
systemUpgradeControllerURL: https://github.com/rancher/system-upgrade-controller/releases/download/${SYSTEM_UPGRADE_CONTROLLER_VERSION}/system-upgrade-controller.yaml
systemUpgradeControllerCRDsURL: https://github.com/rancher/system-upgrade-controller/releases/download/${SYSTEM_UPGRADE_CONTROLLER_VERSION}/crd.yaml
20 changes: 19 additions & 1 deletion tests/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,24 @@ var _ = BeforeSuite(func() {
})

By("installing system-upgrade-controller: "+e2eCfg.SystemUpgradeControllerVersion, func() {
// Install CRDs first
fmt.Println("Using " + e2eCfg.SystemUpgradeControllerCRDsURL)
crdResp, err := http.Get(e2eCfg.SystemUpgradeControllerCRDsURL)
Expect(err).ToNot(HaveOccurred())
defer crdResp.Body.Close()
crdData := bytes.NewBuffer([]byte{})

_, err = io.Copy(crdData, crdResp.Body)
Expect(err).ToNot(HaveOccurred())

temp, err := os.CreateTemp("", "temp")
Expect(err).ToNot(HaveOccurred())

defer os.RemoveAll(temp.Name())
Expect(os.WriteFile(temp.Name(), crdData.Bytes(), os.ModePerm)).To(Succeed())
Expect(kubectl.Apply(cattleSystemNamespace, temp.Name())).To(Succeed())

// Install system upgrade controller
resp, err := http.Get(e2eCfg.SystemUpgradeControllerURL)
Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close()
Expand All @@ -259,7 +277,7 @@ var _ = BeforeSuite(func() {
// It needs to look over cattle-system ns to be functional
toApply := strings.ReplaceAll(data.String(), "namespace: system-upgrade", "namespace: "+cattleSystemNamespace)

temp, err := os.CreateTemp("", "temp")
temp, err = os.CreateTemp("", "temp")
Expect(err).ToNot(HaveOccurred())

defer os.RemoveAll(temp.Name())
Expand Down

0 comments on commit bfb4123

Please sign in to comment.