2020-10-27 00:53:51 +00:00
|
|
|
/*
|
|
|
|
|
Copyright 2020 The Rook Authors. All rights reserved.
|
|
|
|
|
|
|
|
|
|
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 controller
|
|
|
|
|
|
|
|
|
|
import (
|
2021-10-26 13:23:11 -06:00
|
|
|
ctx "context"
|
2025-02-21 18:02:00 -07:00
|
|
|
"os"
|
2020-10-27 00:53:51 +00:00
|
|
|
"testing"
|
2021-02-22 10:19:21 +00:00
|
|
|
"time"
|
2020-10-27 00:53:51 +00:00
|
|
|
|
|
|
|
|
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
|
2021-10-26 13:23:11 -06:00
|
|
|
"github.com/rook/rook/pkg/client/clientset/versioned/scheme"
|
2021-02-22 10:19:21 +00:00
|
|
|
"github.com/rook/rook/pkg/util/exec"
|
2020-10-27 00:53:51 +00:00
|
|
|
"github.com/stretchr/testify/assert"
|
2021-10-26 13:23:11 -06:00
|
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
|
|
|
"k8s.io/apimachinery/pkg/types"
|
|
|
|
|
"sigs.k8s.io/controller-runtime/pkg/client/fake"
|
2020-10-27 00:53:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func CreateTestClusterFromStatusDetails(details map[string]cephv1.CephHealthMessage) cephv1.CephCluster {
|
|
|
|
|
return cephv1.CephCluster{
|
|
|
|
|
Status: cephv1.ClusterStatus{
|
|
|
|
|
CephStatus: &cephv1.CephStatus{
|
|
|
|
|
Details: details,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestCanIgnoreHealthErrStatusInReconcile(t *testing.T) {
|
2025-03-13 15:24:58 -07:00
|
|
|
cluster := CreateTestClusterFromStatusDetails(map[string]cephv1.CephHealthMessage{
|
2020-10-27 00:53:51 +00:00
|
|
|
"MDS_ALL_DOWN": {
|
|
|
|
|
Severity: "HEALTH_ERR",
|
2025-02-26 16:16:19 -07:00
|
|
|
Message: "mds all down error",
|
|
|
|
|
},
|
|
|
|
|
"MGR_MODULE_ERROR": {
|
|
|
|
|
Severity: "HEALTH_ERR",
|
|
|
|
|
Message: "mgr module error",
|
2020-10-27 00:53:51 +00:00
|
|
|
},
|
|
|
|
|
"TEST_OTHER": {
|
|
|
|
|
Severity: "HEALTH_WARN",
|
|
|
|
|
Message: "TEST_OTHER",
|
|
|
|
|
},
|
|
|
|
|
"TEST_ANOTHER": {
|
|
|
|
|
Severity: "HEALTH_OK",
|
|
|
|
|
Message: "TEST_ANOTHER",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
assert.True(t, canIgnoreHealthErrStatusInReconcile(cluster, "controller"))
|
|
|
|
|
|
2025-02-26 16:16:19 -07:00
|
|
|
cluster = CreateTestClusterFromStatusDetails(map[string]cephv1.CephHealthMessage{
|
|
|
|
|
"MGR_MODULE_ERROR": {
|
|
|
|
|
Severity: "HEALTH_ERR",
|
|
|
|
|
Message: "mgr module error",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
assert.True(t, canIgnoreHealthErrStatusInReconcile(cluster, "controller"))
|
|
|
|
|
|
|
|
|
|
cluster = CreateTestClusterFromStatusDetails(map[string]cephv1.CephHealthMessage{
|
|
|
|
|
"MGR_MODULE_ERROR_FALSE": {
|
|
|
|
|
Severity: "HEALTH_ERR",
|
|
|
|
|
Message: "mgr module error",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
assert.False(t, canIgnoreHealthErrStatusInReconcile(cluster, "controller"))
|
|
|
|
|
|
2020-10-27 00:53:51 +00:00
|
|
|
cluster = CreateTestClusterFromStatusDetails(map[string]cephv1.CephHealthMessage{
|
|
|
|
|
"MDS_ALL_DOWN": {
|
|
|
|
|
Severity: "HEALTH_ERR",
|
|
|
|
|
Message: "MDS_ALL_DOWN",
|
|
|
|
|
},
|
|
|
|
|
"TEST_UNIGNORABLE": {
|
|
|
|
|
Severity: "HEALTH_ERR",
|
|
|
|
|
Message: "TEST_UNIGNORABLE",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
assert.False(t, canIgnoreHealthErrStatusInReconcile(cluster, "controller"))
|
|
|
|
|
|
|
|
|
|
cluster = CreateTestClusterFromStatusDetails(map[string]cephv1.CephHealthMessage{
|
|
|
|
|
"TEST_UNIGNORABLE": {
|
|
|
|
|
Severity: "HEALTH_ERR",
|
|
|
|
|
Message: "TEST_UNIGNORABLE",
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
assert.False(t, canIgnoreHealthErrStatusInReconcile(cluster, "controller"))
|
2025-02-26 16:16:19 -07:00
|
|
|
|
|
|
|
|
// The empty status should return false
|
|
|
|
|
cluster = CreateTestClusterFromStatusDetails(map[string]cephv1.CephHealthMessage{})
|
|
|
|
|
assert.False(t, canIgnoreHealthErrStatusInReconcile(cluster, "controller"))
|
2020-10-27 00:53:51 +00:00
|
|
|
}
|
2021-02-22 10:19:21 +00:00
|
|
|
|
|
|
|
|
func TestSetCephCommandsTimeout(t *testing.T) {
|
2025-02-21 18:02:00 -07:00
|
|
|
defer os.Unsetenv("ROOK_CEPH_COMMANDS_TIMEOUT_SECONDS")
|
|
|
|
|
|
|
|
|
|
SetCephCommandsTimeout()
|
2021-02-22 10:19:21 +00:00
|
|
|
assert.Equal(t, 15*time.Second, exec.CephCommandsTimeout)
|
|
|
|
|
|
|
|
|
|
exec.CephCommandsTimeout = 0
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv("ROOK_CEPH_COMMANDS_TIMEOUT_SECONDS", "0")
|
|
|
|
|
SetCephCommandsTimeout()
|
2021-02-22 10:19:21 +00:00
|
|
|
assert.Equal(t, 15*time.Second, exec.CephCommandsTimeout)
|
|
|
|
|
|
|
|
|
|
exec.CephCommandsTimeout = 0
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv("ROOK_CEPH_COMMANDS_TIMEOUT_SECONDS", "1")
|
|
|
|
|
SetCephCommandsTimeout()
|
2021-02-22 10:19:21 +00:00
|
|
|
assert.Equal(t, 1*time.Second, exec.CephCommandsTimeout)
|
|
|
|
|
}
|
2021-10-26 13:23:11 -06:00
|
|
|
|
2022-11-01 08:41:19 +00:00
|
|
|
func TestSetAllowLoopDevices(t *testing.T) {
|
2025-02-21 18:02:00 -07:00
|
|
|
defer os.Unsetenv("ROOK_CEPH_ALLOW_LOOP_DEVICES")
|
|
|
|
|
|
|
|
|
|
SetAllowLoopDevices()
|
2022-11-01 08:41:19 +00:00
|
|
|
assert.False(t, LoopDevicesAllowed())
|
|
|
|
|
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv("ROOK_CEPH_ALLOW_LOOP_DEVICES", "foo")
|
|
|
|
|
SetAllowLoopDevices()
|
2022-11-01 08:41:19 +00:00
|
|
|
assert.False(t, LoopDevicesAllowed())
|
|
|
|
|
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv("ROOK_CEPH_ALLOW_LOOP_DEVICES", "false")
|
|
|
|
|
SetAllowLoopDevices()
|
2022-11-01 08:41:19 +00:00
|
|
|
assert.False(t, LoopDevicesAllowed())
|
|
|
|
|
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv("ROOK_CEPH_ALLOW_LOOP_DEVICES", "true")
|
|
|
|
|
SetAllowLoopDevices()
|
2022-11-01 08:41:19 +00:00
|
|
|
assert.True(t, LoopDevicesAllowed())
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-16 19:04:01 +02:00
|
|
|
func TestSetEnforceHostNetwork(t *testing.T) {
|
2025-02-21 18:02:00 -07:00
|
|
|
defer os.Unsetenv(enforceHostNetworkSettingName)
|
|
|
|
|
|
2024-08-16 19:04:01 +02:00
|
|
|
logger.Infof("testing default value for %v", enforceHostNetworkSettingName)
|
2025-02-21 18:02:00 -07:00
|
|
|
SetEnforceHostNetwork()
|
2024-08-16 19:04:01 +02:00
|
|
|
assert.False(t, EnforceHostNetwork())
|
|
|
|
|
|
|
|
|
|
// test invalid setting
|
2025-05-20 10:45:42 -04:00
|
|
|
value := "foo"
|
2024-08-16 19:04:01 +02:00
|
|
|
logger.Infof("testing invalid value'%v' for %v", value, enforceHostNetworkSettingName)
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv(enforceHostNetworkSettingName, value)
|
|
|
|
|
SetEnforceHostNetwork()
|
2024-08-16 19:04:01 +02:00
|
|
|
assert.False(t, EnforceHostNetwork())
|
|
|
|
|
|
|
|
|
|
// test valid settings
|
|
|
|
|
value = "true"
|
|
|
|
|
logger.Infof("testing valid value'%v' for %v", value, enforceHostNetworkSettingName)
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv(enforceHostNetworkSettingName, value)
|
|
|
|
|
SetEnforceHostNetwork()
|
2024-08-16 19:04:01 +02:00
|
|
|
assert.True(t, EnforceHostNetwork())
|
|
|
|
|
|
|
|
|
|
value = "false"
|
|
|
|
|
logger.Infof("testing valid value'%v' for %v", value, enforceHostNetworkSettingName)
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv(enforceHostNetworkSettingName, value)
|
|
|
|
|
SetEnforceHostNetwork()
|
2024-08-16 19:04:01 +02:00
|
|
|
assert.False(t, EnforceHostNetwork())
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-26 14:11:53 +02:00
|
|
|
func TestSetRevisionHistoryLimit(t *testing.T) {
|
2025-02-21 18:02:00 -07:00
|
|
|
defer os.Unsetenv(revisionHistoryLimitSettingName)
|
|
|
|
|
|
2024-09-26 14:11:53 +02:00
|
|
|
t.Run("ROOK_REVISION_HISTORY_LIMIT: test default value", func(t *testing.T) {
|
2025-02-21 18:02:00 -07:00
|
|
|
SetRevisionHistoryLimit()
|
2024-09-26 14:11:53 +02:00
|
|
|
assert.Nil(t, RevisionHistoryLimit())
|
|
|
|
|
})
|
|
|
|
|
|
2025-05-20 10:45:42 -04:00
|
|
|
value := "foo"
|
2024-09-26 14:11:53 +02:00
|
|
|
t.Run("ROOK_REVISION_HISTORY_LIMIT: test invalid value 'foo'", func(t *testing.T) {
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv(revisionHistoryLimitSettingName, value)
|
|
|
|
|
SetRevisionHistoryLimit()
|
2024-09-26 14:11:53 +02:00
|
|
|
assert.Nil(t, RevisionHistoryLimit())
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("ROOK_REVISION_HISTORY_LIMIT: test empty string value", func(t *testing.T) {
|
|
|
|
|
value = ""
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv(revisionHistoryLimitSettingName, value)
|
|
|
|
|
SetRevisionHistoryLimit()
|
2024-09-26 14:11:53 +02:00
|
|
|
assert.Nil(t, RevisionHistoryLimit())
|
|
|
|
|
})
|
|
|
|
|
t.Run("ROOK_REVISION_HISTORY_LIMIT: test valig value '10'", func(t *testing.T) {
|
|
|
|
|
value = "10"
|
2025-02-21 18:02:00 -07:00
|
|
|
os.Setenv(revisionHistoryLimitSettingName, value)
|
|
|
|
|
SetRevisionHistoryLimit()
|
2024-09-26 14:11:53 +02:00
|
|
|
assert.Equal(t, int32(10), *RevisionHistoryLimit())
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-03-13 15:24:58 -07:00
|
|
|
|
2021-10-26 13:23:11 -06:00
|
|
|
func TestIsReadyToReconcile(t *testing.T) {
|
|
|
|
|
scheme := scheme.Scheme
|
|
|
|
|
scheme.AddKnownTypes(cephv1.SchemeGroupVersion, &cephv1.CephCluster{}, &cephv1.CephClusterList{})
|
|
|
|
|
|
|
|
|
|
controllerName := "testing"
|
|
|
|
|
clusterName := types.NamespacedName{Name: "mycluster", Namespace: "myns"}
|
|
|
|
|
|
|
|
|
|
t.Run("non-existent cephcluster", func(t *testing.T) {
|
|
|
|
|
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects().Build()
|
|
|
|
|
c, ready, clusterExists, reconcileResult := IsReadyToReconcile(ctx.TODO(), client, clusterName, controllerName)
|
|
|
|
|
assert.NotNil(t, c)
|
|
|
|
|
assert.False(t, ready)
|
|
|
|
|
assert.False(t, clusterExists)
|
|
|
|
|
assert.Equal(t, WaitForRequeueIfCephClusterNotReady, reconcileResult)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("valid cephcluster", func(t *testing.T) {
|
|
|
|
|
cephCluster := &cephv1.CephCluster{}
|
|
|
|
|
objects := []runtime.Object{cephCluster}
|
|
|
|
|
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(objects...).Build()
|
|
|
|
|
c, ready, clusterExists, reconcileResult := IsReadyToReconcile(ctx.TODO(), client, clusterName, controllerName)
|
|
|
|
|
assert.NotNil(t, c)
|
|
|
|
|
assert.False(t, ready)
|
|
|
|
|
assert.False(t, clusterExists)
|
|
|
|
|
assert.Equal(t, WaitForRequeueIfCephClusterNotReady, reconcileResult)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("deleted cephcluster with no cleanup policy", func(t *testing.T) {
|
|
|
|
|
cephCluster := &cephv1.CephCluster{
|
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
|
Name: clusterName.Name,
|
|
|
|
|
Namespace: clusterName.Namespace,
|
|
|
|
|
DeletionTimestamp: &metav1.Time{Time: time.Now()},
|
2023-06-19 18:38:32 -06:00
|
|
|
Finalizers: []string{"test"},
|
2021-10-26 13:23:11 -06:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
objects := []runtime.Object{cephCluster}
|
|
|
|
|
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(objects...).Build()
|
|
|
|
|
c, ready, clusterExists, reconcileResult := IsReadyToReconcile(ctx.TODO(), client, clusterName, controllerName)
|
|
|
|
|
assert.NotNil(t, c)
|
|
|
|
|
assert.False(t, ready)
|
|
|
|
|
assert.True(t, clusterExists)
|
|
|
|
|
assert.Equal(t, WaitForRequeueIfCephClusterNotReady, reconcileResult)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("cephcluster with cleanup policy when not deleted", func(t *testing.T) {
|
|
|
|
|
cephCluster := &cephv1.CephCluster{
|
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
|
Name: clusterName.Name,
|
|
|
|
|
Namespace: clusterName.Namespace,
|
|
|
|
|
},
|
|
|
|
|
Spec: cephv1.ClusterSpec{
|
|
|
|
|
CleanupPolicy: cephv1.CleanupPolicySpec{
|
|
|
|
|
Confirmation: cephv1.DeleteDataDirOnHostsConfirmation,
|
|
|
|
|
},
|
2025-03-13 15:24:58 -07:00
|
|
|
},
|
|
|
|
|
}
|
2021-10-26 13:23:11 -06:00
|
|
|
objects := []runtime.Object{cephCluster}
|
|
|
|
|
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(objects...).Build()
|
|
|
|
|
c, ready, clusterExists, _ := IsReadyToReconcile(ctx.TODO(), client, clusterName, controllerName)
|
|
|
|
|
assert.NotNil(t, c)
|
|
|
|
|
assert.False(t, ready)
|
|
|
|
|
assert.True(t, clusterExists)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
t.Run("cephcluster with cleanup policy when deleted", func(t *testing.T) {
|
|
|
|
|
cephCluster := &cephv1.CephCluster{
|
|
|
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
|
|
|
Name: clusterName.Name,
|
|
|
|
|
Namespace: clusterName.Namespace,
|
|
|
|
|
DeletionTimestamp: &metav1.Time{Time: time.Now()},
|
2023-06-19 18:38:32 -06:00
|
|
|
Finalizers: []string{"test"},
|
2021-10-26 13:23:11 -06:00
|
|
|
},
|
|
|
|
|
Spec: cephv1.ClusterSpec{
|
|
|
|
|
CleanupPolicy: cephv1.CleanupPolicySpec{
|
|
|
|
|
Confirmation: cephv1.DeleteDataDirOnHostsConfirmation,
|
|
|
|
|
},
|
2025-03-13 15:24:58 -07:00
|
|
|
},
|
|
|
|
|
}
|
2021-10-26 13:23:11 -06:00
|
|
|
objects := []runtime.Object{cephCluster}
|
|
|
|
|
client := fake.NewClientBuilder().WithScheme(scheme).WithRuntimeObjects(objects...).Build()
|
|
|
|
|
c, ready, clusterExists, _ := IsReadyToReconcile(ctx.TODO(), client, clusterName, controllerName)
|
|
|
|
|
assert.NotNil(t, c)
|
|
|
|
|
assert.False(t, ready)
|
|
|
|
|
assert.False(t, clusterExists)
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-02-07 14:56:24 -07:00
|
|
|
|
|
|
|
|
func TestObcAllowAdditionalConfigFields(t *testing.T) {
|
|
|
|
|
tests := []struct {
|
2025-02-21 18:02:00 -07:00
|
|
|
name string
|
|
|
|
|
additionalConfig string
|
|
|
|
|
shouldAllow []string
|
|
|
|
|
shouldDisallow []string
|
2025-02-07 14:56:24 -07:00
|
|
|
}{
|
2025-03-13 15:24:58 -07:00
|
|
|
{
|
|
|
|
|
"not set", "<notset>",
|
2025-02-07 14:56:24 -07:00
|
|
|
[]string{"maxObjects", "maxSize"}, // default allowlist is unlikely to need changing EVER
|
2025-03-13 15:24:58 -07:00
|
|
|
[]string{"bucketMaxObjects", "bucketMaxSize", "bucketPolicy", "bucketLifecycle", "bucketOwner", "random"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"set to empty", "",
|
2025-02-07 14:56:24 -07:00
|
|
|
[]string{}, // admin can allow no quota options if desired
|
2025-03-13 15:24:58 -07:00
|
|
|
[]string{"maxObjects", "maxSize", "bucketMaxObjects", "bucketMaxSize", "bucketPolicy", "bucketLifecycle", "bucketOwner", "random"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"set to default", "maxObjects,maxSize",
|
2025-02-07 14:56:24 -07:00
|
|
|
[]string{"maxObjects", "maxSize"},
|
2025-03-13 15:24:58 -07:00
|
|
|
[]string{"bucketMaxObjects", "bucketMaxSize", "bucketPolicy", "bucketLifecycle", "bucketOwner", "random"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"all quota fields", "maxObjects,maxSize,bucketMaxObjects,bucketMaxSize",
|
2025-02-07 14:56:24 -07:00
|
|
|
[]string{"maxObjects", "maxSize", "bucketMaxObjects", "bucketMaxSize"},
|
2025-03-13 15:24:58 -07:00
|
|
|
[]string{"bucketPolicy", "bucketLifecycle", "bucketOwner", "random"},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"all fields", "maxObjects,maxSize,bucketMaxObjects,bucketMaxSize,bucketPolicy,bucketLifecycle,bucketOwner",
|
2025-02-07 14:56:24 -07:00
|
|
|
[]string{"maxObjects", "maxSize", "bucketMaxObjects", "bucketMaxSize", "bucketPolicy", "bucketLifecycle", "bucketOwner"},
|
2025-03-13 15:24:58 -07:00
|
|
|
[]string{"random"},
|
|
|
|
|
},
|
2025-02-07 14:56:24 -07:00
|
|
|
// this mechanism doesn't do any field checking - that isn't it's job - it merely handles
|
|
|
|
|
// allow-listing essentially arbitrary config keys
|
2025-03-13 15:24:58 -07:00
|
|
|
{
|
|
|
|
|
"all fields including unknown", "maxObjects,maxSize,bucketMaxObjects,bucketMaxSize,bucketPolicy,bucketLifecycle,bucketOwner,random",
|
2025-02-07 14:56:24 -07:00
|
|
|
[]string{"maxObjects", "maxSize", "bucketMaxObjects", "bucketMaxSize", "bucketPolicy", "bucketLifecycle", "bucketOwner", "random"},
|
2025-03-13 15:24:58 -07:00
|
|
|
[]string{"otherRandom"},
|
|
|
|
|
},
|
2025-02-07 14:56:24 -07:00
|
|
|
}
|
|
|
|
|
for _, tt := range tests {
|
|
|
|
|
t.Run(tt.name, func(t *testing.T) {
|
2025-02-21 18:02:00 -07:00
|
|
|
if tt.additionalConfig != "<notset>" {
|
|
|
|
|
os.Setenv("ROOK_OBC_ALLOW_ADDITIONAL_CONFIG_FIELDS", tt.additionalConfig)
|
|
|
|
|
defer os.Unsetenv("ROOK_OBC_ALLOW_ADDITIONAL_CONFIG_FIELDS")
|
|
|
|
|
}
|
|
|
|
|
SetObcAllowAdditionalConfigFields()
|
2025-02-07 14:56:24 -07:00
|
|
|
for _, toAllow := range tt.shouldAllow {
|
|
|
|
|
assert.True(t, ObcAdditionalConfigKeyIsAllowed(toAllow))
|
|
|
|
|
}
|
|
|
|
|
for _, toDisallow := range tt.shouldDisallow {
|
|
|
|
|
assert.False(t, ObcAdditionalConfigKeyIsAllowed(toDisallow))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|