mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
Revisit CI to spin up clusters on-demand (#7159)
* Label ServiceBinding tests, so we can run them separately They require installing additional components in the cluster (OLM, SBO, ...). * Add GH Workflow for most of our tests (including cluster-related tests) This allows to easily test even multiple versions of Kubernetes if needed. For easier reporting and visualisation (and also avoid rebuilding odo many times), Podman tests have also been relocated in this same Workflow. Notes: I tried to spin up lightweight OpenShift clusters but gave up because of several issues: - MicroShift: I tried to use the aio container image, but this one is no longer maintained and is pretty old version of OCP. Trying to follow the official guidelines did not work either because a base RHEL OS is mandatory - CRC/OpenShiftLocal with Microshift preset: didnt pass the pre-checks because it detected an issue with nested virtualization on the GH Runner. * Drop unused code in helper_oc and use namespace instead of project When testing on Microshift, it seems that the Project API is purposely not implemented on MicroShift
This commit is contained in:
345
.github/workflows/ci.yaml
vendored
Normal file
345
.github/workflows/ci.yaml
vendored
Normal file
@@ -0,0 +1,345 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
|
||||
validate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: Install tools
|
||||
run: make goget-tools
|
||||
- name: Validate
|
||||
run: make validate
|
||||
|
||||
unit_tests:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: Unit Tests
|
||||
run: make test
|
||||
|
||||
build_odo:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha || github.ref }}
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: Build odo
|
||||
run: make bin
|
||||
- run: |
|
||||
chmod +x ./odo
|
||||
./odo version
|
||||
- name: 'Upload odo'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: odo_bin
|
||||
path: odo
|
||||
retention-days: 1
|
||||
if-no-files-found: error
|
||||
|
||||
nocluster_tests:
|
||||
name: "No-Cluster Tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: build_odo
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: Download odo from previous job
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: odo_bin
|
||||
- name: Set odo in system path
|
||||
run: |
|
||||
chmod a+x ./odo
|
||||
sudo mv ./odo /usr/local/bin/odo
|
||||
- run: odo version
|
||||
- name: NoCluster Integration Tests
|
||||
run: make test-integration-no-cluster
|
||||
|
||||
podman_tests:
|
||||
name: "Podman Tests"
|
||||
runs-on: ubuntu-latest
|
||||
needs: build_odo
|
||||
timeout-minutes: 60
|
||||
steps:
|
||||
- run: cat /etc/os-release || true
|
||||
- run: podman info
|
||||
# TODO(rm3l): workaround for https://github.com/actions/runner-images/issues/7753
|
||||
# (caused by https://bugs.launchpad.net/ubuntu/+source/libpod/+bug/2024394).
|
||||
# Remove this when this issue is fixed and available in the ubuntu runner image
|
||||
- run: |
|
||||
sudo apt install podman=3.4.4+ds1-1ubuntu1 --allow-downgrades
|
||||
podman info
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: Download odo from previous job
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: odo_bin
|
||||
- name: Set odo in system path
|
||||
run: |
|
||||
chmod a+x ./odo
|
||||
sudo mv ./odo /usr/local/bin/odo
|
||||
- run: odo version
|
||||
- name: Run Integration tests
|
||||
env:
|
||||
# This should ideally be a configuration in the GH repo (secret or variable).
|
||||
# This is currently hard-coded because GH won't expose secrets or variables to PRs created from forks.
|
||||
# Hopefully, variables (which are non-sensible by definition) will be passed to workflows triggered by PRs from forks.
|
||||
# See https://github.com/community/community/discussions/44322
|
||||
PODMAN_EXEC_NODES: 10
|
||||
run: make test-integration-podman
|
||||
- name: List and stop remaining containers
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
podman pod ls --format '{{.Name}}' | xargs -I '{}' podman pod inspect '{}' || true
|
||||
podman pod ls --format '{{.Name}}' | xargs podman pod stop || true
|
||||
|
||||
kubernetes_tests:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
k8s_version: [v1.28.0, v1.27.3, v1.26.6]
|
||||
service_binding: ["false", "true"]
|
||||
name: "K8s Tests (${{ matrix.k8s_version }}/ServiceBinding=${{ matrix.service_binding }})"
|
||||
runs-on: ubuntu-latest
|
||||
needs: build_odo
|
||||
timeout-minutes: 90
|
||||
env:
|
||||
KUBERNETES: "true"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: Download odo from previous job
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: odo_bin
|
||||
- name: Set odo in system path
|
||||
run: |
|
||||
chmod a+x ./odo
|
||||
sudo mv ./odo /usr/local/bin/odo
|
||||
- name: Create kind cluster
|
||||
uses: helm/kind-action@dda0770415bac9fc20092cacbc54aa298604d140 # v1.8.0
|
||||
with:
|
||||
node_image: "kindest/node:${{ matrix.k8s_version }}"
|
||||
cluster_name: "odo-ci-kind-cluster"
|
||||
ignore_failed_clean: "true"
|
||||
- run: odo version
|
||||
- id: set_service_binding
|
||||
run: echo "service_binding=${{ matrix.service_binding }}" >> "$GITHUB_OUTPUT"
|
||||
- name: Install Operator Lifecycle Manager (OLM)
|
||||
if: ${{ steps.set_service_binding.outputs.service_binding == 'true' }}
|
||||
run: |
|
||||
export olm_version="0.26.0"
|
||||
if ! kubectl get deployment olm-operator -n olm > /dev/null 2>&1; then
|
||||
curl -sL "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v$olm_version/install.sh" | bash -s "v$olm_version"
|
||||
echo -n "Wait for pod app.kubernetes.io/component=controller to be created."
|
||||
while : ; do
|
||||
[ ! -z "`kubectl -n olm get pod --selector=app=olm-operator 2> /dev/null`" ] && echo && break
|
||||
sleep 2
|
||||
echo -n "."
|
||||
done
|
||||
echo -n "Waiting for OLM Operator pod to be ready (timeout in 600s)..."
|
||||
kubectl wait --namespace olm \
|
||||
--for=condition=ready pod \
|
||||
--selector=app=olm-operator \
|
||||
--timeout=600s
|
||||
fi
|
||||
- name: Install ServiceBinding Operator
|
||||
if: ${{ steps.set_service_binding.outputs.service_binding == 'true' }}
|
||||
run: |
|
||||
echo Installing Service Binding Operator
|
||||
kubectl apply -f https://operatorhub.io/install/service-binding-operator.yaml
|
||||
echo -n "Wait for SBO Pod to be created."
|
||||
while : ; do
|
||||
[ ! -z "`kubectl -n operators get pod --selector=control-plane=service-binding-controller-manager 2> /dev/null`" ] && echo && break
|
||||
sleep 2
|
||||
echo -n "."
|
||||
done
|
||||
echo -n "Waiting for SBO Pod pod to be ready (timeout in 600s)..."
|
||||
kubectl wait --namespace operators \
|
||||
--for=condition=ready pod \
|
||||
--selector=control-plane=service-binding-controller-manager \
|
||||
--timeout=600s
|
||||
echo "Installing Cloud Native PostgreSQL Operator"
|
||||
kubectl apply -f https://operatorhub.io/install/stable-v1.19/cloud-native-postgresql.yaml
|
||||
echo -n "Wait for Cloud Native PostgreSQL Controller Manager to be created."
|
||||
while : ; do
|
||||
[ ! -z "`kubectl -n operators get pod --selector=app.kubernetes.io/name=cloud-native-postgresql 2> /dev/null`" ] && echo && break
|
||||
sleep 2
|
||||
echo -n "."
|
||||
done
|
||||
echo -n "Waiting for Cloud Native PostgreSQL Controller Manager pod to be ready (timeout in 600s)..."
|
||||
kubectl wait --namespace operators \
|
||||
--for=condition=ready pod \
|
||||
--selector=app.kubernetes.io/name=cloud-native-postgresql \
|
||||
--timeout=600s
|
||||
- name: Service Binding Integration Tests
|
||||
if: ${{ steps.set_service_binding.outputs.service_binding == 'true' }}
|
||||
run: make test-integration-cluster-service-binding
|
||||
- name: Cluster Integration Tests (w/o Service Binding)
|
||||
if: ${{ steps.set_service_binding.outputs.service_binding != 'true' }}
|
||||
run: make test-integration-cluster-no-service-binding
|
||||
- name: Doc Automation tests
|
||||
if: ${{ steps.set_service_binding.outputs.service_binding != 'true' }}
|
||||
run: make test-doc-automation
|
||||
|
||||
openshift_tests:
|
||||
# # Disabled for now - does not work
|
||||
if: false
|
||||
# TODO(rm3l): Also run unauth tests
|
||||
runs-on: ubuntu-latest
|
||||
name: "OpenShift Tests"
|
||||
needs: build_odo
|
||||
timeout-minutes: 60
|
||||
env:
|
||||
KUBERNETES: "false"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
- name: Download odo from previous job
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: odo_bin
|
||||
- name: Set odo in system path
|
||||
run: |
|
||||
chmod a+x ./odo
|
||||
sudo mv ./odo /usr/local/bin/odo
|
||||
- name: Install oc
|
||||
run: |
|
||||
wget https://mirror.openshift.com/pub/openshift-v4/clients/oc/latest/linux/oc.tar.gz
|
||||
sudo tar xzvf oc.tar.gz -C /usr/local/bin
|
||||
# - name: Install crc
|
||||
# run: |
|
||||
# wget https://developers.redhat.com/content-gateway/file/pub/openshift-v4/clients/crc/2.29.0/crc-linux-amd64.tar.xz
|
||||
# tar xvf crc-linux-amd64.tar.xz
|
||||
# sudo cp -vr crc-linux-*-amd64/crc /usr/local/bin
|
||||
# sudo chmod a+x /usr/local/bin/crc
|
||||
# - name: Enable KVM group perms
|
||||
# run: |
|
||||
# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
|
||||
# sudo udevadm control --reload-rules
|
||||
# sudo udevadm trigger --name-match=kvm
|
||||
# sudo apt-get update
|
||||
# sudo apt-get install -y libvirt-clients libvirt-daemon-system libvirt-daemon virtinst bridge-utils qemu qemu-system-x86
|
||||
# sudo usermod -a -G kvm,libvirt $USER
|
||||
# - name: Run a MicroShift cluster (backed by OpenShift Local, a.k.a. CRC)
|
||||
# run: |
|
||||
# crc config set consent-telemetry no
|
||||
# crc config set preset microshift
|
||||
# crc setup
|
||||
# crc start
|
||||
# eval $(crc oc-env)
|
||||
# oc whoami
|
||||
- name: Run a MicroShift cluster (backed by microshift-aio)
|
||||
run: |
|
||||
sudo podman run -d --rm --name microshift \
|
||||
--privileged -v microshift-data:/var/lib -p 6443:6443 \
|
||||
quay.io/microshift/microshift-aio:latest
|
||||
# get kubeconfig
|
||||
sudo podman exec microshift bash -c \
|
||||
'while ! test -f "/var/lib/microshift/resources/kubeadmin/kubeconfig";
|
||||
do
|
||||
echo "Waiting for kubeconfig..."
|
||||
sleep 5
|
||||
done'
|
||||
mkdir ${HOME}/.kube
|
||||
sudo podman cp \
|
||||
microshift:/var/lib/microshift/resources/kubeadmin/kubeconfig \
|
||||
${HOME}/.kube/config
|
||||
sudo chown ${USER} ${HOME}/.kube/config
|
||||
chmod 600 ${HOME}/.kube/config
|
||||
# wait for the cluster to become available
|
||||
sleep 10
|
||||
kubectl wait --for=condition=available apiservice --all --timeout 300s
|
||||
# - name: Install Operator Lifecycle Manager (OLM)
|
||||
# run: |
|
||||
# eval $(crc oc-env)
|
||||
# export olm_version="0.26.0"
|
||||
# if ! oc get deployment olm-operator -n olm > /dev/null 2>&1; then
|
||||
# curl -sL "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v$olm_version/install.sh" | bash -s "v$olm_version"
|
||||
# echo -n "Wait for pod app.kubernetes.io/component=controller to be created."
|
||||
# while : ; do
|
||||
# [ ! -z "`oc -n olm get pod --selector=app=olm-operator 2> /dev/null`" ] && echo && break
|
||||
# sleep 2
|
||||
# echo -n "."
|
||||
# done
|
||||
# echo -n "Waiting for OLM Operator pod to be ready (timeout in 600s)..."
|
||||
# oc wait --namespace olm \
|
||||
# --for=condition=ready pod \
|
||||
# --selector=app=olm-operator \
|
||||
# --timeout=600s
|
||||
# fi
|
||||
# - name: Install ServiceBinding Operator
|
||||
# run: |
|
||||
# eval $(crc oc-env)
|
||||
# echo Installing Service Binding Operator
|
||||
# oc apply -f https://operatorhub.io/install/service-binding-operator.yaml
|
||||
# echo -n "Wait for SBO Pod to be created."
|
||||
# while : ; do
|
||||
# [ ! -z "`oc -n operators get pod --selector=control-plane=service-binding-controller-manager 2> /dev/null`" ] && echo && break
|
||||
# sleep 2
|
||||
# echo -n "."
|
||||
# done
|
||||
# echo -n "Waiting for SBO Pod pod to be ready (timeout in 600s)..."
|
||||
# oc wait --namespace operators \
|
||||
# --for=condition=ready pod \
|
||||
# --selector=control-plane=service-binding-controller-manager \
|
||||
# --timeout=600s
|
||||
# echo "Installing Cloud Native PostgreSQL Operator"
|
||||
# oc apply -f https://operatorhub.io/install/stable-v1.19/cloud-native-postgresql.yaml
|
||||
# echo -n "Wait for Cloud Native PosgreSQL Controller Manager to be created."
|
||||
# while : ; do
|
||||
# [ ! -z "`oc -n operators get pod --selector=app.kubernetes.io/name=cloud-native-postgresql 2> /dev/null`" ] && echo && break
|
||||
# sleep 2
|
||||
# echo -n "."
|
||||
# done
|
||||
# echo -n "Waiting for Cloud Native PostgreSQL Controller Manager pod to be ready (timeout in 600s)..."
|
||||
# oc wait --namespace operators \
|
||||
# --for=condition=ready pod \
|
||||
# --selector=app.kubernetes.io/name=cloud-native-postgresql \
|
||||
# --timeout=600s
|
||||
# - name: E2E Tests
|
||||
# run: |
|
||||
# # eval $(crc oc-env)
|
||||
# make test-e2e
|
||||
# - if: ${{ always() }}
|
||||
# run: crc delete --force
|
||||
# - name: Setup OpenShift
|
||||
# uses: manusa/actions-setup-openshift@f510517d09cf75af3ad9724b70895471662a4d77
|
||||
# with:
|
||||
# oc version: ${{ matrix.openshift_version }}
|
||||
# github token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: odo version
|
||||
- name: E2E tests
|
||||
run: make test-e2e
|
||||
52
.github/workflows/podman-test.yaml
vendored
52
.github/workflows/podman-test.yaml
vendored
@@ -1,52 +0,0 @@
|
||||
name: odo-podman-test
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
paths-ignore:
|
||||
- 'docs/**'
|
||||
- CONTRIBUTING.md
|
||||
- OWNERS
|
||||
- README.md
|
||||
- USAGE_DATA.md
|
||||
|
||||
jobs:
|
||||
ODO-PODMAN-TEST:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
- run: cat /etc/os-release || true
|
||||
|
||||
- run: podman info
|
||||
|
||||
# TODO(rm3l): workaround for https://github.com/actions/runner-images/issues/7753 (caused by https://bugs.launchpad.net/ubuntu/+source/libpod/+bug/2024394).
|
||||
# Remove this when this issue is fixed and available in the ubuntu runner image
|
||||
- run: |
|
||||
sudo apt install podman=3.4.4+ds1-1ubuntu1 --allow-downgrades
|
||||
podman info
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version-file: 'go.mod'
|
||||
|
||||
- name: Build odo
|
||||
run: make install
|
||||
|
||||
- name: Run Integration tests
|
||||
env:
|
||||
# This should ideally be a configuration in the GH repo (secret or variable).
|
||||
# This is currently hard-coded because GH won't expose secrets or variables to PRs created from forks.
|
||||
# Hopefully, variables (which are non-sensible by definition) will be passed to workflows triggered by PRs from forks.
|
||||
# See https://github.com/community/community/discussions/44322
|
||||
PODMAN_EXEC_NODES: 10
|
||||
run: make test-integration-podman
|
||||
|
||||
- name: List and stop remaining containers
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
podman pod ls --format '{{.Name}}' | xargs -I '{}' podman pod inspect '{}'
|
||||
podman pod ls --format '{{.Name}}' | xargs podman pod stop || true
|
||||
16
Makefile
16
Makefile
@@ -213,6 +213,14 @@ openshiftci-presubmit-unittests:
|
||||
test-integration-cluster:
|
||||
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-integration.xml" --label-filter="!unauth && !nocluster && !podman" tests/integration
|
||||
|
||||
.PHONY: test-integration-cluster-no-service-binding
|
||||
test-integration-cluster-no-service-binding:
|
||||
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-integration.xml" --label-filter="!unauth && !nocluster && !podman &&!servicebinding" tests/integration
|
||||
|
||||
.PHONY: test-integration-service-binding
|
||||
test-integration-cluster-service-binding:
|
||||
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-integration.xml" --label-filter="servicebinding" tests/integration
|
||||
|
||||
.PHONY: test-integration-openshift-unauth
|
||||
test-integration-openshift-unauth:
|
||||
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-integration-unauth.xml" --label-filter="unauth" tests/integration
|
||||
@@ -231,6 +239,14 @@ test-integration-podman:
|
||||
.PHONY: test-integration
|
||||
test-integration: test-integration-no-cluster test-integration-cluster
|
||||
|
||||
.PHONY: test-e2e-no-service-binding
|
||||
test-e2e-no-service-binding:
|
||||
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-e2e.xml" --label-filter="!servicebinding" tests/e2escenarios
|
||||
|
||||
.PHONY: test-e2e-service-binding
|
||||
test-e2e-service-binding:
|
||||
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-e2e.xml" --label-filter="servicebinding" tests/e2escenarios
|
||||
|
||||
.PHONY: test-e2e
|
||||
test-e2e:
|
||||
$(RUN_GINKGO) $(GINKGO_FLAGS) --junit-report="test-e2e.xml" tests/e2escenarios
|
||||
|
||||
@@ -405,7 +405,7 @@ var _ = Describe("E2E Test", func() {
|
||||
})
|
||||
})
|
||||
|
||||
Context("starting with non-empty Directory add Binding", func() {
|
||||
Context("starting with non-empty Directory add Binding", Label(helper.LabelServiceBinding), func() {
|
||||
sendDataEntry := func(url string) map[string]interface{} {
|
||||
values := map[string]interface{}{"name": "joe",
|
||||
"location": "tokyo",
|
||||
|
||||
@@ -35,17 +35,6 @@ func (oc OcRunner) Run(args ...string) *gexec.Session {
|
||||
return session
|
||||
}
|
||||
|
||||
// GetCurrentProject get currently active project in oc
|
||||
// returns empty string if there no active project, or no access to the project
|
||||
func (oc OcRunner) GetCurrentProject() string {
|
||||
session := CmdRunner(oc.path, "project", "-q")
|
||||
session.Wait()
|
||||
if session.ExitCode() == 0 {
|
||||
return strings.TrimSpace(string(session.Out.Contents()))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetCurrentServerURL retrieves the URL of the server we're currently connected to
|
||||
// returns empty if not connected or an error occurred
|
||||
func (oc OcRunner) GetCurrentServerURL() string {
|
||||
@@ -60,36 +49,6 @@ func (oc OcRunner) GetCurrentServerURL() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetFirstURL returns the url of the first Route that it can find for given component
|
||||
func (oc OcRunner) GetFirstURL(component string, app string, project string) string {
|
||||
session := CmdRunner(oc.path, "get", "route",
|
||||
"-n", project,
|
||||
"-l", "app.kubernetes.io/instance="+component,
|
||||
"-l", "app.kubernetes.io/part-of="+app,
|
||||
"-o", "jsonpath={.items[0].spec.host}")
|
||||
|
||||
session.Wait()
|
||||
if session.ExitCode() == 0 {
|
||||
return string(session.Out.Contents())
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// GetComponentRoutes run command to get the Routes in yaml format for given component
|
||||
func (oc OcRunner) GetComponentRoutes(component string, app string, project string) string {
|
||||
session := CmdRunner(oc.path, "get", "route",
|
||||
"-n", project,
|
||||
"-l", "app.kubernetes.io/instance="+component,
|
||||
"-l", "app.kubernetes.io/part-of="+app,
|
||||
"-o", "yaml")
|
||||
|
||||
session.Wait()
|
||||
if session.ExitCode() == 0 {
|
||||
return string(session.Out.Contents())
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ExecListDir returns dir list in specified location of pod
|
||||
func (oc OcRunner) ExecListDir(podName string, projectName string, dir string) string {
|
||||
stdOut := Cmd(oc.path, "exec", podName, "--namespace", projectName,
|
||||
@@ -341,12 +300,13 @@ func (oc OcRunner) createAndSetRandNamespaceProject(projectName string) string {
|
||||
fmt.Fprintf(GinkgoWriter, "Project %q already exists\n", projectName)
|
||||
} else {
|
||||
fmt.Fprintf(GinkgoWriter, "Creating a new project: %s\n", projectName)
|
||||
session := Cmd(oc.path, "new-project", projectName).ShouldPass().Out()
|
||||
session := Cmd(oc.path, "create", "namespace", projectName).ShouldPass().Out()
|
||||
Expect(session).To(ContainSubstring(projectName))
|
||||
}
|
||||
// ListNamespaceProject makes sure that project eventually appears in the list of all namespaces/projects.
|
||||
oc.ListNamespaceProject(projectName)
|
||||
oc.addConfigMapForCleanup(projectName)
|
||||
oc.SetProject(projectName)
|
||||
return projectName
|
||||
}
|
||||
|
||||
@@ -359,7 +319,7 @@ func (oc OcRunner) SetProject(namespace string) string {
|
||||
// DeleteNamespaceProject deletes a specified project in oc cluster
|
||||
func (oc OcRunner) DeleteNamespaceProject(projectName string, wait bool) {
|
||||
fmt.Fprintf(GinkgoWriter, "Deleting project: %s\n", projectName)
|
||||
Cmd(oc.path, "delete", "project", projectName, "--wait="+strconv.FormatBool(wait)).ShouldPass()
|
||||
Cmd(oc.path, "delete", "namespace", projectName, "--wait="+strconv.FormatBool(wait)).ShouldPass()
|
||||
}
|
||||
|
||||
func (oc OcRunner) GetAllPVCNames(namespace string) []string {
|
||||
@@ -590,18 +550,18 @@ func (oc OcRunner) EnsureOperatorIsInstalled(partialOperatorName string) {
|
||||
}
|
||||
|
||||
func (oc OcRunner) GetNamespaceProject() string {
|
||||
return Cmd(oc.path, "get", "project").ShouldPass().Out()
|
||||
return Cmd(oc.path, "get", "namespace").ShouldPass().Out()
|
||||
}
|
||||
|
||||
func (oc OcRunner) HasNamespaceProject(name string) bool {
|
||||
out := Cmd(oc.path, "get", "project", name, "-o", "jsonpath={.metadata.name}").
|
||||
out := Cmd(oc.path, "get", "namespace", name, "-o", "jsonpath={.metadata.name}").
|
||||
ShouldRun().Out()
|
||||
return strings.Contains(out, name)
|
||||
}
|
||||
|
||||
func (oc OcRunner) ListNamespaceProject(name string) {
|
||||
Eventually(func() string {
|
||||
return Cmd(oc.path, "get", "project").ShouldRun().Out()
|
||||
return Cmd(oc.path, "get", "namespace").ShouldRun().Out()
|
||||
}, 30, 1).Should(ContainSubstring(name))
|
||||
}
|
||||
|
||||
@@ -610,7 +570,7 @@ func (oc OcRunner) GetActiveNamespace() string {
|
||||
}
|
||||
|
||||
func (oc OcRunner) GetAllNamespaceProjects() []string {
|
||||
output := Cmd(oc.path, "get", "projects",
|
||||
output := Cmd(oc.path, "get", "namespaces",
|
||||
"-o", "custom-columns=NAME:.metadata.name",
|
||||
"--no-headers").ShouldPass().Out()
|
||||
result, err := ExtractLines(output)
|
||||
|
||||
@@ -5,9 +5,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
LabelNoCluster = "nocluster"
|
||||
LabelUnauth = "unauth"
|
||||
LabelPodman = "podman"
|
||||
LabelNoCluster = "nocluster"
|
||||
LabelUnauth = "unauth"
|
||||
LabelPodman = "podman"
|
||||
LabelServiceBinding = "servicebinding"
|
||||
)
|
||||
|
||||
func NeedsCluster(labels []string) bool {
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/redhat-developer/odo/tests/helper"
|
||||
)
|
||||
|
||||
var _ = Describe("odo add binding command tests", func() {
|
||||
var _ = Describe("odo add binding command tests", Label(helper.LabelServiceBinding), func() {
|
||||
// TODO: Add integration tests for the following cases when SBO is not installed
|
||||
// * servicebinding with envvars does not send `odo dev` in an infinite loop
|
||||
// * `odo dev` deletes service binding secrets for SB that is not present locally
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/redhat-developer/odo/tests/helper"
|
||||
)
|
||||
|
||||
var _ = Describe("odo describe/list binding command tests", func() {
|
||||
var _ = Describe("odo describe/list binding command tests", Label(helper.LabelServiceBinding), func() {
|
||||
var commonVar helper.CommonVar
|
||||
|
||||
// This is run before every Spec (It)
|
||||
|
||||
@@ -1811,7 +1811,7 @@ ComponentSettings:
|
||||
})
|
||||
})
|
||||
|
||||
When("Starting a PostgreSQL service", func() {
|
||||
When("Starting a PostgreSQL service", Label(helper.LabelServiceBinding), func() {
|
||||
BeforeEach(func() {
|
||||
skipLogin := os.Getenv("SKIP_SERVICE_BINDING_TESTS")
|
||||
if skipLogin == "true" {
|
||||
|
||||
@@ -382,7 +382,7 @@ ComponentSettings:
|
||||
})
|
||||
}
|
||||
|
||||
When("deploying a ServiceBinding k8s resource", func() {
|
||||
When("deploying a ServiceBinding k8s resource", Label(helper.LabelServiceBinding), func() {
|
||||
const serviceBindingName = "my-nodejs-app-cluster-sample" // hard-coded from devfile-deploy-with-SB.yaml
|
||||
BeforeEach(func() {
|
||||
skipLogin := os.Getenv("SKIP_SERVICE_BINDING_TESTS")
|
||||
|
||||
@@ -5,11 +5,12 @@ import (
|
||||
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/redhat-developer/odo/tests/helper"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/redhat-developer/odo/tests/helper"
|
||||
)
|
||||
|
||||
var _ = Describe("odo list services tests", func() {
|
||||
var _ = Describe("odo list services tests", Label(helper.LabelServiceBinding), func() {
|
||||
var commonVar helper.CommonVar
|
||||
var randomProject string
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/redhat-developer/odo/tests/helper"
|
||||
)
|
||||
|
||||
var _ = Describe("odo remove binding command tests", func() {
|
||||
var _ = Describe("odo remove binding command tests", Label(helper.LabelServiceBinding), func() {
|
||||
var commonVar helper.CommonVar
|
||||
|
||||
var _ = BeforeEach(func() {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("odo add binding interactive command tests", func() {
|
||||
var _ = Describe("odo add binding interactive command tests", Label(helper.LabelServiceBinding), func() {
|
||||
|
||||
var commonVar helper.CommonVar
|
||||
var serviceName string
|
||||
|
||||
Reference in New Issue
Block a user