Skip to content

Commit

Permalink
Fix the way the resources for storage processes are calculated in the…
Browse files Browse the repository at this point in the history
… e2e test framework
  • Loading branch information
johscheuer committed May 4, 2023
1 parent fa57a33 commit 660064b
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 1 deletion.
6 changes: 5 additions & 1 deletion e2e/fixtures/cluster_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ func (config *ClusterConfig) SetDefaults(factory *Factory) {
config.VolumeSize = "16Gi"
}

if config.StorageServerPerPod == 0 {
config.StorageServerPerPod = 1
}

if config.CreationCallback == nil {
config.CreationCallback = func(fdbCluster *FdbCluster) {
if fdbCluster == nil {
Expand Down Expand Up @@ -165,7 +169,7 @@ func (config *ClusterConfig) generatePodResources(
// for an fdbserver process.
cpu := 1
memory := 8
if processClass == fdbv1beta2.ProcessClassStorage {
if processClass == fdbv1beta2.ProcessClassStorage && config.StorageServerPerPod > 1 {
cpu *= config.StorageServerPerPod
memory *= config.StorageServerPerPod
}
Expand Down
79 changes: 79 additions & 0 deletions e2e/fixtures/cluster_config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* cluster_config_test.go
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2023 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package fixtures

import (
fdbv1beta2 "github.com/FoundationDB/fdb-kubernetes-operator/api/v1beta2"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
)

var _ = FDescribe("Cluster configuration", func() {
DescribeTable("when generating the Pod resources", func(config *ClusterConfig, processClass fdbv1beta2.ProcessClass, expected corev1.ResourceList) {
Expect(config.generatePodResources(processClass)).To(Equal(expected))
},
Entry("empty config for general process class",
&ClusterConfig{},
fdbv1beta2.ProcessClassGeneral,
corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("0.2"),
corev1.ResourceMemory: resource.MustParse("2Gi"),
}),
Entry("empty config for storage process class",
&ClusterConfig{},
fdbv1beta2.ProcessClassStorage,
corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("0.2"),
corev1.ResourceMemory: resource.MustParse("2Gi"),
}),

Entry("performance config for general process class",
&ClusterConfig{
Performance: true,
},
fdbv1beta2.ProcessClassGeneral,
corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("1"),
corev1.ResourceMemory: resource.MustParse("8Gi"),
}),
Entry("performance config for storage process class",
&ClusterConfig{
Performance: true,
},
fdbv1beta2.ProcessClassStorage,
corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("1"),
corev1.ResourceMemory: resource.MustParse("8Gi"),
}),
Entry("performance config for storage process class with multiple storage servers per disk",
&ClusterConfig{
Performance: true,
StorageServerPerPod: 2,
},
fdbv1beta2.ProcessClassStorage,
corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("2"),
corev1.ResourceMemory: resource.MustParse("16Gi"),
}),
)
})
33 changes: 33 additions & 0 deletions e2e/fixtures/suite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* suite_test.go
*
* This source file is part of the FoundationDB open source project
*
* Copyright 2021 Apple Inc. and the FoundationDB project authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package fixtures

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestCmd(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "FDB e2e test fixtures")
}

0 comments on commit 660064b

Please sign in to comment.