Skip to content

Commit

Permalink
refactor(tests): set test ctx timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Feb 29, 2024
1 parent 839dfe7 commit b2bff69
Show file tree
Hide file tree
Showing 25 changed files with 169 additions and 125 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
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
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
9 changes: 5 additions & 4 deletions tests/kafkatopic_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 @@ -74,12 +73,14 @@ func TestKafkaTopic(t *testing.T) {
defer recoverPanic(t)

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

ksName := randName("kafka-topic")
yml := getKafkaTopicNameYaml(cfg.Project, ksName, 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/mysql_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 TestMySQL(t *testing.T) {
defer recoverPanic(t)

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

name := randName("mysql")
yml := getMySQLYaml(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
Loading

0 comments on commit b2bff69

Please sign in to comment.