Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ public class CssSelectors {
private CssSelectors() {}

public static final String PAGE_DIV = new CssBuilder()
.withElementBody().withChild()
.withElementDiv().nth(1)
.withElementDiv().withId("root")
.build();

// ----------------------------
Expand All @@ -31,22 +30,25 @@ private CssSelectors() {}
.build();

// Keycloak
public static final String LOGIN_KEYCLOAK_PAGE_TITLE = new CssBuilder(PAGE_DIV)
.withDesc()
public static final String LOGIN_KEYCLOAK_PAGE_TITLE = new CssBuilder()
.withElementHeader().withId("kc-header")
.build();

public static final String LOGIN_KEYCLOAK_USERNAME_INPUT = new CssBuilder(PAGE_DIV)
public static final String LOGIN_KEYCLOAK_FORM = new CssBuilder()
.withElementForm().withId("kc-form-login")
.build();

public static final String LOGIN_KEYCLOAK_USERNAME_INPUT = new CssBuilder(LOGIN_KEYCLOAK_FORM)
.withDesc()
.withElementInput().withId("username")
.build();

public static final String LOGIN_KEYCLOAK_PASSWORD_INPUT = new CssBuilder(PAGE_DIV)
public static final String LOGIN_KEYCLOAK_PASSWORD_INPUT = new CssBuilder(LOGIN_KEYCLOAK_FORM)
.withDesc()
.withElementInput().withId("password")
.build();

public static final String LOGIN_KEYCLOAK_SIGN_IN_BUTTON = new CssBuilder(PAGE_DIV)
public static final String LOGIN_KEYCLOAK_SIGN_IN_BUTTON = new CssBuilder(LOGIN_KEYCLOAK_FORM)
.withDesc()
.withElementButton().withId("kc-login")
.build();
Expand Down Expand Up @@ -100,7 +102,7 @@ private CssSelectors() {}
.withElementDiv().withChild()
.withElementButton().withComponentButton()
.build();

public static final String PAGES_CONTENT_HEADER_TITLE_CONTENT = new CssBuilder(PAGES_HEADER_CONTENT)
.withElementDiv().withChild()
.withElementH1().withComponentTitle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private MessagesPageSelectors() {}

public static final String MPS_TOOLBAR_POPOVER_FORM = new CssBuilder()
.withElementBody().withChild()
.withElementDiv().nth(3).withChild()
.withElementDiv().nth(4).withChild()
.withElementDiv().withComponentPanel().withChild()
.withElementDiv().withComponentPanel().withSubComponentMain().withChild()
.withElementDiv().withComponentPanel().withSubComponentMainBody().withChild()
Expand Down Expand Up @@ -306,8 +306,8 @@ public static String getTableRowItem(int nthRow, int nthColumn) {
.withElementSpan().withComponentFormControl().withChild()
.withElementInput()
.build();


public static final String MPS_MESSAGE_SIDEBAR = new CssBuilder(CssSelectors.PAGES_CONTENT)
.withChild()
.withElementDiv().withComponentPage().withSubComponentMainBody().withChild()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
import com.github.streamshub.console.api.v1alpha1.spec.security.Rule;
import com.github.streamshub.systemtests.Environment;
import com.github.streamshub.systemtests.constants.Constants;
import com.github.streamshub.systemtests.constants.Labels;
import com.github.streamshub.systemtests.setup.keycloak.KeycloakInstanceSetup;
import com.github.streamshub.systemtests.setup.keycloak.KeycloakTestConfig;
import com.github.streamshub.systemtests.utils.WaitUtils;
import com.github.streamshub.systemtests.utils.resourceutils.ClusterUtils;
import com.github.streamshub.systemtests.utils.resourceutils.ResourceUtils;
import com.github.streamshub.systemtests.utils.resourceutils.console.ConsoleUtils;
Expand All @@ -39,8 +37,6 @@ public static void setupIfNeeded(Console console) {
return;
}
KubeResourceManager.get().createResourceWithWait(console);
WaitUtils.waitForPodsReadyAndStable(console.getMetadata().getNamespace(),
Comment thread
MikeEdgar marked this conversation as resolved.
Labels.getConsolePodSelector(console.getMetadata().getName()), 1, true);
LOGGER.info("Console deployed and available at {}", ConsoleUtils.getConsoleUiUrl(console.getMetadata().getName(), true));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package com.github.streamshub.systemtests.utils;

import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.apache.logging.log4j.Logger;

import com.github.streamshub.systemtests.clients.KafkaClients;
import com.github.streamshub.systemtests.constants.ResourceConditions;
import com.github.streamshub.systemtests.constants.TimeConstants;
Expand All @@ -11,6 +20,7 @@
import com.github.streamshub.systemtests.utils.resourceutils.ResourceUtils;
import com.github.streamshub.systemtests.utils.resourceutils.kafka.KafkaNamingUtils;
import com.github.streamshub.systemtests.utils.resourceutils.keycloak.KeycloakApiUtils;

import io.fabric8.kubernetes.api.model.ContainerStatus;
import io.fabric8.kubernetes.api.model.LabelSelector;
import io.fabric8.kubernetes.api.model.Pod;
Expand All @@ -28,12 +38,6 @@
import io.strimzi.api.kafka.model.rebalance.KafkaRebalance;
import io.strimzi.api.kafka.model.rebalance.KafkaRebalanceState;
import io.strimzi.api.kafka.model.topic.KafkaTopic;
import org.apache.logging.log4j.Logger;

import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

import static com.github.streamshub.systemtests.utils.resourceutils.ResourceUtils.listKubeResourcesByPrefix;

Expand Down Expand Up @@ -333,6 +337,15 @@ public static void waitForKafkaHasNoWarningStatus(String namespaceName, String c
});
}

