Skip to content

Commit

Permalink
Fix testPersistAddressAfterCOBrokerRestart
Browse files Browse the repository at this point in the history
  • Loading branch information
michalxo committed Oct 17, 2024
1 parent ae111bf commit 4af414e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
11 changes: 6 additions & 5 deletions operator-suite/src/main/java/io/brokerqe/claire/KubeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,15 @@ public Pod waitForPodReload(String namespace, Pod pod, String podName, long maxT
});

for (Pod podTmp : listPodsByPrefixName(namespace, podName)) {
if (podTmp.getMetadata().getUid().equals(originalUid)) {
waitUntilPodIsDeleted(namespace, podTmp);
}
if (!podTmp.getMetadata().getUid().equals(originalUid)) {
this.waitUntilPodIsReady(namespace, podTmp);
LOGGER.trace("[{}] Returning reloaded pod {}", namespace, podName);
return getPod(namespace, podTmp.getMetadata().getName());
waitUntilPodIsReady(namespace, podTmp);
}
}
LOGGER.error("[{}] Reloaded pod {} has not been found!", namespace, podName);
return null;
LOGGER.debug("[{}] Returning reloaded pod {}", namespace, podName);
return getFirstPodByPrefixName(namespace, podName);
}

public String executeCommandInPod(Pod pod, String cmd, long timeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.brokerqe.claire.ArtemisConstants;
import io.brokerqe.claire.Constants;
import io.brokerqe.claire.KubeClient;
import io.brokerqe.claire.TestUtils;
import io.fabric8.openshift.api.model.Route;
import org.json.JSONArray;
import org.json.JSONObject;
Expand All @@ -19,7 +21,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
Expand Down Expand Up @@ -59,9 +60,7 @@ private String getBasicAuth() {
}

private String performJmxCall(String host, String jmxPath) throws IOException {
URL url = new URL("http://" + host + jmxPath);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("GET");
HttpURLConnection con = (HttpURLConnection) TestUtils.makeHttpRequest("http://" + host + jmxPath, Constants.GET);
con.setRequestProperty("Authorization", getBasicAuth());
BufferedReader in = new BufferedReader(
new InputStreamReader(con.getInputStream()));
Expand All @@ -75,7 +74,7 @@ private String performJmxCall(String host, String jmxPath) throws IOException {
return content.toString();
}

private List<String> getAllAdresses(String host) throws IOException {
private List<String> getAllAddresses(String host) throws IOException {
String jmxPath = JMX_CALL_BASE + "/AddressNames";
String content = performJmxCall(host, jmxPath);
JSONObject json = new JSONObject(content);
Expand Down Expand Up @@ -125,7 +124,7 @@ public List<AddressData> getAllAddressesQueues(String deployName, String routing
try {
Route route = getRoute(deployName, pod);
String host = route.getSpec().getHost();
List<String> addresses = getAllAdresses(host);
List<String> addresses = getAllAddresses(host);
for (String address: addresses) {
for (String queue: getQueueNames(host, address)) {
AddressData addressData = new AddressData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ void persistAddressAfterCOBrokerRestart() {
LOGGER.info("[{}] Getting info from {} with uid {}", testNamespace, brokerPod.getMetadata().getName(), brokerPod.getMetadata().getUid());
List<AddressData> allAddresses = jmx.getAllAddressesQueues(brokerName, ArtemisConstants.ROUTING_TYPE_ANYCAST, 0);
verifyAddresses(allAddresses, myAddress);

getClient().reloadPodWithWait(testNamespace, operatorPod, operatorName);
getClient().reloadPodWithWait(testNamespace, brokerPod, brokerName);
getClient().deletePod(testNamespace, brokerPod, false);
ResourceManager.waitForBrokerDeployment(testNamespace, broker, true, brokerPod);

brokerPod = getClient().getFirstPodByPrefixName(testNamespace, brokerName);
LOGGER.info("[{}] Getting info from {} with uid {}", testNamespace, brokerPod.getMetadata().getName(), brokerPod.getMetadata().getUid());
Expand All @@ -83,7 +85,7 @@ void persistAddressAfterCOBrokerRestart() {
return commandOutput.contains(myAddress.getSpec().getAddressName());
});

TestUtils.waitFor("[JMX] Addresses to show up in artemis address call", Constants.DURATION_5_SECONDS, Constants.DURATION_30_SECONDS, () -> {
TestUtils.waitFor("[JMX] Updated addresses to show up in artemis address call", Constants.DURATION_5_SECONDS, Constants.DURATION_30_SECONDS, () -> {
List<AddressData> updatedAddressesTmp = new ArrayList<>();
try {
updatedAddressesTmp = jmx.getAllAddressesQueues(brokerName, ArtemisConstants.ROUTING_TYPE_ANYCAST, 0);
Expand Down

0 comments on commit 4af414e

Please sign in to comment.