Skip to content

Commit

Permalink
Fix test issues
Browse files Browse the repository at this point in the history
Signed-off-by: clyang82 <[email protected]>
  • Loading branch information
clyang82 committed Dec 2, 2024
1 parent 34f3563 commit 9a1fdd9
Show file tree
Hide file tree
Showing 12 changed files with 9,372 additions and 7,865 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,8 @@ func (k *strimziTransporter) getConnCredentailByCluster() (*transport.KafkaConfi
}
credential := &transport.KafkaConfig{
ClusterID: clusterIdentity,
BootstrapServer: *kafkaCluster.Status.Listeners[1].BootstrapServers,
CACert: base64.StdEncoding.EncodeToString([]byte(kafkaCluster.Status.Listeners[1].Certificates[0])),
BootstrapServer: *kafkaCluster.Status.Listeners[0].BootstrapServers,
CACert: base64.StdEncoding.EncodeToString([]byte(kafkaCluster.Status.Listeners[0].Certificates[0])),
}
return credential, nil
}
Expand Down Expand Up @@ -892,15 +892,6 @@ func (k *strimziTransporter) setImagePullSecret(mgh *operatorv1alpha4.Multiclust
},
},
}
desiredKafkaSpec.Zookeeper.Template = &kafkav1beta2.KafkaSpecZookeeperTemplate{
Pod: &kafkav1beta2.KafkaSpecZookeeperTemplatePod{
ImagePullSecrets: []kafkav1beta2.KafkaSpecZookeeperTemplatePodImagePullSecretsElem{
{
Name: &mgh.Spec.ImagePullSecret,
},
},
},
}
// marshal to json
existingKafkaJson, _ := json.Marshal(existingKafkaSpec)
desiredKafkaJson, _ := json.Marshal(desiredKafkaSpec)
Expand Down
4 changes: 2 additions & 2 deletions samples/config/confluent_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ func GetConfluentConfigMapByUser(c client.Client, namespace, clusterName, userNa
cm := config.GetBasicConfigMap()
for _, condition := range kafkaCluster.Status.Conditions {
if *condition.Type == "Ready" && *condition.Status == "True" {
clusterCaCert := kafkaCluster.Status.Listeners[1].Certificates[0]
_ = cm.SetKey("bootstrap.servers", *kafkaCluster.Status.Listeners[1].BootstrapServers)
clusterCaCert := kafkaCluster.Status.Listeners[0].Certificates[0]
_ = cm.SetKey("bootstrap.servers", *kafkaCluster.Status.Listeners[0].BootstrapServers)
_ = cm.SetKey("security.protocol", "ssl")
_ = cm.SetKey("ssl.ca.pem", clusterCaCert)
_ = cm.SetKey("ssl.certificate.pem", clientCert)
Expand Down
4 changes: 2 additions & 2 deletions samples/config/sarama_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func GetSaramaConfigFromKafkaUser() (string, *sarama.Config, error) {
return "", nil, err
}

bootstrapServer := *kafkaCluster.Status.Listeners[1].BootstrapServers
bootstrapServer := *kafkaCluster.Status.Listeners[0].BootstrapServers

// Load CA cert
caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM([]byte(kafkaCluster.Status.Listeners[1].Certificates[0]))
caCertPool.AppendCertsFromPEM([]byte(kafkaCluster.Status.Listeners[0].Certificates[0]))
tlsConfig.RootCAs = caCertPool

kafkaUserSecret := &corev1.Secret{}
Expand Down
10 changes: 2 additions & 8 deletions test/integration/operator/controllers/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ var _ = Describe("manager", Ordered, func() {
initOption = config.ControllerOption{
Manager: runtimeManager,
MulticlusterGlobalHub: mgh,
OperatorConfig: &config.OperatorConfig{},
}
// transport
err := CreateTestSecretTransport(runtimeClient, mgh.Namespace)
Expand All @@ -80,14 +81,7 @@ var _ = Describe("manager", Ordered, func() {
})

It("should generate the manager resources", func() {
_, err := reconciler.Reconcile(ctx, reconcile.Request{
NamespacedName: types.NamespacedName{
Namespace: mgh.Namespace,
Name: mgh.Name,
},
})
Expect(err).To(Succeed())

var err error
// deployment
Eventually(func() error {
deployment := &appsv1.Deployment{}
Expand Down
21 changes: 4 additions & 17 deletions test/integration/operator/controllers/transporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,13 +323,6 @@ var _ = Describe("transporter", Ordered, func() {
Expect(string(kafka.Spec.Kafka.Resources.Requests.Raw)).To(Equal(`{"cpu":"1m","memory":"1Mi"}`))
Expect(string(kafka.Spec.Kafka.Resources.Limits.Raw)).To(Equal(`{"cpu":"2m","memory":"2Mi"}`))

Expect(kafka.Spec.Zookeeper.Template.Pod.Affinity.NodeAffinity).NotTo(BeNil())
Expect(kafka.Spec.Zookeeper.Template.Pod.Tolerations).NotTo(BeEmpty())
Expect(kafka.Spec.Zookeeper.Template.Pod.ImagePullSecrets).NotTo(BeEmpty())

Expect(string(kafka.Spec.Zookeeper.Resources.Requests.Raw)).To(Equal(`{"cpu":"1m","memory":"1Mi"}`))
Expect(string(kafka.Spec.Zookeeper.Resources.Limits.Raw)).To(Equal(`{"cpu":"2m","memory":"2Mi"}`))

Expect(kafka.Spec.EntityOperator.Template.Pod.Affinity.NodeAffinity).NotTo(BeNil())
Expect(kafka.Spec.EntityOperator.Template.Pod.Tolerations).NotTo(BeEmpty())
Expect(kafka.Spec.EntityOperator.Template.Pod.ImagePullSecrets).NotTo(BeEmpty())
Expand Down Expand Up @@ -429,7 +422,7 @@ var _ = Describe("transporter", Ordered, func() {
})

func UpdateKafkaClusterReady(c client.Client, ns string) error {
kafkaVersion := "3.5.0"
kafkaVersion := "3.8.0"
kafkaClusterName := "kafka"
globalHubKafkaUser := "global-hub-kafka-user"
clientCa := "kafka-clients-ca-cert"
Expand All @@ -449,9 +442,9 @@ func UpdateKafkaClusterReady(c client.Client, ns string) error {
Kafka: kafkav1beta2.KafkaSpecKafka{
Listeners: []kafkav1beta2.KafkaSpecKafkaListenersElem{
{
Name: "plain",
Port: 9092,
Type: "internal",
Name: "tls",
Port: 9093,
Type: "nodeport",
},
},
Config: &apiextensions.JSON{Raw: []byte(`{
Expand All @@ -463,9 +456,6 @@ func UpdateKafkaClusterReady(c client.Client, ns string) error {
Status: &kafkav1beta2.KafkaStatus{
ClusterId: &statusClusterId,
Listeners: []kafkav1beta2.KafkaStatusListenersElem{
{
BootstrapServers: &bootServer,
},
{
BootstrapServers: &bootServer,
Certificates: []string{
Expand Down Expand Up @@ -501,9 +491,6 @@ func UpdateKafkaClusterReady(c client.Client, ns string) error {
}
existkafkaCluster.Status = &kafkav1beta2.KafkaStatus{
Listeners: []kafkav1beta2.KafkaStatusListenersElem{
{
BootstrapServers: &bootServer,
},
{
BootstrapServers: &bootServer,
Certificates: []string{
Expand Down
Loading

0 comments on commit 9a1fdd9

Please sign in to comment.