fix unit test and improve stability in e2e test
This commit is contained in:
parent
1d88009ec4
commit
b3c5b4066c
|
|
@ -208,8 +208,6 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
k8s.update_config(patch_capabilities)
|
k8s.update_config(patch_capabilities)
|
||||||
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"},
|
|
||||||
"Operator does not get in sync")
|
|
||||||
|
|
||||||
# changed security context of postgres container should trigger a rolling update
|
# changed security context of postgres container should trigger a rolling update
|
||||||
k8s.wait_for_pod_failover(replica_nodes, 'spilo-role=master,' + cluster_label)
|
k8s.wait_for_pod_failover(replica_nodes, 'spilo-role=master,' + cluster_label)
|
||||||
|
|
@ -1002,7 +1000,6 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
}
|
}
|
||||||
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
k8s.api.custom_objects_api.patch_namespaced_custom_object(
|
||||||
"acid.zalan.do", "v1", "default", "postgresqls", "acid-minimal-cluster", pg_patch_resources)
|
"acid.zalan.do", "v1", "default", "postgresqls", "acid-minimal-cluster", pg_patch_resources)
|
||||||
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync")
|
|
||||||
|
|
||||||
# wait for switched over
|
# wait for switched over
|
||||||
k8s.wait_for_pod_failover(replica_nodes, 'spilo-role=master,' + cluster_label)
|
k8s.wait_for_pod_failover(replica_nodes, 'spilo-role=master,' + cluster_label)
|
||||||
|
|
@ -1109,7 +1106,6 @@ class EndToEndTestCase(unittest.TestCase):
|
||||||
plural="postgresqls",
|
plural="postgresqls",
|
||||||
name="acid-minimal-cluster",
|
name="acid-minimal-cluster",
|
||||||
body=patch_node_affinity_config)
|
body=patch_node_affinity_config)
|
||||||
self.eventuallyEqual(lambda: k8s.get_operator_state(), {"0": "idle"}, "Operator does not get in sync")
|
|
||||||
|
|
||||||
# node affinity change should cause replica to relocate from replica node to master node due to node affinity requirement
|
# node affinity change should cause replica to relocate from replica node to master node due to node affinity requirement
|
||||||
k8s.wait_for_pod_failover(master_nodes, 'spilo-role=replica,' + cluster_label)
|
k8s.wait_for_pod_failover(master_nodes, 'spilo-role=replica,' + cluster_label)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
||||||
fakeacidv1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/fake"
|
fakeacidv1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/fake"
|
||||||
"github.com/zalando/postgres-operator/pkg/spec"
|
"github.com/zalando/postgres-operator/pkg/spec"
|
||||||
|
"github.com/zalando/postgres-operator/pkg/util"
|
||||||
"github.com/zalando/postgres-operator/pkg/util/config"
|
"github.com/zalando/postgres-operator/pkg/util/config"
|
||||||
"github.com/zalando/postgres-operator/pkg/util/constants"
|
"github.com/zalando/postgres-operator/pkg/util/constants"
|
||||||
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
|
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
|
||||||
|
|
@ -167,8 +168,17 @@ func TestInitAdditionalOwnerRoles(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
cl.initAdditionalOwnerRoles()
|
cl.initAdditionalOwnerRoles()
|
||||||
if !reflect.DeepEqual(cl.pgUsers, expectedUsers) {
|
|
||||||
t.Errorf("%s expected: %#v, got %#v", testName, expectedUsers, cl.pgUsers)
|
for _, additionalOwnerRole := range cl.Config.OpConfig.AdditionalOwnerRoles {
|
||||||
|
expectedPgUser := expectedUsers[additionalOwnerRole]
|
||||||
|
existingPgUser, exists := cl.pgUsers[additionalOwnerRole]
|
||||||
|
if !exists {
|
||||||
|
t.Errorf("%s additional owner role %q not initilaized", testName, additionalOwnerRole)
|
||||||
|
}
|
||||||
|
if !util.IsEqualIgnoreOrder(expectedPgUser.MemberOf, existingPgUser.MemberOf) {
|
||||||
|
t.Errorf("%s unexpected membership of additional owner role %q: expected member of %#v, got member of %#v",
|
||||||
|
testName, additionalOwnerRole, expectedPgUser.MemberOf, existingPgUser.MemberOf)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue