Skip to content
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
3 changes: 3 additions & 0 deletions .changes/unreleased/Added-20241204-153550.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kind: Added
body: compatibility tests running automatically on each new tag
time: 2024-12-04T15:35:50.352507104+01:00
129 changes: 129 additions & 0 deletions .github/workflows/compatibility-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: compatibility-tests

on:
push:
tags:
- '*'
workflow_dispatch:

jobs:
test-compatibility:
runs-on: ubuntu-latest
steps:
- name: Maximize build space
uses: AdityaGarg8/[email protected]
with:
remove-android: 'true'
remove-haskell: 'true'
remove-codeql: 'true'
remove-dotnet: 'true'
remove-swapfile: 'true'

- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # we need to know about previous tags

- name: print the latest version without "v"
id: latest-no-v
uses: miniscruff/changie-action@v2
with:
version: latest
args: latest --remove-prefix

- name: determine-versions
run: |
NEW_VERSION=${{ steps.latest-no-v.outputs.output }}

# Extract the major and minor parts of the version
MAJOR=$(echo $NEW_VERSION | cut -d. -f1)
MINOR=$(echo $NEW_VERSION | cut -d. -f2)
PREV_MINOR=$((MINOR - 1))

# Find the previous version tag in the format "<MAJOR>.<MINOR-1>.<LATEST_PATCH>"
PREVIOUS_VERSION=$(git tag -l "${MAJOR}.${PREV_MINOR}.*" | sort --version-sort | tail -1)

# If no previous version is found, fallback to a default or handle the error somehow
if [ -z "$PREVIOUS_VERSION" ]; then
echo "No previous version found, ensure your repository has proper tags."
exit 1
fi

# remove after creating 0.6.0 tag.
# Basically, we are incompatible with 0.4, and while there is no 0.6 (and prev minor being 0.5),
# we will run compat tests from previous patch version
if [ "$PREVIOUS_VERSION" = "0.4.42" ]; then
PREVIOUS_VERSION="0.5.30"
fi

echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_ENV

- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: '1.22'

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential

curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl
chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin

HELM_VERSION="v3.10.3"
curl -sSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -zxvf - --strip-components=1 linux-amd64/helm
chmod +x ./helm && sudo mv ./helm /usr/local/bin

go install sigs.k8s.io/[email protected]

curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash

echo "$(pwd)" >> $GITHUB_PATH
echo "$HOME/ydb/bin" >> $GITHUB_PATH
echo "$HOME/go/bin" >> $GITHUB_PATH

- name: Check dependencies
run: |
gcc --version
go version
kind version
kubectl version --client=true
helm version
ydb version

- name: Setup k8s cluster
run: |
kind create cluster \
--image=kindest/node:v1.31.2@sha256:18fbefc20a7113353c7b75b5c869d7145a6abd6269154825872dc59c1329912e \
--config=./tests/cfg/kind-cluster-config.yaml

kubectl wait --timeout=5m --for=condition=ready node -l worker=true

- name: Run compatibility tests
env:
NEW_VERSION: ${{ env.NEW_VERSION }}
PREVIOUS_VERSION: ${{ env.PREVIOUS_VERSION }}
run: |
go install gotest.tools/[email protected]
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./tests/compatibility/... -ginkgo.vv -coverprofile cover.out

- name: convert-to-human-readable
run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true

- name: artifact-upload-step
uses: actions/upload-artifact@v4
id: artifact-upload-step
if: always()
with:
name: compat-tests-log
path: log.txt
if-no-files-found: error

- name: echo-tests-log-url
run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}'

- name: Teardown k8s cluster
run: |
kind delete cluster
15 changes: 5 additions & 10 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y build-essential

go install sigs.k8s.io/kind@v0.17.0
go install sigs.k8s.io/kind@v0.25.0

curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl
chmod +x ./kubectl
Expand All @@ -108,14 +108,10 @@ jobs:
run: |
kind delete cluster
kind create cluster \
--image=kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5 \
--config=./e2e/kind-cluster-config.yaml
--image=kindest/node:v1.31.2@sha256:18fbefc20a7113353c7b75b5c869d7145a6abd6269154825872dc59c1329912e \
--config=./tests/cfg/kind-cluster-config.yaml

kubectl wait --timeout=5m --for=condition=ready node -l worker=true

kubectl label --overwrite node kind-worker topology.kubernetes.io/zone=fakeZone1
kubectl label --overwrite node kind-worker2 topology.kubernetes.io/zone=fakeZone2
kubectl label --overwrite node kind-worker3 topology.kubernetes.io/zone=fakeZone3
- name: build-operator-image
uses: docker/build-push-action@v3
with:
Expand All @@ -138,7 +134,7 @@ jobs:
kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 --nodes kind-worker,kind-worker2,kind-worker3
- name: pull-and-load-ydb-image
run: |
YDB_IMAGE=$(grep "anchor_for_fetching_image_from_workflow" ./e2e/tests/**/*.go | grep -o -E '"cr\.yandex.*"')
YDB_IMAGE=$(grep "anchor_for_fetching_image_from_workflow" ./tests/**/*.go | grep -o -E '"cr\.yandex.*"')
YDB_IMAGE=${YDB_IMAGE:1:-1} # strip ""
docker pull $YDB_IMAGE
kind load docker-image $YDB_IMAGE --nodes kind-worker,kind-worker2,kind-worker3
Expand All @@ -148,7 +144,7 @@ jobs:
- name: run-e2e-tests
id: run-e2e-tests
run: |
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./e2e/... -ginkgo.vv
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./tests/e2e/... -ginkgo.vv
- name: convert-json-log-to-human-readable
run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true
- name: artifact-upload-step
Expand All @@ -164,4 +160,3 @@ jobs:
- name: teardown-k8s-cluster
run: |
kind delete cluster

