Skip to content
Open
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 @@ -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,27 @@
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);
// PwUtils.waitForContainsText(tcc, ClusterOverviewPageSelectors.COPS_TOPICS_CARD_TOTAL_TOPICS, total + " topics", true);

Check warning on line 43 in systemtests/src/main/java/com/github/streamshub/systemtests/utils/testchecks/TopicChecks.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=streamshub_console&issues=AZ1PrbXl_4SQWyQ53el3&open=AZ1PrbXl_4SQWyQ53el3&pullRequest=2323
// 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);
// PwUtils.waitForContainsText(tcc, ClusterOverviewPageSelectors.COPS_TOPICS_CARD_FULLY_REPLICATED, fullyReplicated + " Fully replicated", true);

Check warning on line 52 in systemtests/src/main/java/com/github/streamshub/systemtests/utils/testchecks/TopicChecks.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=streamshub_console&issues=AZ1PrbXl_4SQWyQ53el4&open=AZ1PrbXl_4SQWyQ53el4&pullRequest=2323
// 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 +79,24 @@
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);
// PwUtils.waitForContainsText(tcc, TopicsPageSelectors.TPS_HEADER_TOTAL_TOPICS_BADGE, total + " total", true);

Check warning on line 82 in systemtests/src/main/java/com/github/streamshub/systemtests/utils/testchecks/TopicChecks.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=streamshub_console&issues=AZ1PrbXl_4SQWyQ53el5&open=AZ1PrbXl_4SQWyQ53el5&pullRequest=2323
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);
// PwUtils.waitForContainsText(tcc, TopicsPageSelectors.TPS_HEADER_BADGE_STATUS_SUCCESS, Integer.toString(fullyReplicated), true);

Check warning on line 88 in systemtests/src/main/java/com/github/streamshub/systemtests/utils/testchecks/TopicChecks.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=streamshub_console&issues=AZ1PrbXl_4SQWyQ53el6&open=AZ1PrbXl_4SQWyQ53el6&pullRequest=2323
// 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 +175,14 @@
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());
// PwUtils.waitForLocatorVisible(tcc, new CssBuilder(TopicsPageSelectors.TPS_TABLE_ROWS).nth(1).build());

Check warning on line 178 in systemtests/src/main/java/com/github/streamshub/systemtests/utils/testchecks/TopicChecks.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This block of commented-out lines of code should be removed.

See more on https://sonarcloud.io/project/issues?id=streamshub_console&issues=AZ1PrbXl_4SQWyQ53el7&open=AZ1PrbXl_4SQWyQ53el7&pullRequest=2323
// 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
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.github.streamshub.systemtests.kafka;

import java.util.List;

import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import com.github.streamshub.systemtests.AbstractST;
import com.github.streamshub.systemtests.MessageStore;
import com.github.streamshub.systemtests.TestCaseConfig;
Expand All @@ -23,22 +31,22 @@
import com.github.streamshub.systemtests.utils.resourceutils.ResourceUtils;
import com.github.streamshub.systemtests.utils.resourceutils.kafka.KafkaNamingUtils;
import com.github.streamshub.systemtests.utils.resourceutils.kafka.KafkaUtils;
import com.microsoft.playwright.Locator.ClickOptions;
import com.microsoft.playwright.assertions.LocatorAssertions;
import com.microsoft.playwright.assertions.PlaywrightAssertions;

import io.skodjob.kubetest4j.resources.KubeResourceManager;
import io.skodjob.kubetest4j.wait.Wait;
import io.strimzi.api.ResourceAnnotations;
import io.strimzi.api.kafka.model.common.Condition;
import io.strimzi.api.kafka.model.kafka.JbodStorageBuilder;
import io.strimzi.api.kafka.model.kafka.Kafka;
import io.strimzi.api.kafka.model.kafka.KafkaClusterSpec;
import io.strimzi.api.kafka.model.kafka.PersistentClaimStorageBuilder;
import io.strimzi.api.kafka.model.nodepool.KafkaNodePool;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import static com.github.streamshub.systemtests.utils.Utils.getTestCaseConfig;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

