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

Allow to specify a cluster name in test suite #1946

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
4 changes: 2 additions & 2 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ compile:
# INPUT ENVIRONMENT VARIABLES
TIMEOUT?=168h

CLUSTER_NAME?=
NAMESPACE?=
PREFIX?=
CONTEXT?=
FDB_VERSION?=7.1.53
# This will be the version used for upgrade tests.
Expand Down Expand Up @@ -111,7 +111,6 @@ nightly-tests: run
--ginkgo.timeout=$(TIMEOUT) \
--timeout=$(TIMEOUT) \
--namespace="$(NAMESPACE)" \
--prefix="$(PREFIX)" \
--context="$(CONTEXT)" \
--fdb-image="$(FDB_IMAGE)" \
--sidecar-image="$(SIDECAR_IMAGE)" \
Expand All @@ -129,4 +128,5 @@ nightly-tests: run
--feature-dns=$(FEATURE_DNS) \
--cloud-provider=$(CLOUD_PROVIDER) \
--dump-operator-state=$(DUMP_OPERATOR_STATE) \
--cluster-name=$(CLUSTER_NAME) \
| grep -v 'constructing many client instances from the same exec auth config can cause performance problems during cert rotation' &> $(BASE_DIR)/../logs/$<.log
11 changes: 11 additions & 0 deletions e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ make -C e2e test_operator.run

Every test suite will create at least one namespace, HA cluster tests will create all the required namespaces.

### Reusing an existing test cluster

A test cluster can be reused if wanted, e.g. for test cases that load a large amount of data into the cluster.
This requires to specify the `CLUSTER_NAME` and the `NAMESPACE`, if those values are not specified the test suite will use randomized values.
** NOTE ** The limitation of this approach is that the test suite will not update the existing `FoundationDBCluster` in the creation step.
So if you're modifying the `FoundationDBCluster` spec, you have to recreate the cluster.

```bash
CLEANUP=false CLUSTER_NAME=dev-cluster-1 NAMESPACE=dev make -kj -C e2e run
```

### StorageClass selection

The e2e tests assume that at least one `StorageClass` is present in the target Kubernetes cluster.
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func DefaultClusterConfig(debugSymbols bool) *ClusterConfig {
// SetDefaults will set all unset fields to the default values.
func (config *ClusterConfig) SetDefaults(factory *Factory) {
if config.Name == "" {
config.Name = factory.getClusterPrefix()
config.Name = factory.getClusterName()
}

// Only create the namespace for non HA clusters, otherwise the namespaces will be created in a different way.
Expand Down
8 changes: 4 additions & 4 deletions e2e/fixtures/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@ func (factory *Factory) getContainerOverrides(
return mainOverrides, sidecarOverrides
}

func (factory *Factory) getClusterPrefix() string {
prefix := factory.options.prefix
if prefix == "" {
func (factory *Factory) getClusterName() string {
if factory.options.clusterName == "" {
return fmt.Sprintf("fdb-cluster-%s", RandStringRunes(8))
}
return prefix

return factory.options.clusterName
}

// GetDefaultStorageClass returns either the StorageClass provided by the command line or fetches the StorageClass passed on
Expand Down
2 changes: 1 addition & 1 deletion e2e/fixtures/fdb_operator_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func (factory *Factory) ensureHAFdbClusterExists(
options []ClusterOption,
) (*HaFdbCluster, error) {
fdb := &HaFdbCluster{}
clusterPrefix := factory.getClusterPrefix()
clusterPrefix := factory.getClusterName()

databaseConfiguration := config.CreateDatabaseConfiguration()
dcIDs := GetDcIDsFromConfig(databaseConfiguration)
Expand Down
13 changes: 6 additions & 7 deletions e2e/fixtures/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import (
type FactoryOptions struct {
namespace string
chaosNamespace string
prefix string
context string
fdbImage string // TODO (johscheuer): Make this optional if we use the default
sidecarImage string // TODO (johscheuer): Make this optional if we use the default
Expand All @@ -45,6 +44,7 @@ type FactoryOptions struct {
storageClass string
upgradeString string
cloudProvider string
clusterName string
enableChaosTests bool
enableDataLoading bool
cleanup bool
Expand All @@ -69,12 +69,6 @@ func (options *FactoryOptions) BindFlags(fs *flag.FlagSet) {
"",
"defines the chaos namespace to run experiments (will be created if missing)",
)
fs.StringVar(
&options.prefix,
"prefix",
"",
"defines the prefix of fdb cluster to run the test (will be created if missing)",
)
fs.StringVar(
&options.context,
"context",
Expand Down Expand Up @@ -183,6 +177,11 @@ func (options *FactoryOptions) BindFlags(fs *flag.FlagSet) {
true,
"defines if the operator tests should print the state of the cluster and the according Pods for better debugging.",
)
fs.StringVar(&options.clusterName,
"cluster-name",
"",
"if defined, the test suite will create a cluster with the specified name or update the setting of an existing cluster."+
"For multi-region clusters, this will define the prefix for all clusters.")
}

func (options *FactoryOptions) validateFlags() error {
Expand Down
21 changes: 12 additions & 9 deletions e2e/fixtures/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,19 @@ func (fdbCluster *FdbCluster) RunFdbCliCommandInOperatorWithoutRetry(
break
}

var parsedStatus *fdbv1beta2.FoundationDBStatus
parsedStatus, err = parseStatusOutput(stdout)
// If we cannot parse the status we probably have an error or timeout
if err != nil {
continue
}
// Only try to parse the content to json if the command was "status json".
if strings.Contains(command, "status json") {
johscheuer marked this conversation as resolved.
Show resolved Hide resolved
var parsedStatus *fdbv1beta2.FoundationDBStatus
parsedStatus, err = parseStatusOutput(stdout)
// If we cannot parse the status we probably have an error or timeout
if err != nil {
continue
}

// Quorum of coordinators are available, so we probably use the correct version
if parsedStatus.Client.Coordinators.QuorumReachable {
break
// Quorum of coordinators are available, so we probably use the correct version
if parsedStatus.Client.Coordinators.QuorumReachable {
break
}
}
}

Expand Down
Loading