Skip to content

Commit 7c94ece

Browse files
committed
feat: compatibility tests
1 parent fd95db4 commit 7c94ece

26 files changed

+958
-331
lines changed
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: compatibility-tests
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
test-compatibility:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Maximize build space
14+
uses: AdityaGarg8/[email protected]
15+
with:
16+
remove-android: 'true'
17+
remove-haskell: 'true'
18+
remove-codeql: 'true'
19+
remove-dotnet: 'true'
20+
remove-swapfile: 'true'
21+
22+
- name: checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0 # we need to know about previous tags
26+
27+
- name: print the latest version without "v"
28+
id: latest-no-v
29+
uses: miniscruff/changie-action@v2
30+
with:
31+
version: latest
32+
args: latest --remove-prefix
33+
34+
- name: determine-versions
35+
run: |
36+
NEW_VERSION=${{ steps.latest-no-v.outputs.output }}
37+
38+
# Extract the major and minor parts of the version
39+
MAJOR=$(echo $NEW_VERSION | cut -d. -f1)
40+
MINOR=$(echo $NEW_VERSION | cut -d. -f2)
41+
PREV_MINOR=$((MINOR - 1))
42+
43+
# Find the previous version tag in the format "<MAJOR>.<MINOR-1>.<LATEST_PATCH>"
44+
PREVIOUS_VERSION=$(git tag -l "${MAJOR}.${PREV_MINOR}.*" | sort --version-sort | tail -1)
45+
46+
# If no previous version is found, fallback to a default or handle the error somehow
47+
if [ -z "$PREVIOUS_VERSION" ]; then
48+
echo "No previous version found, ensure your repository has proper tags."
49+
exit 1
50+
fi
51+
52+
# remove after creating 0.6.0 tag.
53+
# Basically, we are incompatible with 0.4, and while there is no 0.6 (and prev minor being 0.5),
54+
# we will run compat tests from previous patch version
55+
if [ "$PREVIOUS_VERSION" = "0.4.42" ]; then
56+
PREVIOUS_VERSION="0.5.30"
57+
fi
58+
59+
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
60+
echo "PREVIOUS_VERSION=$PREVIOUS_VERSION" >> $GITHUB_ENV
61+
62+
- name: Setup Go
63+
uses: actions/setup-go@v3
64+
with:
65+
go-version: '1.22'
66+
67+
- name: Install dependencies
68+
run: |
69+
sudo apt-get update
70+
sudo apt-get install -y build-essential
71+
72+
curl -LO https://dl.k8s.io/release/v1.25.3/bin/linux/amd64/kubectl
73+
chmod +x ./kubectl && sudo mv ./kubectl /usr/local/bin
74+
75+
HELM_VERSION="v3.10.3"
76+
curl -sSL https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz | tar -zxvf - --strip-components=1 linux-amd64/helm
77+
chmod +x ./helm && sudo mv ./helm /usr/local/bin
78+
79+
go install sigs.k8s.io/[email protected]
80+
81+
curl -sSL https://storage.yandexcloud.net/yandexcloud-ydb/install.sh | bash
82+
83+
echo "$(pwd)" >> $GITHUB_PATH
84+
echo "$HOME/ydb/bin" >> $GITHUB_PATH
85+
echo "$HOME/go/bin" >> $GITHUB_PATH
86+
87+
- name: Check dependencies
88+
run: |
89+
gcc --version
90+
go version
91+
kind version
92+
kubectl version --client=true
93+
helm version
94+
ydb version
95+
96+
- name: Setup k8s cluster
97+
run: |
98+
kind create cluster \
99+
--image=kindest/node:v1.25.3 \
100+
--config=./tests/cfg/kind-cluster-config.yaml
101+
102+
kubectl wait --timeout=5m --for=condition=ready node -l worker=true
103+
104+
- name: Run compatibility tests
105+
env:
106+
NEW_VERSION: ${{ env.NEW_VERSION }}
107+
PREVIOUS_VERSION: ${{ env.PREVIOUS_VERSION }}
108+
run: |
109+
go install gotest.tools/[email protected]
110+
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 1800s ./tests/compatibility/... -ginkgo.vv -coverprofile cover.out
111+
112+
- name: convert-to-human-readable
113+
run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true
114+
115+
- name: artifact-upload-step
116+
uses: actions/upload-artifact@v4
117+
id: artifact-upload-step
118+
if: always()
119+
with:
120+
name: compat-tests-log
121+
path: log.txt
122+
if-no-files-found: error
123+
124+
- name: echo-tests-log-url
125+
run: echo 'Unit tests log URL is ${{ steps.artifact-upload-step.outputs.artifact-url }}'
126+
127+
- name: Teardown k8s cluster
128+
run: |
129+
kind delete cluster