12 changes: 10 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,22 @@ output:
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
format: colored-line-number

# print lines of code with issue, default is true
print-issued-lines: true

# print linter name in the end of issue text, default is true
print-linter-name: true


# all available settings of specific linters
linters-settings:
stylecheck:
dot-import-whitelist:
# used in tests only
- "github.com/onsi/ginkgo/v2"
# used in tests only
- "github.com/onsi/gomega"
# it's nice having string constants in a separate package, but without boilerplate
- "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"

errcheck:
# report about not checking of errors in types assetions: `a := b.(MyStruct)`;
# default is false: such cases aren't reported by default.
Expand Down Expand Up @@ -77,6 +84,7 @@ linters-settings:
excludes:
- G101
- G115
- G601 # no longer actual since 1.22
fieldalignment:
# print struct with more effective memory layout or not, false by default
suggest-new: true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![run-tests](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/run-tests.yml)
[![upload-artifacts](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/upload-artifacts.yml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/upload-artifacts.yml)
[![compatibility-tests](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/compatibility-tests.yaml/badge.svg)](https://github.com/ydb-platform/ydb-kubernetes-operator/actions/workflows/compatibility-tests.yaml)

# YDB Kubernetes Operator

Expand Down
6 changes: 3 additions & 3 deletions docs/tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ containers on a single machine. This allows for full-blown smoke tests - apply t
`Storage` manifests, wait until the `Pod`s become available, run `SELECT 1` inside
one of those pods to check that YDB is actually up and running!

E2E tests are located in [e2e](../e2e) folder.
E2E tests are located in [tests/e2e](../tests/e2e) folder.

## Running tests

Expand Down Expand Up @@ -81,7 +81,7 @@ kind delete cluster --name=local-kind
kind create cluster \
--image=kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1 \
--name=local-kind \
--config=./e2e/kind-cluster-config.yaml \
--config=./tests/cfg/kind-cluster-config.yaml \
--wait 5m

# Switch your local kubeconfig to the newly created cluster:
Expand All @@ -92,7 +92,7 @@ kubectl config use-context kind-local-kind
# kind/ydb-operator:current

# You have to download the ydb image and build the operator image yourself. Then, explicitly
# upload them into the kind cluster. Refer to `./github/e2e.yaml` github workflow which essentially
# upload them into the kind cluster. Refer to `./github/workflows/run-tests.yaml` github workflow which essentially
# does the same thing.
kind --name local-kind load docker-image kind/ydb-operator:current
kind --name local-kind load docker-image ydb:<version>
Expand Down
10 changes: 0 additions & 10 deletions e2e/operator-values.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions e2e/tests/data/ca.crt

This file was deleted.

21 changes: 0 additions & 21 deletions e2e/tests/data/tls.crt

This file was deleted.

27 changes: 0 additions & 27 deletions e2e/tests/data/tls.key

This file was deleted.

4 changes: 2 additions & 2 deletions internal/controllers/database/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"

"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/database"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storage"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
)

var (
Expand Down Expand Up @@ -65,7 +65,7 @@ var _ = Describe("Database controller medium tests", func() {
},
}
Expect(k8sClient.Create(ctx, &namespace)).Should(Succeed())
storageSample = *testobjects.DefaultStorage(filepath.Join("..", "..", "..", "e2e", "tests", "data", "storage-mirror-3-dc-config.yaml"))
storageSample = *testobjects.DefaultStorage(filepath.Join("..", "..", "..", "tests", "data", "storage-mirror-3-dc-config.yaml"))
Expect(k8sClient.Create(ctx, &storageSample)).Should(Succeed())

By("checking that Storage created on local cluster...")
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/databasenodeset/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"

"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/database"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/databasenodeset"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storage"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
)

const (
Expand Down Expand Up @@ -71,7 +71,7 @@ var _ = Describe("DatabaseNodeSet controller medium tests", func() {
}
Expect(k8sClient.Create(ctx, &namespace)).Should(Succeed())

storageSample = *testobjects.DefaultStorage(filepath.Join("..", "..", "..", "e2e", "tests", "data", "storage-mirror-3-dc-config.yaml"))
storageSample = *testobjects.DefaultStorage(filepath.Join("..", "..", "..", "tests", "data", "storage-mirror-3-dc-config.yaml"))
Expect(k8sClient.Create(ctx, &storageSample)).Should(Succeed())

By("checking that Storage created on local cluster...")
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/monitoring/monitoring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"

api "github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants" //nolint:revive,stylecheck
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/monitoring"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
)

var (
Expand Down Expand Up @@ -119,7 +119,7 @@ func createMockDBAndSvc() {
func createMockStorageAndSvc() {
GinkgoHelper()

stor := testobjects.DefaultStorage(filepath.Join("..", "..", "..", "e2e", "tests", "data", "storage-mirror-3-dc-config.yaml"))
stor := testobjects.DefaultStorage(filepath.Join("..", "..", "..", "tests", "data", "storage-mirror-3-dc-config.yaml"))
Expect(k8sClient.Create(ctx, stor)).Should(Succeed())

stor.Status.State = StorageReady
Expand Down
Loading
Loading