mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-01 07:15:18 +02:00
* Enable connection pooler for replica * Refactor code for connection pooler - Move all the relevant code to a separate file - Move all the related tests to a separate file - Avoid using cluster where not required - Simplify the logic in sync and other methods - Cleanup of duplicated or unused code * Fix labels for the replica pods * Update deleteConnectionPooler to include role * Adding test cases and other changes - Fix unit test and delete secret when required only - Make sure we use empty fresh cluster for every test case. * enhance e2e test * Disable pooler in complete manifest as this is source for e2e too an creates unnecessary pooler setups. Co-authored-by: Rafia Sabih <rafia.sabih@zalando.de> Co-authored-by: Jan Mussler <janm81@gmail.com>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package cluster
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"context"
|
|
|
|
appsv1 "k8s.io/api/apps/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
|
|
"k8s.io/apimachinery/pkg/labels"
|
|
|
|
"k8s.io/client-go/kubernetes/fake"
|
|
)
|
|
|
|
func TestFakeClient(t *testing.T) {
|
|
clientSet := fake.NewSimpleClientset()
|
|
namespace := "default"
|
|
|
|
l := labels.Set(map[string]string{
|
|
"application": "spilo",
|
|
})
|
|
|
|
deployment := &appsv1.Deployment{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: "my-deployment1",
|
|
Namespace: namespace,
|
|
Labels: l,
|
|
},
|
|
}
|
|
|
|
clientSet.AppsV1().Deployments(namespace).Create(context.TODO(), deployment, metav1.CreateOptions{})
|
|
|
|
deployment2, _ := clientSet.AppsV1().Deployments(namespace).Get(context.TODO(), "my-deployment1", metav1.GetOptions{})
|
|
|
|
if deployment.ObjectMeta.Name != deployment2.ObjectMeta.Name {
|
|
t.Errorf("Deployments are not equal")
|
|
}
|
|
|
|
deployments, _ := clientSet.AppsV1().Deployments(namespace).List(context.TODO(), metav1.ListOptions{LabelSelector: "application=spilo"})
|
|
|
|
if len(deployments.Items) != 1 {
|
|
t.Errorf("Label search does not work")
|
|
}
|
|
}
|