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/e2e: use skaffold profile to install operator #212

Merged
merged 2 commits into from
Oct 14, 2024
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: 5 additions & 1 deletion .github/workflows/push-chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
- uses: actions/checkout@v4
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1
- name: Install Skaffold
run: |
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.3.1/skaffold-linux-amd64 && \
sudo install skaffold /usr/local/bin/
- name: Setup Helm
uses: azure/setup-helm@v4
- name: Run e2e tests with Operator
Expand All @@ -38,7 +42,7 @@ jobs:
KIND_CLUSTER=chart-testing \
TEST_RUN='(schema|migration)-mysql'
env:
HELM_TEST: "true"
SKAFFOLD_PROFILE: helm
- name: test env vars
run: |
helm template atlas-operator charts/atlas-operator \
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ test: manifests generate fmt vet envtest ## Run tests.
# - PROMETHEUS_INSTALL_SKIP=true
# - CERT_MANAGER_INSTALL_SKIP=true
.PHONY: test-e2e
SKAFFOLD_PROFILE ?= kustomize
test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated environment using Kind.
go test ./test/e2e/ -v -run="^TestOperator/${TEST_RUN}"
SKAFFOLD_PROFILE=${SKAFFOLD_PROFILE} go test ./test/e2e/ -v -run="^TestOperator/${TEST_RUN}"

.PHONY: kind-image
kind-image:
Expand Down
35 changes: 35 additions & 0 deletions config/sqlserver/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2023 The Atlas Operator Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

namespace: atlas-operator-system
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ../default
patches:
- target:
kind: Deployment
namespace: system
name: controller-manager
patch: |-
- op: add
path: "/spec/template/spec/containers/0/env/-"
value:
name: MSSQL_ACCEPT_EULA
value: "Y"
- op: add
path: "/spec/template/spec/containers/0/env/-"
value:
name: MSSQL_PID
value: "Developer"
30 changes: 25 additions & 5 deletions skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,29 @@ build:
dockerfile: Dockerfile
buildArgs:
OPERATOR_VERSION: v0.0.1-local-k8s
manifests:
kustomize:
paths:
- config/default
profiles:
- name: integration
- name: kustomize
manifests:
kustomize:
paths:
- config/default
- config/sqlserver
- name: helm
deploy:
helm:
releases:
- name: atlas-operator
chartPath: charts/atlas-operator
namespace: atlas-operator-system
createNamespace: true
setValues:
image:
repository: controller
tag: v0.0.1-local-k8s
extraEnvs:
- name: MSSQL_ACCEPT_EULA
value: "Y"
- name: MSSQL_PID
value: "Developer"
valuesFiles:
- charts/atlas-operator/values.yaml
40 changes: 6 additions & 34 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,13 @@ func TestOperator(t *testing.T) {
}
return string(output), nil
}
if os.Getenv("HELM_TEST") != "" {
release := "atlas-operator"
// Deploying the controller-manager using helm
_, err = kind("helm", "install",
"-n", nsController, release,
"charts/atlas-operator",
"--create-namespace",
"--set", "image.tag=nightly",
"--set", "image.pullPolicy=Always",
"--set-json", `extraEnvs=[{"name":"MSSQL_ACCEPT_EULA","value":"Y"},{"name":"MSSQL_PID","value":"Developer"}]`,
"--wait")
require.NoError(t, err)
t.Cleanup(func() {
_, err = kind("helm", "uninstall",
"-n", nsController, release,
"--wait")
require.NoError(t, err)
})
} else {
// Deploying the controller-manager
_, err = kind("skaffold", "run", "--wait-for-connection=true", "-p", "integration")
require.NoError(t, err)
// Installing the CRDs
_, err = kind("make", "install")
require.NoError(t, err)
t.Cleanup(func() {
_, err = kind("make", "undeploy", "ignore-not-found=true")
require.NoError(t, err)
})
// Accept the EULA and set the PID
_, err = kind("kubectl", "set", "env",
"-n", nsController, "deployment/atlas-operator-controller-manager",
"MSSQL_ACCEPT_EULA=Y", "MSSQL_PID=Developer")
// Deploying the controller-manager
_, err = kind("skaffold", "run", "--wait-for-connection=true")
require.NoError(t, err)
t.Cleanup(func() {
_, err = kind("skaffold", "delete")
require.NoError(t, err)
}
})
var controllerPod string
for range 10 {
// Getting the controller-manager pod name
Expand Down