浏览代码

Merge branch 'master' into vlad/develop

VladSenyuta 2 年之前
父节点
当前提交
6496375599

+ 9 - 1
kafka-ui-e2e-checks/src/main/java/com/provectus/kafka/ui/pages/topic/TopicsList.java

@@ -8,6 +8,7 @@ import com.codeborne.selenide.Condition;
 import com.codeborne.selenide.SelenideElement;
 import com.codeborne.selenide.SelenideElement;
 import com.provectus.kafka.ui.pages.BasePage;
 import com.provectus.kafka.ui.pages.BasePage;
 import io.qameta.allure.Step;
 import io.qameta.allure.Step;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.List;
 import java.util.List;
@@ -24,6 +25,7 @@ public class TopicsList extends BasePage {
     protected SelenideElement copySelectedTopicBtn = $x("//button[text()='Copy selected topic']");
     protected SelenideElement copySelectedTopicBtn = $x("//button[text()='Copy selected topic']");
     protected SelenideElement purgeMessagesOfSelectedTopicsBtn = $x("//button[text()='Purge messages of selected topics']");
     protected SelenideElement purgeMessagesOfSelectedTopicsBtn = $x("//button[text()='Purge messages of selected topics']");
     protected SelenideElement clearMessagesBtn = $x("//ul[contains(@class ,'open')]//div[text()='Clear Messages']");
     protected SelenideElement clearMessagesBtn = $x("//ul[contains(@class ,'open')]//div[text()='Clear Messages']");
+    protected SelenideElement recreateTopicBtn = $x("//ul[contains(@class ,'open')]//div[text()='Recreate Topic']");
 
 
     @Step
     @Step
     public TopicsList waitUntilScreenReady() {
     public TopicsList waitUntilScreenReady() {
@@ -90,6 +92,12 @@ public class TopicsList extends BasePage {
       return this;
       return this;
     }
     }
 
 
+    @Step
+    public TopicsList clickRecreateTopicBtn(){
+      clickByJavaScript(recreateTopicBtn.shouldBe(visible));
+      return this;
+    }
+
     @Step
     @Step
     public TopicsList clickConfirmBtnMdl() {
     public TopicsList clickConfirmBtnMdl() {
     clickConfirmButton();
     clickConfirmButton();
@@ -174,7 +182,7 @@ public class TopicsList extends BasePage {
       public boolean isInternal() {
       public boolean isInternal() {
         boolean internal = false;
         boolean internal = false;
         try {
         try {
-          element.$x("./td[2]/a/span").shouldBe(visible);
+          element.$x("./td[2]/a/span").shouldBe(visible, Duration.ofMillis(500));
           internal = true;
           internal = true;
         } catch (Throwable ignored) {
         } catch (Throwable ignored) {
         }
         }

+ 40 - 1
kafka-ui-e2e-checks/src/test/java/com/provectus/kafka/ui/suite/topics/TopicMessagesTests.java

@@ -38,11 +38,15 @@ public class TopicMessagesTests extends BaseTest {
       .setName("topic-to-clear-message-attribute-" + randomAlphabetic(5))
       .setName("topic-to-clear-message-attribute-" + randomAlphabetic(5))
       .setMessageKey(fileToString(System.getProperty("user.dir") + "/src/test/resources/producedkey.txt"))
       .setMessageKey(fileToString(System.getProperty("user.dir") + "/src/test/resources/producedkey.txt"))
       .setMessageContent(fileToString(System.getProperty("user.dir") + "/src/test/resources/testData.txt"));
       .setMessageContent(fileToString(System.getProperty("user.dir") + "/src/test/resources/testData.txt"));
+  private static final Topic TOPIC_TO_RECREATE = new Topic()
+      .setName("topic-to-recreate-attribute-" + randomAlphabetic(5))
+      .setMessageKey(fileToString(System.getProperty("user.dir") + "/src/test/resources/producedkey.txt"))
+      .setMessageContent(fileToString(System.getProperty("user.dir") + "/src/test/resources/testData.txt"));
   private static final List<Topic> TOPIC_LIST = new ArrayList<>();
   private static final List<Topic> TOPIC_LIST = new ArrayList<>();
 
 
   @BeforeAll
   @BeforeAll
   public void beforeAll() {
   public void beforeAll() {
-    TOPIC_LIST.addAll(List.of(TOPIC_FOR_MESSAGES, TOPIC_TO_CLEAR_MESSAGES));
+    TOPIC_LIST.addAll(List.of(TOPIC_FOR_MESSAGES, TOPIC_TO_CLEAR_MESSAGES, TOPIC_TO_RECREATE));
     TOPIC_LIST.forEach(topic -> apiService.createTopic(CLUSTER_NAME, topic.getName()));
     TOPIC_LIST.forEach(topic -> apiService.createTopic(CLUSTER_NAME, topic.getName()));
   }
   }
 
 
@@ -174,6 +178,41 @@ public class TopicMessagesTests extends BaseTest {
     softly.assertAll();
     softly.assertAll();
   }
   }
 
 
+  @DisplayName("TopicTests.recreateTopic : Recreate topic")
+  @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
+  @AutomationStatus(status = Status.AUTOMATED)
+  @CaseId(240)
+  @Test
+  void checkRecreateTopic(){
+    navigateToTopicsAndOpenDetails(TOPIC_TO_RECREATE.getName());
+    topicDetails
+        .openDetailsTab(TopicDetails.TopicMenu.OVERVIEW)
+        .clickProduceMessageBtn();
+    produceMessagePanel
+        .waitUntilScreenReady()
+        .setContentFiled(TOPIC_TO_RECREATE.getMessageContent())
+        .setKeyField(TOPIC_TO_RECREATE.getMessageKey())
+        .submitProduceMessage();
+    topicDetails
+        .waitUntilScreenReady();
+    navigateToTopics();
+    topicsList
+        .waitUntilScreenReady();
+    assertThat(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages())
+        .as("getNumberOfMessages()").isEqualTo(1);
+    topicsList
+        .openDotMenuByTopicName(TOPIC_TO_RECREATE.getName())
+        .clickRecreateTopicBtn()
+        .clickConfirmBtnMdl();
+    SoftAssertions softly = new SoftAssertions();
+    softly.assertThat(topicDetails.isAlertWithMessageVisible(SUCCESS,
+            String.format("Topic %s successfully recreated!", TOPIC_TO_RECREATE.getName())))
+        .as("isAlertWithMessageVisible()").isTrue();
+    softly.assertThat(topicsList.getTopicItem(TOPIC_TO_RECREATE.getName()).getNumberOfMessages())
+        .as("getNumberOfMessages()").isEqualTo(0);
+    softly.assertAll();
+  }
+
   @AfterAll
   @AfterAll
   public void afterAll() {
   public void afterAll() {
     TOPIC_LIST.forEach(topic -> apiService.deleteTopic(CLUSTER_NAME, topic.getName()));
     TOPIC_LIST.forEach(topic -> apiService.deleteTopic(CLUSTER_NAME, topic.getName()));

+ 15 - 12
kafka-ui-react-app/src/components/Topics/Topic/Messages/Filters/Filters.tsx

@@ -231,18 +231,21 @@ const Filters: React.FC<FiltersProps> = ({
         props.seekType = SeekType.TIMESTAMP;
         props.seekType = SeekType.TIMESTAMP;
       }
       }
 
 
-      props.seekTo = selectedPartitions.map(({ value }) => {
-        const offsetProperty =
-          seekDirection === SeekDirection.FORWARD ? 'offsetMin' : 'offsetMax';
-        const offsetBasedSeekTo =
-          currentOffset || partitionMap[value][offsetProperty];
-        const seekToOffset =
-          currentSeekType === SeekType.OFFSET
-            ? offsetBasedSeekTo
-            : timestamp?.getTime();
-
-        return `${value}::${seekToOffset || '0'}`;
-      });
+      if (selectedPartitions.length !== partitions.length) {
+        // not everything in the partition is selected
+        props.seekTo = selectedPartitions.map(({ value }) => {
+          const offsetProperty =
+            seekDirection === SeekDirection.FORWARD ? 'offsetMin' : 'offsetMax';
+          const offsetBasedSeekTo =
+            currentOffset || partitionMap[value][offsetProperty];
+          const seekToOffset =
+            currentSeekType === SeekType.OFFSET
+              ? offsetBasedSeekTo
+              : timestamp?.getTime();
+
+          return `${value}::${seekToOffset || '0'}`;
+        });
+      }
     }
     }
 
 
     const newProps = omitBy(props, (v) => v === undefined || v === '');
     const newProps = omitBy(props, (v) => v === undefined || v === '');