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

ci(tests): fix tests panic #657

Merged
merged 3 commits into from
Feb 29, 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
23 changes: 20 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,42 @@ jobs:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME_PREFIX: ${{ secrets.AIVEN_PROJECT_NAME_PREFIX }}

find_tests:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.find_tests.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- id: find_tests
run: |
echo "matrix=$(LIST_ONLY=1 go test ./tests/... -list=. | grep Test | jq -cnR '[inputs | select(length>0)]')" >> $GITHUB_OUTPUT

test:
needs: setup_aiven_project_suffix
needs: [setup_aiven_project_suffix, find_tests]
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
name: ${{ fromJson(needs.find_tests.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- run: make test
- run: make run="^${{ matrix.name }}$" test
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: >-
${{ secrets.AIVEN_PROJECT_NAME_PREFIX }}${{ needs.setup_aiven_project_suffix.outputs.project_name_suffix }}

sweep:
if: always()
needs: [test, setup_aiven_project_suffix]
needs: [setup_aiven_project_suffix, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ test-e2e-preinstalled: check-env-vars check-avn-client ## Run end-to-end tests u

test: envtest ## Run tests. To target a specific test, use 'run=TestName make test'.
export KUBEBUILDER_ASSETS=$(shell eval ${KUBEBUILDER_ASSETS_CMD}); \
go test ./tests/... -race -run=$(run) -v $(if $(run), -timeout 20m, -timeout 60m) -parallel 10 -cover -coverpkg=./controllers -covermode=atomic -coverprofile=coverage.out
go test ./tests/... -race -run=$(run) -v $(if $(run), -timeout 30m, -timeout 60m) -parallel 10 -cover -coverpkg=./controllers -covermode=atomic -coverprofile=coverage.out

##@ Build

Expand Down
7 changes: 4 additions & 3 deletions tests/cassandra_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -49,10 +48,12 @@ func TestCassandra(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

name := randName("cassandra")
yml := getCassandraYaml(cfg.Project, name, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterward
defer s.Destroy()
Expand Down
9 changes: 5 additions & 4 deletions tests/clickhouse_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -45,12 +44,14 @@ func TestClickhouse(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

name := randName("clickhouse")
yml := getClickhouseYaml(cfg.Project, name, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/clickhouseuser_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -55,13 +54,15 @@ func TestClickhouseUser(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

chName := randName("clickhouse-user")
userName := randName("clickhouse-user")
yml := getClickhouseUserYaml(cfg.Project, chName, userName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/connectionpool_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -79,15 +78,17 @@ func TestConnectionPool(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

pgName := randName("connection-pool")
dbName := randName("connection-pool")
userName := randName("connection-pool")
poolName := randName("connection-pool")
yml := getConnectionPoolYaml(cfg.Project, pgName, dbName, userName, poolName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/database_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -51,13 +50,15 @@ func TestDatabase(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

pgName := randName("database")
dbName := randName("database")
yml := getDatabaseYaml(cfg.Project, pgName, dbName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
17 changes: 10 additions & 7 deletions tests/generic_service_handler_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -58,12 +57,14 @@ func TestCreateUpdateService(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

pgName := randName("generic-handler")
ymlCreate := getCreateServiceYaml(cfg.Project, pgName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down Expand Up @@ -116,12 +117,14 @@ func TestErrorCondition(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

pgName := randName("generic-handler")
yml := getErrorConditionYaml(cfg.Project, pgName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/grafana_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -48,12 +47,14 @@ func TestGrafana(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

name := randName("grafana")
yml := getGrafanaYaml(cfg.Project, name, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/kafka_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -50,12 +49,14 @@ func TestKafka(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

name := randName("kafka")
yml := getKafkaYaml(cfg.Project, name, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/kafka_with_projectvpc_ref_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -52,13 +51,15 @@ func TestKafkaWithProjectVPCRef(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

vpcName := randName("kafka-vpc")
kafkaName := randName("kafka-vpc")
yml := getKafkaWithProjectVPCRefYaml(cfg.Project, vpcName, kafkaName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/kafkaacl_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -68,14 +67,16 @@ func TestKafkaACL(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

kafkaName := randName("kafka-acl")
topicName := randName("kafka-acl")
aclName := randName("kafka-acl")
yml := getKafkaACLYaml(cfg.Project, kafkaName, topicName, aclName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/kafkaconnect_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"fmt"
"testing"

Expand Down Expand Up @@ -48,12 +47,14 @@ func TestKafkaConnect(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

name := randName("kafka-connect")
yml := getKafkaConnectYaml(cfg.Project, name, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
9 changes: 5 additions & 4 deletions tests/kafkaschema_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package tests

import (
"context"
"encoding/json"
"fmt"
"testing"
Expand Down Expand Up @@ -67,14 +66,16 @@ func TestKafkaSchema(t *testing.T) {
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ctx, cancel := testCtx()
defer cancel()

kafkaName := randName("kafka-schema")
schemaName := randName("kafka-schema")
subjectName := randName("kafka-schema")
yml := getKafkaSchemaYaml(cfg.Project, kafkaName, schemaName, subjectName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)
s := NewSession(ctx, k8sClient, cfg.Project)

// Cleans test afterwards
// Cleans test afterward
defer s.Destroy()

// WHEN
Expand Down
Loading
Loading