Skip to content

Fix isSelf address.#3051

Merged
wu-sheng merged 3 commits intoapache:masterfrom
wayilau:fix-cluster-etcd
Jul 11, 2019
Merged

Fix isSelf address.#3051
wu-sheng merged 3 commits intoapache:masterfrom
wayilau:fix-cluster-etcd

Conversation

@wayilau
Copy link
Copy Markdown
Member

@wayilau wayilau commented Jul 11, 2019

Please answer these questions before submitting pull request


Bug fix

  • Bug description.

@wu-sheng wu-sheng added this to the 6.3.0 milestone Jul 11, 2019
@wu-sheng wu-sheng added bug Something isn't working and you are sure it's a bug! backend OAP backend related. plugin Plugin for agent or collector. Be used to extend the capabilities of default implementor. labels Jul 11, 2019
@wu-sheng
Copy link
Copy Markdown
Member

We are waiting for Apache Jenkins restore.

@rainbend
Copy link
Copy Markdown
Member

Hi All

Should a base class be abstracted to cover the necessary test.

Taking ClusterRegister#registerRemote as an example, various plugins have different implementations.

ps: I don't know if I described it clearly

case 1: NacosCoordinatorTest

    @Test
    public void queryRemoteNodes() throws NacosException {
        registerSelfRemote();
        List<Instance> instances = mockInstance();
        when(namingService.selectInstances(anyString(), anyBoolean())).thenReturn(instances);
        List<RemoteInstance> remoteInstances = coordinator.queryRemoteNodes();
        assertEquals(2, remoteInstances.size());

        RemoteInstance selfInstance = remoteInstances.get(0);
        validate(selfRemoteAddress, selfInstance);

        RemoteInstance notSelfInstance = remoteInstances.get(1);
        validate(remoteAddress, notSelfInstance);
    }

case 2: ZookeeperCoordinatorTest

    @Test
    public void queryRemoteNodes() {
    }

case 3: EtcdCoordinatorTest

    @Test
    public void queryRemoteNodes() {
        registerSelfRemote();

        EtcdKeysResponse.EtcdNode node = PowerMockito.mock(EtcdKeysResponse.EtcdNode.class);
        EtcdKeysResponse.EtcdNode node1 = PowerMockito.mock(EtcdKeysResponse.EtcdNode.class);

        when(response.getNode()).thenReturn(node);
        list = new ArrayList<>();
        List list1 = Mockito.spy(list);
        list1.add(node1);
        when(node.getNodes()).thenReturn(list1);
        when(node1.getValue()).thenReturn("{\"serviceId\":\"my-service\",\"host\":\"10.0.0.2\",\"port\":1001}");
        List<RemoteInstance> remoteInstances = coordinator.queryRemoteNodes();
        assertEquals(1, remoteInstances.size());

        RemoteInstance selfInstance = remoteInstances.get(0);
        velidate(selfRemoteAddress, selfInstance);
    }

@wu-sheng
Copy link
Copy Markdown
Member

/run e2e

@wu-sheng
Copy link
Copy Markdown
Member

@Arugal we are welcome test enhancement. You could send a pull request to do that

@wu-sheng wu-sheng merged commit 52b674e into apache:master Jul 11, 2019
@wayilau wayilau deleted the fix-cluster-etcd branch July 12, 2019 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend OAP backend related. bug Something isn't working and you are sure it's a bug! plugin Plugin for agent or collector. Be used to extend the capabilities of default implementor.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants