This is an automated email from the ASF dual-hosted git repository.

Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new c8b8ccb801 fix(kubernetes-controller): isolate dubbo reconciler test 
cache keys (#7277)
c8b8ccb801 is described below

commit c8b8ccb801e0a47eb34dd52f30d33c0f7611d20c
Author: shown <[email protected]>
AuthorDate: Fri Sep 25 11:34:04 2026 +0800

    fix(kubernetes-controller): isolate dubbo reconciler test cache keys (#7277)
---
 .../org/apache/shenyu/k8s/DubboReconcilerTest.java | 44 +++++++++++++---------
 1 file changed, 27 insertions(+), 17 deletions(-)

diff --git 
a/shenyu-kubernetes-controller/src/test/java/org/apache/shenyu/k8s/DubboReconcilerTest.java
 
b/shenyu-kubernetes-controller/src/test/java/org/apache/shenyu/k8s/DubboReconcilerTest.java
index f033bb3477..74639e6166 100644
--- 
a/shenyu-kubernetes-controller/src/test/java/org/apache/shenyu/k8s/DubboReconcilerTest.java
+++ 
b/shenyu-kubernetes-controller/src/test/java/org/apache/shenyu/k8s/DubboReconcilerTest.java
@@ -55,6 +55,16 @@ import static org.mockito.Mockito.when;
  */
 public final class DubboReconcilerTest {
 
+    private static final String NAMESPACE = "dubboReconcilerNamespace";
+
+    private static final String INGRESS_NAME = "dubboReconcilerIngress";
+
+    private static final String SERVICE_NAME = "dubboReconcilerService";
+
+    private static final String ZOOKEEPER_SERVICE = 
"dubboReconcilerZookeeperService";
+
+    private static final String METADATA_SERVICE = 
"dubboReconcilerMetadataService";
+
     private SharedIndexInformer<V1Ingress> ingressInformer;
 
     private SharedIndexInformer<V1Secret> secretInformer;
@@ -85,16 +95,16 @@ public final class DubboReconcilerTest {
         final V1IngressRule mockedRule = new 
V1IngressRuleBuilder().withNewHttp().withPaths(
                         new V1HTTPIngressPathBuilder().withPath("/**")
                                 .withNewBackend()
-                                    
.withNewService().withName("testService").withNewPort().withNumber(20888).endPort().endService()
+                                    
.withNewService().withName(SERVICE_NAME).withNewPort().withNumber(20888).endPort().endService()
                                 .endBackend().build())
                 .endHttp().build();
         Map<String, String> annotations = new HashMap<>();
         annotations.put("kubernetes.io/ingress.class", "shenyu");
         annotations.put("shenyu.apache.org/plugin-dubbo-enabled", "true");
-        annotations.put("shenyu.apache.org/zookeeper-register-address", 
"zookeeper://zookeeperService:2181");
+        annotations.put("shenyu.apache.org/zookeeper-register-address", 
"zookeeper://" + ZOOKEEPER_SERVICE + ":2181");
         annotations.put("shenyu.apache.org/upstreams-protocol", 
"dubbo://,dubbo://");
         Map<String, String> labels = new HashMap<>();
-        labels.put("shenyu.apache.org/metadata-labels-1", 
"dubboFindIdService");
+        labels.put("shenyu.apache.org/metadata-labels-1", METADATA_SERVICE);
         Map<String, String> labelsAnnotations = new HashMap<>();
         labelsAnnotations.put("kubernetes.io/ingress.class", "shenyu");
         labelsAnnotations.put("shenyu.apache.org/plugin-dubbo-enabled", 
"true");
@@ -106,30 +116,30 @@ public final class DubboReconcilerTest {
         labelsAnnotations.put("shenyu.apache.org/plugin-dubbo-params-type", 
"java.lang.String");
         labelsAnnotations.put("shenyu.apache.org/plugin-dubbo-rpc-expand", 
"{\"group\":\"\",\"version\":\"v0.0.2\",\"loadbalance\":\"random\","
                     + 
"\"retries\":2,\"timeout\":10000,\"url\":\"\",\"sent\":false,\"cluster\":\"failover\",\"protocol\":\"dubbo\"}");
-        V1Service dubboFindIdService = new 
V1ServiceBuilder().withNewMetadata().withName("dubboFindIdService").withNamespace("mockedNamespace").withAnnotations(labelsAnnotations).endMetadata()
+        V1Service dubboFindIdService = new 
V1ServiceBuilder().withNewMetadata().withName(METADATA_SERVICE).withNamespace(NAMESPACE).withAnnotations(labelsAnnotations).endMetadata()
                 .withNewSpec().endSpec()
                 .withKind("Service").build();
 
-        V1Ingress mockedIngress = new 
V1IngressBuilder().withNewMetadata().withLabels(labels).withName("mockedIngress").withNamespace("mockedNamespace").withAnnotations(annotations).endMetadata()
+        V1Ingress mockedIngress = new 
V1IngressBuilder().withNewMetadata().withLabels(labels).withName(INGRESS_NAME).withNamespace(NAMESPACE).withAnnotations(annotations).endMetadata()
                 .withNewSpec().withRules(mockedRule).endSpec()
                 .withKind("Ingress").build();
 
-        
when(ingressIndexer.getByKey("mockedNamespace/mockedIngress")).thenReturn(mockedIngress);
-        
when(serviceIndexer.getByKey("mockedNamespace/dubboFindIdService")).thenReturn(dubboFindIdService);
+        when(ingressIndexer.getByKey(NAMESPACE + "/" + 
INGRESS_NAME)).thenReturn(mockedIngress);
+        when(serviceIndexer.getByKey(NAMESPACE + "/" + 
METADATA_SERVICE)).thenReturn(dubboFindIdService);
         when(serviceInformer.getIndexer()).thenReturn(serviceIndexer);
         when(ingressInformer.getIndexer()).thenReturn(ingressIndexer);
 
         //mock endpointsInformer
         Indexer<V1Endpoints> endpointsIndexer = mock(Indexer.class);
         V1Endpoints mockedEndpoints = new 
V1EndpointsBuilder().withKind("Endpoints")
-                
.withNewMetadata().withNamespace("mockedNamespace").withName("testService").endMetadata()
+                
.withNewMetadata().withNamespace(NAMESPACE).withName(SERVICE_NAME).endMetadata()
                 .withSubsets(new V1EndpointSubsetBuilder().withAddresses(new 
V1EndpointAddress().ip("127.0.0.1")).build())
                 .build();
-        V1Endpoints zookeeperEndpoints = new 
V1EndpointsBuilder().withNewMetadata().withName("zookeeperService").withNamespace("mockedNamespace").endMetadata()
+        V1Endpoints zookeeperEndpoints = new 
V1EndpointsBuilder().withNewMetadata().withName(ZOOKEEPER_SERVICE).withNamespace(NAMESPACE).endMetadata()
                 .withSubsets(new V1EndpointSubsetBuilder().withAddresses(new 
V1EndpointAddress().ip("127.0.0.1")).build())
                 .build();
-        
when(endpointsIndexer.getByKey("mockedNamespace/testService")).thenReturn(mockedEndpoints);
-        
when(endpointsIndexer.getByKey("mockedNamespace/zookeeperService")).thenReturn(zookeeperEndpoints);
+        when(endpointsIndexer.getByKey(NAMESPACE + "/" + 
SERVICE_NAME)).thenReturn(mockedEndpoints);
+        when(endpointsIndexer.getByKey(NAMESPACE + "/" + 
ZOOKEEPER_SERVICE)).thenReturn(zookeeperEndpoints);
         when(endpointsInformer.getIndexer()).thenReturn(endpointsIndexer);
 
         IngressParser ingressParser = new IngressParser(serviceInformer, 
endpointsInformer);
@@ -144,7 +154,7 @@ public final class DubboReconcilerTest {
      */
     @Test
     public void testReconcile() {
-        Result result = ingressReconciler.reconcile(new 
Request("mockedNamespace", "mockedIngress"));
+        Result result = ingressReconciler.reconcile(new Request(NAMESPACE, 
INGRESS_NAME));
         Assertions.assertEquals(new Result(false), result);
         verify(shenyuCacheRepository).saveOrUpdateSelectorData(any());
         verify(shenyuCacheRepository).saveOrUpdateRuleData(any());
@@ -156,14 +166,14 @@ public final class DubboReconcilerTest {
         Map<String, String> annotations = new HashMap<>();
         annotations.put("kubernetes.io/ingress.class", "shenyu");
         annotations.put("shenyu.apache.org/plugin-dubbo-enabled", "true");
-        annotations.put("shenyu.apache.org/zookeeper-register-address", 
"zookeeper://zookeeperService:2181");
+        annotations.put("shenyu.apache.org/zookeeper-register-address", 
"zookeeper://" + ZOOKEEPER_SERVICE + ":2181");
         annotations.put("shenyu.apache.org/upstreams-protocol", 
"dubbo://,dubbo://");
         Map<String, String> labels = new HashMap<>();
-        labels.put("shenyu.apache.org/metadata-labels-1", 
"dubboFindIdService");
+        labels.put("shenyu.apache.org/metadata-labels-1", METADATA_SERVICE);
 
         V1Ingress ingress = new V1IngressBuilder().withNewMetadata()
-                .withName("mockedIngress")
-                .withNamespace("mockedNamespace")
+                .withName(INGRESS_NAME)
+                .withNamespace(NAMESPACE)
                 .withAnnotations(annotations)
                 .withLabels(labels)
                 .endMetadata()
@@ -172,7 +182,7 @@ public final class DubboReconcilerTest {
                         .withNewHttp()
                         .withPaths(new 
V1HTTPIngressPathBuilder().withPath("/**")
                                 .withNewBackend()
-                                
.withNewService().withName("testService").withNewPort().withNumber(20888).endPort().endService()
+                                
.withNewService().withName(SERVICE_NAME).withNewPort().withNumber(20888).endPort().endService()
                                 .endBackend().build())
                         .endHttp()
                         .build())

Reply via email to