Skip to content

Commit

Permalink
Fix nil pointer ha e2e (FoundationDB#1952)
Browse files Browse the repository at this point in the history
* Fix nil pointer exception when creating a FDB cluster in e2e test suite
  • Loading branch information
johscheuer authored Feb 29, 2024
1 parent 344c45e commit 6a1ea6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
4 changes: 1 addition & 3 deletions e2e/fixtures/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (factory *Factory) CreateFdbHaCluster(
startTime := time.Now()
config.SetDefaults(factory)

cluster, err := factory.ensureHAFdbClusterExists(
cluster := factory.ensureHAFdbClusterExists(
config,
options,
)
Expand All @@ -200,8 +200,6 @@ func (factory *Factory) CreateFdbHaCluster(
time.Since(startTime).Minutes(),
)

gomega.Expect(err).ToNot(gomega.HaveOccurred())

return cluster
}

Expand Down
27 changes: 9 additions & 18 deletions e2e/fixtures/fdb_operator_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package fixtures

import (
"fmt"
"github.com/onsi/gomega"
"log"

fdbv1beta2 "github.com/FoundationDB/fdb-kubernetes-operator/api/v1beta2"
Expand Down Expand Up @@ -149,7 +150,7 @@ func (factory *Factory) ensureHaMemberClusterExists(
func (factory *Factory) ensureHAFdbClusterExists(
config *ClusterConfig,
options []ClusterOption,
) (*HaFdbCluster, error) {
) *HaFdbCluster {
fdb := &HaFdbCluster{}
clusterPrefix := factory.getClusterName()

Expand Down Expand Up @@ -182,18 +183,13 @@ func (factory *Factory) ensureHAFdbClusterExists(
initialDatabaseConfiguration,
options,
)
if err != nil {
return nil, err
}
gomega.Expect(err).ToNot(gomega.HaveOccurred())
err = fdb.WaitForReconciliation(CreationTrackerLoggerOption(config.CreationTracker))
gomega.Expect(err).ToNot(gomega.HaveOccurred())
log.Printf("primary cluster is reconciled in namespaces=%s", namespaces)
if err != nil {
return nil, err
}

cluster, err := factory.getClusterStatus(fdb.GetPrimary().Name(), fdb.GetPrimary().Namespace())
if err != nil {
return nil, err
}
gomega.Expect(err).ToNot(gomega.HaveOccurred())

for idx := range dcIDs {
currentConfig := config.Copy()
Expand All @@ -208,20 +204,15 @@ func (factory *Factory) ensureHAFdbClusterExists(
&databaseConfiguration,
options,
)
if err != nil {
return nil, err
}
gomega.Expect(err).ToNot(gomega.HaveOccurred())
}

// Wait until clusters are ready
err = fdb.WaitForReconciliation(CreationTrackerLoggerOption(config.CreationTracker))
if err != nil {
return nil, err
}
gomega.Expect(fdb.WaitForReconciliation(CreationTrackerLoggerOption(config.CreationTracker))).ToNot(gomega.HaveOccurred())

config.CreationCallback(fdb.GetPrimary())

return fdb, nil
return fdb
}

// GetDcIDsFromConfig returns unique DC IDs from the current config.
Expand Down

0 comments on commit 6a1ea6c

Please sign in to comment.