Skip to content

Commit

Permalink
refactor(tests): clean artefacts on panic
Browse files Browse the repository at this point in the history
  • Loading branch information
byashimov committed Feb 28, 2024
1 parent a2a99bf commit 960250c
Show file tree
Hide file tree
Showing 23 changed files with 61 additions and 61 deletions.
4 changes: 2 additions & 2 deletions tests/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ spec:

func TestCassandra(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

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

// Cleans test afterward
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/clickhouse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@ spec:

func TestClickhouse(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

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

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/clickhouseuser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ spec:

func TestClickhouseUser(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
Expand All @@ -61,8 +60,9 @@ func TestClickhouseUser(t *testing.T) {
yml := getClickhouseUserYaml(cfg.Project, chName, userName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/connectionpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ spec:

func TestConnectionPool(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
Expand All @@ -87,8 +86,9 @@ func TestConnectionPool(t *testing.T) {
yml := getConnectionPoolYaml(cfg.Project, pgName, dbName, userName, poolName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ spec:

func TestDatabase(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
Expand All @@ -57,8 +56,9 @@ func TestDatabase(t *testing.T) {
yml := getDatabaseYaml(cfg.Project, pgName, dbName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
8 changes: 4 additions & 4 deletions tests/generic_service_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ spec:
// TestCreateUpdateService tests create and update flow
func TestCreateUpdateService(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

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

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down Expand Up @@ -113,16 +113,16 @@ spec:

func TestErrorCondition(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

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

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/grafana_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ spec:

func TestGrafana(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

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

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,16 @@ spec:

func TestKafka(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

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

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/kafka_with_projectvpc_ref_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ spec:
// TestKafkaWithProjectVPCRef tests Kafka.Spec.ProjectVPCRef
func TestKafkaWithProjectVPCRef(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
Expand All @@ -58,8 +57,9 @@ func TestKafkaWithProjectVPCRef(t *testing.T) {
yml := getKafkaWithProjectVPCRefYaml(cfg.Project, vpcName, kafkaName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/kafkaacl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ spec:

func TestKafkaACL(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
Expand All @@ -75,8 +74,9 @@ func TestKafkaACL(t *testing.T) {
yml := getKafkaACLYaml(cfg.Project, kafkaName, topicName, aclName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/kafkaconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ spec:

func TestKafkaConnect(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

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

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/kafkaschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ spec:

func TestKafkaSchema(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
Expand All @@ -74,8 +73,9 @@ func TestKafkaSchema(t *testing.T) {
yml := getKafkaSchemaYaml(cfg.Project, kafkaName, schemaName, subjectName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/kafkatopic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ spec:
// Also validates kafka topic controller checkPreconditions(), because kafka and topic are applied simultaneously
func TestKafkaTopic(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
ksName := randName("kafka-topic")
yml := getKafkaTopicNameYaml(cfg.Project, ksName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ spec:

func TestMySQL(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
name := randName("mysql")
yml := getMySQLYaml(cfg.Project, name, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
4 changes: 2 additions & 2 deletions tests/opensearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ spec:

func TestOpenSearch(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
name := randName("opensearch")
yml := getOpenSearchYaml(cfg.Project, name, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
10 changes: 5 additions & 5 deletions tests/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ spec:

func TestPgReadReplica(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
Expand All @@ -75,8 +74,9 @@ func TestPgReadReplica(t *testing.T) {
yml := getPgReadReplicaYaml(cfg.Project, masterName, replicaName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down Expand Up @@ -183,16 +183,16 @@ spec:

func TestPgCustomPrefix(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
pgName := randName("secret-prefix")
yml := getPgCustomPrefixYaml(cfg.Project, pgName, cfg.PrimaryCloudName)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down Expand Up @@ -271,7 +271,6 @@ func getPgUpgradeVersionYaml(project, pgName, cloudName, version string) string

func TestPgUpgradeVersion(t *testing.T) {
t.Parallel()
defer recoverPanic(t)

pgVersions := service.TargetVersionTypeChoices()
startingVersion := pgVersions[len(pgVersions)-2]
Expand All @@ -283,6 +282,7 @@ func TestPgUpgradeVersion(t *testing.T) {
s := NewSession(k8sClient, avnClient, cfg.Project)

defer s.Destroy()
defer recoverPanic(t)

require.NoError(t, s.Apply(yaml))

Expand Down
4 changes: 2 additions & 2 deletions tests/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ spec:
func TestProject(t *testing.T) {
t.Skip("Requires a payment to be done to remove the project.")
t.Parallel()
defer recoverPanic(t)

// GIVEN
ctx := context.Background()
name := randName("project")
yml := getProjectYaml(name)
s := NewSession(k8sClient, avnClient, cfg.Project)

// Cleans test afterwards
// Clean the test afterward
defer s.Destroy()
defer recoverPanic(t)

// WHEN
// Applies given manifest
Expand Down
Loading

0 comments on commit 960250c

Please sign in to comment.