Skip to content

Commit

Permalink
Add docker regional curated packages e2e test (#6964)
Browse files Browse the repository at this point in the history
  • Loading branch information
d8660091 authored Nov 7, 2023
1 parent c2f7602 commit 03b4275
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ env:
EKSA_AWS_ACCESS_KEY_ID: "packages_ci_beta:aws_access_key_id"
EKSA_AWS_SECRET_ACCESS_KEY: "packages_ci_beta:aws_secret_access_key_id"
EKSA_AWS_REGION: "packages_ci_beta:aws_region"
REGIONAL_EKSA_AWS_ACCESS_KEY_ID: "packages_ci_beta:regional_aws_access_key_id"
REGIONAL_EKSA_AWS_SECRET_ACCESS_KEY: "packages_ci_beta:regional_aws_secret_access_key_id"
EKSA_GITHUB_TOKEN: "github-eks-anywhere-flux-bot:github-token"
T_GITHUB_USER: "github-eks-anywhere-flux-bot:github-user"
T_GIT_REPOSITORY: "github-eks-anywhere-flux-bot:github-repository"
Expand Down
14 changes: 12 additions & 2 deletions internal/test/e2e/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
)

const (
packagesRegex = `^.*CuratedPackages.*$`
certManagerRegex = "^.*CuratedPackagesCertManager.*$"
packagesRegex = `^.*CuratedPackages.*$`
regionalPackagesRegex = `^.*RegionalCuratedPackages.*$`
certManagerRegex = "^.*CuratedPackagesCertManager.*$"
)

func (e *E2ESession) setupPackagesEnv(testRegex string) error {
Expand All @@ -24,6 +25,15 @@ func (e *E2ESession) setupPackagesEnv(testRegex string) error {
e.testEnvVars[eVar] = val
}
}

// overwrite envs for regional curated packages test
if regexp.MustCompile(regionalPackagesRegex).MatchString(testRegex) {
for _, eVar := range requiredEnvVars {
if val, ok := os.LookupEnv("REGIONAL_" + eVar); ok {
e.testEnvVars[eVar] = val
}
}
}
return nil
}

Expand Down
13 changes: 8 additions & 5 deletions pkg/executables/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,13 +695,16 @@ func (k *Kubectl) DeleteFluxConfig(ctx context.Context, managementCluster *types
// GetPackageBundleController will retrieve the packagebundlecontroller from eksa-packages namespace and return the object.
func (k *Kubectl) GetPackageBundleController(ctx context.Context, kubeconfigFile, clusterName string) (packagesv1.PackageBundleController, error) {
params := []string{"get", eksaPackagesBundleControllerType, clusterName, "-o", "json", "--kubeconfig", kubeconfigFile, "--namespace", constants.EksaPackagesName, "--ignore-not-found=true"}
stdOut, _ := k.Execute(ctx, params...)
response := &packagesv1.PackageBundleController{}
err := json.Unmarshal(stdOut.Bytes(), response)
stdOut, err := k.Execute(ctx, params...)
if err != nil {
return packagesv1.PackageBundleController{}, fmt.Errorf("failed to execute cmd \"%s\": %w", strings.Join(params, " "), err)
}
pbc := &packagesv1.PackageBundleController{}
err = json.Unmarshal(stdOut.Bytes(), pbc)
if err != nil {
return packagesv1.PackageBundleController{}, fmt.Errorf("unmarshalling kubectl response to GO struct %s: %v", clusterName, err)
return packagesv1.PackageBundleController{}, fmt.Errorf("unmarshalling kubectl response to GO struct %s: %v, response: %s", clusterName, err, stdOut.String())
}
return *response, nil
return *pbc, nil
}

// GetPackageBundleList will retrieve the packagebundle list from eksa-packages namespace and return the list.
Expand Down
20 changes: 20 additions & 0 deletions test/e2e/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1298,3 +1298,23 @@ func TestDockerCiliumSkipUpgrade_ControllerUpgrade(t *testing.T) {
test.ManagementCluster.StopIfFailed()
test.DeleteManagementCluster()
}

func TestDockerKubernetesRegionalCuratedPackages(t *testing.T) {
framework.CheckCuratedPackagesCredentials(t)
test := framework.NewClusterE2ETest(t,
framework.NewDocker(t),
framework.WithClusterFiller(api.WithKubernetesVersion(v1alpha1.Kube128)),
)

test.WithCluster(func(e *framework.ClusterE2ETest) {
runCuratedPackageInstall(e)

pbc, err := test.KubectlClient.GetPackageBundleController(context.Background(), test.KubeconfigFilePath(), test.ClusterName)
if err != nil {
e.T.Fatalf("cannot get PackageBundleController: %v", err)
}
if pbc.Spec.DefaultImageRegistry != pbc.Spec.DefaultRegistry {
e.T.Fatal("in regional pbc, DefaultImageRegistry should equal to DefaultRegistry")
}
})
}

0 comments on commit 03b4275

Please sign in to comment.