.github/workflows/run-tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
kind delete cluster
110110
kind create cluster \
111111
--image=kindest/node:v1.25.3@sha256:cd248d1438192f7814fbca8fede13cfe5b9918746dfa12583976158a834fd5c5 \
112-
--config=./e2e/kind-cluster-config.yaml
112+
--config=./tests/cfg/kind-cluster-config.yaml
113113
114114
kubectl wait --timeout=5m --for=condition=ready node -l worker=true
115115
@@ -138,7 +138,7 @@ jobs:
138138
kind load docker-image k8s.gcr.io/ingress-nginx/kube-webhook-certgen:v1.0 --nodes kind-worker,kind-worker2,kind-worker3
139139
- name: pull-and-load-ydb-image
140140
run: |
141-
YDB_IMAGE=$(grep "anchor_for_fetching_image_from_workflow" ./e2e/tests/**/*.go | grep -o -E '"cr\.yandex.*"')
141+
YDB_IMAGE=$(grep "anchor_for_fetching_image_from_workflow" ./tests/e2e/**/*.go | grep -o -E '"cr\.yandex.*"')
142142
YDB_IMAGE=${YDB_IMAGE:1:-1} # strip ""
143143
docker pull $YDB_IMAGE
144144
kind load docker-image $YDB_IMAGE --nodes kind-worker,kind-worker2,kind-worker3
@@ -148,7 +148,7 @@ jobs:
148148
- name: run-e2e-tests
149149
id: run-e2e-tests
150150
run: |
151-
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./e2e/... -ginkgo.vv
151+
gotestsum --format pkgname --jsonfile log.json -- -v -timeout 3600s -p 1 ./tests/e2e/... -ginkgo.vv
152152
- name: convert-json-log-to-human-readable
153153
run: jq -r '.Output| gsub("[\\n]"; "")' log.json 2>/dev/null 1>log.txt || true
154154
- name: artifact-upload-step
@@ -164,4 +164,3 @@ jobs:
164164
- name: teardown-k8s-cluster
165165
run: |
166166
kind delete cluster
167-

docs/tests.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ containers on a single machine. This allows for full-blown smoke tests - apply t
4343
`Storage` manifests, wait until the `Pod`s become available, run `SELECT 1` inside
4444
one of those pods to check that YDB is actually up and running!
4545

46-
E2E tests are located in [e2e](../e2e) folder.
46+
E2E tests are located in [tests/e2e](../tests/e2e) folder.
4747

4848
## Running tests
4949

@@ -81,7 +81,7 @@ kind delete cluster --name=local-kind
8181
kind create cluster \
8282
--image=kindest/node:v1.21.14@sha256:9d9eb5fb26b4fbc0c6d95fa8c790414f9750dd583f5d7cee45d92e8c26670aa1 \
8383
--name=local-kind \
84-
--config=./e2e/kind-cluster-config.yaml \
84+
--config=./tests/cfg/kind-cluster-config.yaml \
8585
--wait 5m
8686

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

9494
# You have to download the ydb image and build the operator image yourself. Then, explicitly
95-
# upload them into the kind cluster. Refer to `./github/e2e.yaml` github workflow which essentially
95+
# upload them into the kind cluster. Refer to `./github/workflows/run-tests.yaml` github workflow which essentially
9696
# does the same thing.
9797
kind --name local-kind load docker-image kind/ydb-operator:current
9898
kind --name local-kind load docker-image ydb:<version>

e2e/operator-values.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

internal/controllers/database/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ import (
2121
"sigs.k8s.io/controller-runtime/pkg/manager"
2222

2323
"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
24-
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
2524
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
2625
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/database"
2726
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storage"
2827
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
28+
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
2929
)
3030

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

7171
By("checking that Storage created on local cluster...")

