Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: refactor oci/helm tests for registryproviders #1113

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Makefile.oss.prow
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@ KUSTOMIZE_COMPONENTS_DIR := e2e/testdata/hydration/$(KUSTOMIZE_COMPONENTS_PACKAG
KUSTOMIZE_COMPONENTS_PUBLIC_AR_IMAGE := $(LOCATION)-docker.pkg.dev/$(TEST_INFRA_PROJECT)/config-sync-test-public/$(KUSTOMIZE_COMPONENTS_PACKAGE_NAME)
KUSTOMIZE_COMPONENTS_PUBLIC_GCR_IMAGE := gcr.io/$(TEST_INFRA_PROJECT)/$(KUSTOMIZE_COMPONENTS_PACKAGE_NAME)

BOOKINFO_REPO_PACKAGE_NAME := namespace-repo-bookinfo
BOOKINFO_REPO_DIR := e2e/testdata/$(BOOKINFO_REPO_PACKAGE_NAME)
# namespace-repo-bookinfo images (singleton test-infra registry)
BOOKINFO_REPO_PUBLIC_AR_IMAGE := $(LOCATION)-docker.pkg.dev/$(TEST_INFRA_PROJECT)/config-sync-test-public/$(BOOKINFO_REPO_PACKAGE_NAME)

# This target is run as a singleton against the ci-artifacts project, since
# these require for the registries to be public.
.PHONY: push-test-oci-images-public
push-test-oci-images-public: "$(CRANE)"
@gcloud $(GCLOUD_QUIET) auth configure-docker $(LOCATION)-docker.pkg.dev,gcr.io
cd $(KUSTOMIZE_COMPONENTS_DIR) && crane append -f <(tar -f - -c .) -t $(KUSTOMIZE_COMPONENTS_PUBLIC_GCR_IMAGE)
cd $(KUSTOMIZE_COMPONENTS_DIR) && crane append -f <(tar -f - -c .) -t $(KUSTOMIZE_COMPONENTS_PUBLIC_AR_IMAGE)
cd $(BOOKINFO_REPO_DIR) && crane append -f <(tar -f - -c .) -t $(BOOKINFO_REPO_PUBLIC_AR_IMAGE)

# The following targets are used to provision test resources in a prow environment

Expand Down
2 changes: 1 addition & 1 deletion build/prow/e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ARG DOCKER_CLI_IMAGE
FROM ${GCLOUD_IMAGE} as gcloud-install

RUN apt-get update && apt-get install -y \
kubectl google-cloud-sdk-gke-gcloud-auth-plugin
kubectl google-cloud-cli-gke-gcloud-auth-plugin

FROM ${GOLANG_IMAGE} as builder

Expand Down
47 changes: 40 additions & 7 deletions e2e/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package e2e
import (
"flag"
"fmt"
"slices"
"strings"
"testing"

Expand Down Expand Up @@ -47,6 +48,33 @@ func newStringListFlag(name string, def []string, usage string) *[]string {
return &lf.arr
}

// stringEnum is a string flag with a set of allowed values
type stringEnum struct {
value string
allowedValues []string
}

func (i *stringEnum) String() string {
return i.value
}

func (i *stringEnum) Set(value string) error {
if !slices.Contains(i.allowedValues, value) {
return fmt.Errorf("%s not in allowed values: %s", value, i.allowedValues)
}
i.value = value
return nil
}

func newStringEnum(name string, defaultVal string, usage string, allowed []string) *string {
lf := &stringEnum{
value: defaultVal,
allowedValues: allowed,
}
flag.Var(lf, name, fmt.Sprintf("%s Allowed values: %s", usage, allowed))
return &lf.value
}

// E2E enables running end-to-end tests.
var E2E = flag.Bool("e2e", false,
"If true, run end-to-end tests.")
Expand Down Expand Up @@ -101,16 +129,19 @@ var ShareTestEnv = flag.Bool("share-test-env", false,
"Specify that the test is using a shared test environment instead of fresh installation per test case.")

// GitProvider is the provider that hosts the Git repositories.
var GitProvider = flag.String("git-provider", Local,
"The git provider that hosts the Git repositories. Defaults to local.")
var GitProvider = newStringEnum("git-provider", util.EnvString("E2E_GIT_PROVIDER", Local),
"The git provider that hosts the Git repositories. Defaults to Local.",
[]string{Local, Bitbucket, GitLab, CSR})

// OCIProvider is the provider that hosts the OCI repositories.
var OCIProvider = flag.String("oci-provider", Local,
"The registry provider that hosts the OCI repositories. Defaults to local.")
var OCIProvider = newStringEnum("oci-provider", util.EnvString("E2E_OCI_PROVIDER", Local),
"The registry provider that hosts the OCI repositories. Defaults to Local.",
[]string{Local, ArtifactRegistry})

// HelmProvider is the provider that hosts the OCI repositories.
var HelmProvider = flag.String("helm-provider", Local,
"The registry provider that hosts the helm packages. Defaults to local.")
// HelmProvider is the provider that hosts the helm repositories.
var HelmProvider = newStringEnum("helm-provider", util.EnvString("E2E_HELM_PROVIDER", Local),
"The registry provider that hosts the helm repositories. Defaults to Local.",
[]string{Local, ArtifactRegistry})

// TestFeatures is the list of features to run.
var TestFeatures = flag.String("test-features", "",
Expand Down Expand Up @@ -250,6 +281,8 @@ const (
GitLab = "gitlab"
// CSR indicates using Google Cloud Source Repositories to host the repositories.
CSR = "csr"
// ArtifactRegistry indicates using Google Artifact Registry to host the repositories.
ArtifactRegistry = "gar"
)

// NumParallel returns the number of parallel test threads
Expand Down
92 changes: 0 additions & 92 deletions e2e/nomostest/artifactregistry/crane.go

This file was deleted.

167 changes: 0 additions & 167 deletions e2e/nomostest/artifactregistry/helm.go

This file was deleted.

Loading