public static void waitForKafkaCondition(String namespace, String kafkaName, Predicate<Kafka> condition) {
KubeResourceManager.get().kubeClient()
.getClient()
.resources(Kafka.class)
.inNamespace(namespace)
.withName(kafkaName)
.waitUntilCondition(condition, TimeConstants.GLOBAL_STATUS_TIMEOUT, TimeUnit.MILLISECONDS);
}

public static void waitForClientsSuccess(KafkaClients clients) {
waitForClientsSuccess(clients.getNamespaceName(), clients.getProducerName(), clients.getConsumerName(), clients.getMessageCount(), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class KafkaTopicUtils {
private static final Logger LOGGER = LogWrapper.getLogger(KafkaTopicUtils.class);

private KafkaTopicUtils() {}

/**
Expand Down Expand Up @@ -57,7 +57,7 @@ public static List<KafkaTopic> setupTopicsIfNeededAndReturn(String namespace, St
KubeResourceManager.get().deleteResourceWithWait(existingTopics.toArray(new KafkaTopic[0]));
}

KubeResourceManager.get().createResourceWithWait(topics.toArray(new KafkaTopic[0]));
KubeResourceManager.get().createResourceAsyncWait(topics.toArray(new KafkaTopic[0]));

return topics;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
package com.github.streamshub.systemtests.utils.resourceutils.kafka;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.IntStream;

import org.apache.logging.log4j.Logger;

import com.github.streamshub.systemtests.constants.Constants;
import com.github.streamshub.systemtests.constants.Labels;
import com.github.streamshub.systemtests.enums.ConditionStatus;
import com.github.streamshub.systemtests.enums.ResourceStatus;
import com.github.streamshub.systemtests.logs.LogWrapper;
import com.github.streamshub.systemtests.utils.Utils;
import com.github.streamshub.systemtests.utils.WaitUtils;
import com.github.streamshub.systemtests.utils.resourceutils.ClusterUtils;
import com.github.streamshub.systemtests.utils.resourceutils.ResourceUtils;

import io.fabric8.kubernetes.api.model.Pod;
import io.skodjob.kubetest4j.resources.KubeResourceManager;
import io.strimzi.api.kafka.model.common.Condition;
import io.strimzi.api.kafka.model.kafka.Kafka;
import io.strimzi.api.kafka.model.kafka.KafkaBuilder;
import io.strimzi.api.kafka.model.kafka.listener.GenericKafkaListener;
import io.strimzi.api.kafka.model.kafka.listener.GenericKafkaListenerConfigurationBroker;
import io.strimzi.api.kafka.model.kafka.listener.GenericKafkaListenerConfigurationBrokerBuilder;
import io.strimzi.api.kafka.model.nodepool.KafkaNodePool;
import io.strimzi.api.kafka.model.nodepool.KafkaNodePoolBuilder;
import org.apache.logging.log4j.Logger;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.IntStream;

public class KafkaUtils {
private static final Logger LOGGER = LogWrapper.getLogger(KafkaUtils.class);
Expand Down Expand Up @@ -242,4 +247,21 @@ public static void scaleBrokerReplicasWithWait(String namespace, String kafkaNam
WaitUtils.waitForKafkaBrokerNodePoolReplicasInSpec(namespace, kafkaName, scaledBrokersCount);
WaitUtils.waitForPodsReadyAndStable(namespace, Labels.getKnpBrokerLabelSelector(kafkaName), scaledBrokersCount, true);
}

public static List<Condition> warningConditions(String namespace, String kafkaName) {
var kafka = ResourceUtils.getKubeResource(Kafka.class, namespace, kafkaName);
if (kafka != null) {
return warningConditions(kafka);
}
return Collections.emptyList();
}

public static List<Condition> warningConditions(Kafka kafka) {
return kafka.getStatus()
.getConditions()
.stream()
.filter(condition -> condition.getType().equals(ResourceStatus.WARNING.toString()))
.filter(condition -> condition.getStatus().equals(ConditionStatus.TRUE.toString()))
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
import com.github.streamshub.systemtests.utils.playwright.PwPageUrls;
import com.github.streamshub.systemtests.utils.playwright.PwUtils;
import com.github.streamshub.systemtests.utils.testutils.TopicsTestUtils;
import com.microsoft.playwright.assertions.PlaywrightAssertions;

import org.apache.logging.log4j.Logger;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class TopicChecks {
private static final Logger LOGGER = LogWrapper.getLogger(TopicChecks.class);
private TopicChecks() {}
Expand All @@ -40,12 +40,22 @@ public static void checkOverviewPageTopicState(TestCaseConfig tcc, String kafkaN
PwUtils.navigate(tcc, PwPageUrls.getOverviewPage(tcc, kafkaName));

// Status
PwUtils.waitForContainsText(tcc, ClusterOverviewPageSelectors.COPS_TOPICS_CARD_TOTAL_TOPICS, total + " topics", true);
PwUtils.waitForContainsText(tcc, ClusterOverviewPageSelectors.COPS_TOPICS_CARD_TOTAL_PARTITIONS, partitions + " partitions", true);
PlaywrightAssertions
.assertThat(tcc.page().locator(ClusterOverviewPageSelectors.COPS_TOPICS_CARD_TOTAL_TOPICS))
.containsText(total + " topics");
PlaywrightAssertions
.assertThat(tcc.page().locator(ClusterOverviewPageSelectors.COPS_TOPICS_CARD_TOTAL_PARTITIONS))
.containsText(partitions + " partitions");

PwUtils.waitForContainsText(tcc, ClusterOverviewPageSelectors.COPS_TOPICS_CARD_FULLY_REPLICATED, fullyReplicated + " Fully replicated", true);
PwUtils.waitForContainsText(tcc, ClusterOverviewPageSelectors.COPS_TOPICS_CARD_UNDER_REPLICATED, underReplicated + " Under replicated", true);
PwUtils.waitForContainsText(tcc, ClusterOverviewPageSelectors.COPS_TOPICS_CARD_UNAVAILABLE, unavailable + " Unavailable", true);
PlaywrightAssertions
.assertThat(tcc.page().locator(ClusterOverviewPageSelectors.COPS_TOPICS_CARD_FULLY_REPLICATED))
.containsText(fullyReplicated + " Fully replicated");
PlaywrightAssertions
.assertThat(tcc.page().locator(ClusterOverviewPageSelectors.COPS_TOPICS_CARD_UNDER_REPLICATED))
.containsText(underReplicated + " Under replicated");
PlaywrightAssertions
.assertThat(tcc.page().locator(ClusterOverviewPageSelectors.COPS_TOPICS_CARD_UNAVAILABLE))
.containsText(unavailable + " Unavailable");
}

/**
Expand All @@ -64,11 +74,20 @@ public static void checkTopicsPageTopicState(TestCaseConfig tcc, String kafkaNam
LOGGER.info("Verify Overview Page topic status [{} total topics] [FullyReplicated: {}] [UnderReplicated: {}] [Unavailabe: {}]", total, fullyReplicated, underReplicated, unavailable);
// Total topic count
PwUtils.navigate(tcc, PwPageUrls.getTopicsPage(tcc, kafkaName));
PwUtils.waitForContainsText(tcc, TopicsPageSelectors.TPS_HEADER_TOTAL_TOPICS_BADGE, total + " total", true);
PlaywrightAssertions
.assertThat(tcc.page().locator(TopicsPageSelectors.TPS_HEADER_TOTAL_TOPICS_BADGE))
.containsText(total + " total");

// Status
PwUtils.waitForContainsText(tcc, TopicsPageSelectors.TPS_HEADER_BADGE_STATUS_SUCCESS, Integer.toString(fullyReplicated), true);
PwUtils.waitForContainsText(tcc, TopicsPageSelectors.TPS_HEADER_BADGE_STATUS_WARNING, Integer.toString(underReplicated), true);
PwUtils.waitForContainsText(tcc, TopicsPageSelectors.TPS_HEADER_BADGE_STATUS_ERROR, Integer.toString(unavailable), true);
PlaywrightAssertions
.assertThat(tcc.page().locator(TopicsPageSelectors.TPS_HEADER_BADGE_STATUS_SUCCESS))
.containsText(Integer.toString(fullyReplicated));
PlaywrightAssertions
.assertThat(tcc.page().locator(TopicsPageSelectors.TPS_HEADER_BADGE_STATUS_WARNING))
.containsText(Integer.toString(underReplicated));
PlaywrightAssertions
.assertThat(tcc.page().locator(TopicsPageSelectors.TPS_HEADER_BADGE_STATUS_ERROR))
.containsText(Integer.toString(unavailable));
}

/**
Expand Down Expand Up @@ -147,8 +166,12 @@ public static void checkPaginationPage(TestCaseConfig tcc, int topicsCount, List
private static void checkPaginationContent(TestCaseConfig tcc, int pageNum, int numOfFinalPage, int topicsOnPage, int lowBoundary, int highBoundary, int topicsCount, String paginationTextSelector, String moveButtonSelector) {
LOGGER.debug("Checking page {}/{}", pageNum, numOfFinalPage);
// Check that correct number of topics is displayed
PwUtils.waitForLocatorVisible(tcc, new CssBuilder(TopicsPageSelectors.TPS_TABLE_ROWS).nth(1).build());
assertEquals(topicsOnPage, tcc.page().locator(TopicsPageSelectors.TPS_TABLE_ROWS).all().size());
PlaywrightAssertions
.assertThat(tcc.page().locator(new CssBuilder(TopicsPageSelectors.TPS_TABLE_ROWS)
.withDesc()
.withElementTr()
.build()))
.hasCount(topicsOnPage);

// Check pagination details
String paginationOf = String.format("%s - %s of %s", lowBoundary, highBoundary, topicsCount);
Expand Down
Loading