@Tag(TestTags.REGRESSION)
public class KafkaST extends AbstractST {
Expand Down Expand Up @@ -263,16 +271,62 @@ void testAddRemoveKafkaNodes() {
void testDisplayKafkaWarnings() {
final TestCaseConfig tcc = getTestCaseConfig();

LOGGER.info("Verify default Kafka state - expecting no warnings or errors");
List<String> initialWarningMessages = ResourceUtils.getKubeResource(Kafka.class, tcc.namespace(), tcc.kafkaName())
.getStatus()
.getConditions()
.stream()
.filter(condition -> condition.getType().equals(ResourceStatus.WARNING.toString()))
.filter(condition -> condition.getStatus().equals(ConditionStatus.TRUE.toString()))
.map(Condition::getMessage)
.toList();

LOGGER.info("Verify default Kafka state - expecting {} warnings/errors", initialWarningMessages.size());
PwUtils.navigate(tcc, PwPageUrls.getOverviewPage(tcc, tcc.kafkaName()));

// Open warnings
PwUtils.waitForLocatorAndClick(tcc, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNINGS_DROPDOWN_BUTTON);
var warningsToggle = tcc.page().locator(ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNINGS_DROPDOWN_BUTTON);
PlaywrightAssertions.assertThat(warningsToggle).isVisible();

// Check warnings list
LOGGER.debug("Verify warnings list contains only one row with `No messages` text");
PwUtils.waitForLocatorVisible(tcc, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS);
PwUtils.waitForLocatorCount(tcc, 1, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS, true);
PwUtils.waitForContainsText(tcc, new CssBuilder(ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS).nth(1).build(), MessageStore.clusterCardNoMessages(), true);
var messageItems = tcc.page().locator(ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS);
Runnable initialStateAssertions;

/*
* Two possible initial states:
* - the list has warnings and is expanded by default
* - the list is empty and is collapsed by default
*/
if (!initialWarningMessages.isEmpty()) {
initialStateAssertions = () -> {
messageItems.all()
.stream()
.map(PlaywrightAssertions::assertThat)
.forEach(LocatorAssertions::isVisible);
PlaywrightAssertions
.assertThat(messageItems)
.hasCount(initialWarningMessages.size());
PlaywrightAssertions
.assertThat(messageItems)
.not()
.containsText(MessageStore.clusterCardNoMessages());
};
} else {
initialStateAssertions = () -> {
LOGGER.debug("Verify warnings list contains only one row with `No messages` text");
warningsToggle.click(new ClickOptions().setForce(true));
PlaywrightAssertions
.assertThat(messageItems)
.isVisible();
PlaywrightAssertions
.assertThat(messageItems)
.hasCount(1);
PlaywrightAssertions
.assertThat(messageItems)
.containsText(MessageStore.clusterCardNoMessages());
};
}

initialStateAssertions.run();

// Make kafka fail
LOGGER.info("Cause Kafka status to display Warning state by setting DeprecatedFields");
Expand All @@ -287,23 +341,32 @@ void testDisplayKafkaWarnings() {
WaitUtils.waitForKafkaHasWarningStatus(tcc.namespace(), tcc.kafkaName());

// Expect a warning message
String warningMessage = ResourceUtils.getKubeResource(Kafka.class, tcc.namespace(), tcc.kafkaName()).getStatus().getConditions().stream()
.filter(condition -> condition.getType().equals(ResourceStatus.WARNING.toString()) && condition.getStatus().equals(ConditionStatus.TRUE.toString()))
.toList().getFirst().getMessage();
LOGGER.debug("Kafka currently contains warning message: [{}]", warningMessage);
List<String> warningMessages = ResourceUtils.getKubeResource(Kafka.class, tcc.namespace(), tcc.kafkaName())
.getStatus()
.getConditions()
.stream()
.filter(condition -> condition.getType().equals(ResourceStatus.WARNING.toString()))
.filter(condition -> condition.getStatus().equals(ConditionStatus.TRUE.toString()))
.map(Condition::getMessage)
.toList();
LOGGER.debug("Kafka currently contains warning messages: {}", warningMessages);

// Reload using on page button
PwUtils.waitForLocatorAndClick(tcc, CssSelectors.PAGES_HEADER_RELOAD_BUTTON);

// Check warnings list
LOGGER.debug("Verify warnings list now contains one row with warning message");
PwUtils.waitForLocatorVisible(tcc, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS);
PwUtils.waitForLocatorCount(tcc, 1, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS, true);

assertTrue(PwUtils.locatorContainsText(
tcc.page().locator(new CssBuilder(ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS).nth(1).build()),
warningMessage,
true));
LOGGER.debug("Verify warnings list now contains {} row(s) with warning messages", warningMessages.size());

PlaywrightAssertions
.assertThat(messageItems)
.hasCount(warningMessages.size());
messageItems.all()
.stream()
.map(PlaywrightAssertions::assertThat)
.forEach(LocatorAssertions::isVisible);
PlaywrightAssertions
.assertThat(messageItems)
.containsText(warningMessages.toArray(String[]::new));

// Remove wrong config
LOGGER.info("Remove incorrect Kafka config to get rid off the warning from UI status");
Expand All @@ -313,16 +376,29 @@ void testDisplayKafkaWarnings() {
}
);

WaitUtils.waitForKafkaHasNoWarningStatus(tcc.namespace(), tcc.kafkaName());
Wait.until("Kafka has initial warnings",
TimeConstants.POLL_INTERVAL_FOR_RESOURCE_READINESS, TimeConstants.GLOBAL_STATUS_TIMEOUT,
() -> {
Kafka kafka = ResourceUtils.getKubeResource(Kafka.class, tcc.namespace(), tcc.kafkaName());
if (kafka == null) {
return false;
}

List<String> latestMessages = ResourceUtils.getKubeResource(Kafka.class, tcc.namespace(), tcc.kafkaName())
.getStatus()
.getConditions()
.stream()
.filter(condition -> condition.getType().equals(ResourceStatus.WARNING.toString()))
.filter(condition -> condition.getStatus().equals(ConditionStatus.TRUE.toString()))
.map(Condition::getMessage)
.toList();

return initialWarningMessages.equals(latestMessages);
});

LOGGER.debug("Reload page and verify that there is `No messages` in the warnings list again");
LOGGER.debug("Reload page and verify the initial assertions are again true");
tcc.page().reload(PwUtils.getDefaultReloadOpts());

PwUtils.waitForLocatorAndClick(tcc, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNINGS_DROPDOWN_BUTTON);

PwUtils.waitForLocatorVisible(tcc, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS);
PwUtils.waitForLocatorCount(tcc, 1, ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS, true);
PwUtils.waitForContainsText(tcc, new CssBuilder(ClusterOverviewPageSelectors.COPS_CLUSTER_CARD_KAFKA_WARNING_MESSAGE_ITEMS).nth(1).build(), MessageStore.clusterCardNoMessages(), true);
initialStateAssertions.run();
}

@AfterEach
Expand Down
Loading