internal/controllers/databasenodeset/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ import (
1616
"sigs.k8s.io/controller-runtime/pkg/manager"
1717

1818
"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
19-
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
2019
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
2120
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/database"
2221
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/databasenodeset"
2322
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storage"
2423
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
24+
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
2525
)
2626

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

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

7777
By("checking that Storage created on local cluster...")

internal/controllers/monitoring/monitoring_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import (
1616
"sigs.k8s.io/controller-runtime/pkg/manager"
1717

1818
api "github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
19-
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
2019
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants" //nolint:revive,stylecheck
2120
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/monitoring"
2221
"github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
2322
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
23+
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
2424
)
2525

2626
var (
@@ -119,7 +119,7 @@ func createMockDBAndSvc() {
119119
func createMockStorageAndSvc() {
120120
GinkgoHelper()
121121

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

125125
stor.Status.State = StorageReady

internal/controllers/remotedatabasenodeset/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2626

2727
"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
28-
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
2928
ydbannotations "github.com/ydb-platform/ydb-kubernetes-operator/internal/annotations"
3029
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
3130
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/database"
@@ -36,6 +35,7 @@ import (
3635
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storagenodeset"
3736
"github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
3837
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
38+
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
3939
)
4040

4141
const (
@@ -203,7 +203,7 @@ var _ = Describe("RemoteDatabaseNodeSet controller tests", func() {
203203
var databaseSample *v1alpha1.Database
204204

205205
BeforeEach(func() {
206-
storageSample = testobjects.DefaultStorage(filepath.Join("..", "..", "..", "e2e", "tests", "data", "storage-mirror-3-dc-config.yaml"))
206+
storageSample = testobjects.DefaultStorage(filepath.Join("..", "..", "..", "tests", "data", "storage-mirror-3-dc-config.yaml"))
207207
databaseSample = testobjects.DefaultDatabase()
208208
databaseSample.Spec.NodeSets = append(databaseSample.Spec.NodeSets, v1alpha1.DatabaseNodeSetSpecInline{
209209
Name: testNodeSetName + "-local",

internal/controllers/remotestoragenodeset/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ import (
2424
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2525

2626
"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
27-
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
2827
ydbannotations "github.com/ydb-platform/ydb-kubernetes-operator/internal/annotations"
2928
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
3029
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/remotestoragenodeset"
3130
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storage"
3231
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storagenodeset"
3332
"github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
3433
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
34+
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
3535
)
3636

3737
const (
@@ -175,7 +175,7 @@ var _ = Describe("RemoteStorageNodeSet controller tests", func() {
175175
var storageSample *v1alpha1.Storage
176176

177177
BeforeEach(func() {
178-
storageSample = testobjects.DefaultStorage(filepath.Join("..", "..", "..", "e2e", "tests", "data", "storage-mirror-3-dc-config.yaml"))
178+
storageSample = testobjects.DefaultStorage(filepath.Join("..", "..", "..", "tests", "data", "storage-mirror-3-dc-config.yaml"))
179179
storageSample.Spec.NodeSets = append(storageSample.Spec.NodeSets, v1alpha1.StorageNodeSetSpecInline{
180180
Name: testNodeSetName + "-local",
181181
StorageNodeSpec: v1alpha1.StorageNodeSpec{

internal/controllers/storage/controller_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import (
1717
"sigs.k8s.io/controller-runtime/pkg/manager"
1818

1919
"github.com/ydb-platform/ydb-kubernetes-operator/api/v1alpha1"
20-
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
2120
"github.com/ydb-platform/ydb-kubernetes-operator/internal/annotations"
2221
"github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/storage"
2322
"github.com/ydb-platform/ydb-kubernetes-operator/internal/labels"
2423
"github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
2524
"github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
25+
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/tests/test-k8s-objects"
2626
)
2727

2828
var (
@@ -62,7 +62,7 @@ var _ = Describe("Storage controller medium tests", func() {
6262
})
6363

6464
It("Checking field propagation to objects", func() {
65-
storageSample := testobjects.DefaultStorage(filepath.Join("..", "..", "..", "e2e", "tests", "data", "storage-mirror-3-dc-config.yaml"))
65+
storageSample := testobjects.DefaultStorage(filepath.Join("..", "..", "..", "tests", "data", "storage-mirror-3-dc-config.yaml"))
6666

6767
tmpFilesDir := "/tmp/mounted_volume"
6868
testVolumeName := "sample-volume"

0 commit comments

Comments
 (0)