Add unit test
This commit is contained in:
parent
6aa989020b
commit
8cb46cf37b
|
|
@ -28,19 +28,46 @@ var eventRecorder = record.NewFakeRecorder(1)
|
||||||
var cl = New(
|
var cl = New(
|
||||||
Config{
|
Config{
|
||||||
OpConfig: config.Config{
|
OpConfig: config.Config{
|
||||||
|
PodManagementPolicy: "ordered_ready",
|
||||||
ProtectedRoles: []string{"admin"},
|
ProtectedRoles: []string{"admin"},
|
||||||
Auth: config.Auth{
|
Auth: config.Auth{
|
||||||
SuperUsername: superUserName,
|
SuperUsername: superUserName,
|
||||||
ReplicationUsername: replicationUserName,
|
ReplicationUsername: replicationUserName,
|
||||||
},
|
},
|
||||||
|
StatefulsetPropagateAnnotations: []string{"downscaler/*"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
k8sutil.NewMockKubernetesClient(),
|
k8sutil.NewMockKubernetesClient(),
|
||||||
acidv1.Postgresql{ObjectMeta: metav1.ObjectMeta{Name: "acid-test", Namespace: "test"}},
|
acidv1.Postgresql{ObjectMeta: metav1.ObjectMeta{Name: "acid-test", Namespace: "test", Annotations: map[string]string{"downscaler/downtime_replicas": "0"}}},
|
||||||
logger,
|
logger,
|
||||||
eventRecorder,
|
eventRecorder,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestStatefulSetAnnotations(t *testing.T) {
|
||||||
|
testName := "CheckStatefulsetAnnotations"
|
||||||
|
spec := acidv1.PostgresSpec{
|
||||||
|
TeamID: "myapp", NumberOfInstances: 1,
|
||||||
|
Resources: acidv1.Resources{
|
||||||
|
ResourceRequests: acidv1.ResourceDescription{CPU: "1", Memory: "10"},
|
||||||
|
ResourceLimits: acidv1.ResourceDescription{CPU: "1", Memory: "10"},
|
||||||
|
},
|
||||||
|
Volume: acidv1.Volume{
|
||||||
|
Size: "1G",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
ss, err := cl.generateStatefulSet(&spec)
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("in %s no statefulset created %v", testName, err)
|
||||||
|
}
|
||||||
|
if ss != nil {
|
||||||
|
annotation := ss.ObjectMeta.GetAnnotations()
|
||||||
|
if _, ok := annotation["downscaler/downtime_replicas"]; !ok {
|
||||||
|
t.Errorf("in %s respective annotation not found on sts", testName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func TestInitRobotUsers(t *testing.T) {
|
func TestInitRobotUsers(t *testing.T) {
|
||||||
testName := "TestInitRobotUsers"
|
testName := "TestInitRobotUsers"
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue