Skip to content

Commit

Permalink
[fix][client] Fix authentication not update after changing the servic…
Browse files Browse the repository at this point in the history
…eUrl (apache#19510)

(cherry picked from commit 0f025f3)
(cherry picked from commit 132abe9)
  • Loading branch information
hangc0276 authored and nicoloboschi committed Feb 28, 2023
1 parent 4a1bf35 commit 465431f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ private void updateServiceUrl(String target,
}

pulsarClient.updateServiceUrl(target);
pulsarClient.reloadLookUp();
currentPulsarServiceUrl = target;
} catch (IOException e) {
log.error("Current Pulsar service is {}, "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void initialize(PulsarClient client) {
}

pulsarClient.updateServiceUrl(serviceUrl);
pulsarClient.reloadLookUp();
currentPulsarServiceUrl = serviceUrl;
currentControlledConfiguration = controlledConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,15 @@ public void testAutoClusterFailoverSwitchWithAuthentication() throws IOException

Awaitility.await().untilAsserted(() ->
Assert.assertEquals(secondary, autoClusterFailover.getServiceUrl()));
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).reloadLookUp();
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateTlsTrustCertsFilePath(secondaryTlsTrustCertsFilePath);
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateAuthentication(secondaryAuthentication);

// primary cluster came back
Mockito.doReturn(true).when(autoClusterFailover).probeAvailable(primary);
Awaitility.await().untilAsserted(() ->
Assert.assertEquals(primary, autoClusterFailover.getServiceUrl()));
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).reloadLookUp();
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateTlsTrustCertsFilePath(primaryTlsTrustCertsFilePath);
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateAuthentication(primaryAuthentication);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public void testControlledClusterFailoverSwitch() throws IOException {

Awaitility.await().untilAsserted(() ->
Assert.assertEquals(backupServiceUrlV1, controlledClusterFailover.getServiceUrl()));
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).reloadLookUp();
Mockito.verify(pulsarClient, Mockito.atLeastOnce()).updateServiceUrl(backupServiceUrlV1);
Mockito.verify(pulsarClient, Mockito.atLeastOnce())
.updateTlsTrustCertsFilePath(tlsTrustCertsFilePathV1);
Expand Down

0 comments on commit 465431f

Please sign in to comment.