Skip to content

Commit

Permalink
Mirror federation initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
michalxo committed Aug 14, 2024
1 parent e56e3db commit 03ba5a8
Show file tree
Hide file tree
Showing 30 changed files with 1,202 additions and 84 deletions.
1 change: 1 addition & 0 deletions common/src/main/java/io/brokerqe/claire/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public interface Constants {
String EV_DUMP_ENABLED = "DUMP_ENABLED";
String EV_DUMP_LOCATION = "DUMP_LOCATION";
String EV_DUMP_FORMAT = "DUMP_FORMAT";
String EV_TEARDOWN = "TEARDOWN_ENV";
String EV_CLUSTER_OPERATOR_MANAGED = "CLUSTER_OPERATOR_MANAGED";
String EV_COLLECT_TEST_DATA = "COLLECT_TEST_DATA";
String EV_JDBC_DATA = "JDBC_DATA";
Expand Down
1 change: 1 addition & 0 deletions common/src/main/java/io/brokerqe/claire/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public String getCertificatesLocation() {
}
public abstract String getKeycloakVersion();
public abstract boolean isCollectTestData();
public abstract boolean isTeardownEnv();
public abstract int getCustomExtraDelay();
public abstract void setupDatabase();

Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/io/brokerqe/claire/TestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static long waitFor(String description, long pollIntervalMs, long timeout
}

public static long waitFor(String description, long pollIntervalMs, long timeoutMs, BooleanSupplier ready, Runnable onTimeout) {
LOGGER.debug("Waiting for {}", description);
LOGGER.debug("[" + (char) 27 + "[34m" + "WAIT" + (char) 27 + "[0m] {}", description);
long deadline = System.currentTimeMillis() + timeoutMs + Environment.get().getCustomExtraDelay();

String exceptionMessage = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public interface MessagingClient {
int receiveMessages();
void subscribe();
void unsubscribe();
int receiveMessages(long duration);
Object getSentMessages();
Object getReceivedMessages();
boolean compareMessages();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ public enum ArtemisCommand {
QUEUE_CREATE("queue create"),
QUEUE_DELETE("queue delete"),
QUEUE_STAT("queue stat"),
PERF_CLIENT("perf client");
// BROWSE,
PERF_CLIENT("perf client"),
BROWSE_CLIENT("browser");
// DATA,
// TRANSFER;


private final String command;

ArtemisCommand(String command) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ private Object parseOutput(String cmdOutput) {
case PERF_CLIENT -> {
return parsePerfClientOutput(cmdOutput);
}
case BROWSE_CLIENT -> {
return parseBrowseCommand(cmdOutput);
}

}
return null;
Expand Down Expand Up @@ -175,4 +178,24 @@ private static Map<String, String> parsePerfClientOutput(String cmdOutput) {
return data;
}

private static Map<Integer, String> parseBrowseCommand(String cmdOutput) {
List<String> lines = List.of(cmdOutput.split("\n"));
Map<Integer, String> data = new HashMap<>();
int msgCounter = 0;
for (String line : lines) {
if (line.contains("browsing ")) {
String msgContent = line.substring(line.indexOf("browsing") + 9);
data.put(msgCounter, msgContent);
msgCounter++;
} else if (line.contains("browsed:")) {
String totalBrowsedMsgs = line.substring(line.indexOf("browsed:") + 9, line.indexOf(" messages"));
data.put(-1, totalBrowsedMsgs);
}
}
if (Integer.parseInt(data.get(-1)) != msgCounter) {
LOGGER.warn("Error while browsing messages! Message count does not equals number of browsed messages!");
}
return data;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,19 @@ public int sendMessages() {

@Override
public int receiveMessages() {
return receiveMessages(Constants.DURATION_3_MINUTES);
}

@Override
public int receiveMessages(long duration) {
if (subscriberExecutor != null) {
// executed client on background
return getSubscribedMessages();
} else {
// executed client on foreground
String cmdOutput;
String[] command = constructClientCommand(CONSUMER);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(Constants.DURATION_3_MINUTES, command);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(duration, command);
LOGGER.debug("[{}] {}", deployableClient.getContainerName(), cmdOutput);
return parseMessageCount(cmdOutput, CONSUMER);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,19 @@ private String[] constructClientCommand(String clientType, Map<String, String> c

@Override
public int receiveMessages() {
return receiveMessages(Constants.DURATION_3_MINUTES);
}

@Override
public int receiveMessages(long duration) {
if (subscriberExecWatch != null) {
// executed client on background
return getSubscribedMessages();
} else {
// executed client on foreground
String cmdOutput;
String[] command = constructClientCommand(MessagingClient.RECEIVER, receiverOptions);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(Constants.DURATION_3_MINUTES, command);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(duration, command);
LOGGER.debug("[{}][RX] \n{}", deployableClient.getContainerName(), cmdOutput);
this.receivedMessages = parseMessages(cmdOutput);
return receivedMessages.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ private String[] constructClientCommand(String clientType, Map<String, String> c

@Override
public int receiveMessages() {
return receiveMessages(Constants.DURATION_3_MINUTES);
}

@Override
public int receiveMessages(long duration) {
if (subscriberExecWatch != null) {
// executed client on background
return getSubscribedMessages();
} else {
// executed client on foreground
String cmdOutput;
String[] command = constructClientCommand(MessagingClient.RECEIVER, receiverOptions);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(Constants.DURATION_3_MINUTES, command);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(duration, command);
LOGGER.debug("[{}][RX] \n{}", deployableClient.getContainerName(), cmdOutput);
this.receivedMessages = parseMessages(cmdOutput);
return receivedMessages.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,19 @@ private String[] constructClientCommand(String clientType, Map<String, String> c

@Override
public int receiveMessages() {
return receiveMessages(Constants.DURATION_3_MINUTES);
}

@Override
public int receiveMessages(long duration) {
if (subscriberExecWatch != null) {
// executed client on background
return getSubscribedMessages();
} else {
// executed client on foreground
String cmdOutput;
String[] command = constructClientCommand(MessagingClient.RECEIVER, receiverOptions);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(Constants.DURATION_3_MINUTES, command);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(duration, command);
LOGGER.debug("[{}][RX] \n{}", deployableClient.getContainerName(), cmdOutput);
this.receivedMessages = parseMessages(cmdOutput);
return receivedMessages.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,19 @@ private String[] constructClientCommand(String clientType, Map<String, String> c

@Override
public int receiveMessages() {
return receiveMessages(Constants.DURATION_3_MINUTES);
}

@Override
public int receiveMessages(long duration) {
if (subscriberExecWatch != null) {
// executed client on background
return getSubscribedMessages();
} else {
// executed client on foreground
String cmdOutput;
String[] command = constructClientCommand(MessagingClient.RECEIVER, receiverOptions);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(Constants.DURATION_3_MINUTES, command);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(duration, command);
LOGGER.debug("[{}][RX] \n{}", deployableClient.getContainerName(), cmdOutput);
this.receivedMessages = parseMessages(cmdOutput);
return receivedMessages.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ public int sendMessages() {

@Override
public int receiveMessages() {
return receiveMessages(Constants.DURATION_3_MINUTES);
}

public int receiveMessages(long duration) {
if (subscriberExecWatch != null) {
// executed client on background
return getSubscribedMessages();
Expand All @@ -111,7 +115,7 @@ public int receiveMessages() {
String cmdOutput;
String[] command = constructClientCommand(MessagingClient.RECEIVER);
try {
cmdOutput = (String) deployableClient.getExecutor().executeCommand(Constants.DURATION_3_MINUTES, command);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(duration, command);
LOGGER.debug("[{}][RX] \n{}", deployableClient.getContainerName(), cmdOutput);
this.receivedMessages = parseMessages(cmdOutput);
return receivedMessages.size();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,19 @@ public int sendMessages() {

@Override
public int receiveMessages() {
return receiveMessages(Constants.DURATION_3_MINUTES);
}

@Override
public int receiveMessages(long duration) {
if (subscriberExecutor != null) {
// executed client on background
return getSubscribedMessages();
} else {
// executed client on foreground
String cmdOutput;
String[] command = constructClientCommand(MessagingClient.RECEIVER);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(Constants.DURATION_3_MINUTES, command);
cmdOutput = (String) deployableClient.getExecutor().executeCommand(duration, command);
LOGGER.debug("[{}][RX] \n{}", deployableClient.getContainerName(), cmdOutput);
this.receivedMessages = parseMessages(cmdOutput, RECEIVER);
return receivedMessages.size();
Expand Down
47 changes: 24 additions & 23 deletions operator-suite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,30 +34,31 @@ If you would want to try your own OLM operator, you would need to specify only f

## List of available Environment Variables

| Name | Description | Default | Possible values |
|---------------------------|---------------------------------------------------------------------|-----------------------------|-------------------------------------------------|
| ARTEMIS_VERSION | ArtemisCloud Version to be used (Makefile) | 7.10.2 | \<major\>.\<minor\>.\<micro\> |
| ARTEMIS_TEST_VERSION | ArtemisCloud Version to be used by tests | not set | \<major\>.\<minor\> |
| OPERATOR_IMAGE | ArtemisCloud Operator image url | not set | \<image registry url\> |
| BROKER_IMAGE | Broker image url | not set | \<image registry url\> |
| BROKER_INIT_IMAGE | Broker init image url | not set | \<image registry url\> |
| BUNDLE_IMAGE | Bundle image url | not set | \<image registry url\> |
| OLM | Whether to install latest available Operator | false | `true`, `false` |
| OLM_LTS | Whether to install lts or latest available operator (tied to `OLM`) | false | `true`, `false` |
| OLM_IIB | OLM Index Image Bundle to use | not set | \<iib image registry url\> |
| OLM_CHANNEL | OLM channel to use with Subscription | not set | \<channel\> |
| DISABLE_RANDOM_NAMESPACES | Whether to use random string suffices | not set (`false`) | `true`, `false` |
| LOGS_LOCATION | Location where to generate collected logs | `test-logs` | \<directory\> |
| Name | Description | Default | Possible values |
|---------------------------|---------------------------------------------------------------------|-----------------------------|--------------------------------------------|
| ARTEMIS_VERSION | ArtemisCloud Version to be used (Makefile) | 7.10.2 | \<major\>.\<minor\>.\<micro\> |
| ARTEMIS_TEST_VERSION | ArtemisCloud Version to be used by tests | not set | \<major\>.\<minor\> |
| OPERATOR_IMAGE | ArtemisCloud Operator image url | not set | \<image registry url\> |
| BROKER_IMAGE | Broker image url | not set | \<image registry url\> |
| BROKER_INIT_IMAGE | Broker init image url | not set | \<image registry url\> |
| BUNDLE_IMAGE | Bundle image url | not set | \<image registry url\> |
| OLM | Whether to install latest available Operator | false | `true`, `false` |
| OLM_LTS | Whether to install lts or latest available operator (tied to `OLM`) | false | `true`, `false` |
| OLM_IIB | OLM Index Image Bundle to use | not set | \<iib image registry url\> |
| OLM_CHANNEL | OLM channel to use with Subscription | not set | \<channel\> |
| DISABLE_RANDOM_NAMESPACES | Whether to use random string suffices | not set (`false`) | `true`, `false` |
| LOGS_LOCATION | Location where to generate collected logs | `test-logs` | \<directory\> |
| TEST_LOG_LEVEL | Set logging level of test suite | `INFO` set in `logback.xml` | `TRACE`, `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` |
| CLUSTER_OPERATOR_MANAGED | Whether test suite manages CO or not (Makefile) | `true` | `false` |
| COLLECT_TEST_DATA | Whether to gather test data on error or not | `true` | `true`, `false` |
| CUSTOM_EXTRA_DELAY | Prolonged all internal waitFor calls (seconds) | `0` | \<number of seconds\> |
| OPERATOR_INSTALL_ZIP | Url to zip file with install/examples (Makefile) | 7.10.2 url | \<url\> |
| OPERATOR_VERSION_UPSTREAM | Version/branch of repository (Makefile) | main | \<branch\> |
| DUMP_ENABLED | Enabled serialization of deployed resources | `false` | `true`, `false` |
| DUMP_FORMAT | Format of serialized deployed resources | `yaml` | `yaml`, `json` |
| DUMP_LOCATION | Location to dump serialized deployed resources | `serialization-dump` | \<directory\> |
| KUBE_CONTEXT | Provide comma separated context(s) for kubernetes client | `default/null` | null, \<contextA,contextB,contextC,...\> |
| CLUSTER_OPERATOR_MANAGED | Whether test suite manages CO or not (Makefile) | `true` | `false` |
| COLLECT_TEST_DATA | Whether to gather test data on error or not | `true` | `true`, `false` |
| CUSTOM_EXTRA_DELAY | Prolonged all internal waitFor calls (seconds) | `0` | \<number of seconds\> |
| OPERATOR_INSTALL_ZIP | Url to zip file with install/examples (Makefile) | 7.10.2 url | \<url\> |
| OPERATOR_VERSION_UPSTREAM | Version/branch of repository (Makefile) | main | \<branch\> |
| DUMP_ENABLED | Enabled serialization of deployed resources | `false` | `true`, `false` |
| DUMP_FORMAT | Format of serialized deployed resources | `yaml` | `yaml`, `json` |
| DUMP_LOCATION | Location to dump serialized deployed resources | `serialization-dump` | \<directory\> |
| KUBE_CONTEXT | Provide comma separated context(s) for kubernetes client | `default/null` | null, \<contextA,contextB,contextC,...\> |
| TEARDOWN_ENV | Teardown down deployment or leave it as is | `true` | `true`, `false` |

## Setting log level
Currently, there is supported `TEST_LOG_LEVEL` environment variable, which can set desired logging level of test suite.
Expand Down
Loading

0 comments on commit 03ba5a8

Please sign in to comment.