TopicTests.java 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. package com.provectus.kafka.ui.tests;
  2. import static com.provectus.kafka.ui.pages.NaviSideBar.SideMenuOption.TOPICS;
  3. import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.CleanupPolicyValue.COMPACT;
  4. import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.CleanupPolicyValue.DELETE;
  5. import static com.provectus.kafka.ui.pages.topic.TopicCreateEditForm.MaxSizeOnDisk.SIZE_20_GB;
  6. import static com.provectus.kafka.ui.settings.Source.CLUSTER_NAME;
  7. import static com.provectus.kafka.ui.utilities.FileUtils.fileToString;
  8. import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic;
  9. import static org.assertj.core.api.Assertions.assertThat;
  10. import com.provectus.kafka.ui.base.BaseTest;
  11. import com.provectus.kafka.ui.models.Topic;
  12. import com.provectus.kafka.ui.pages.topic.TopicDetails;
  13. import com.provectus.kafka.ui.utilities.qaseIoUtils.annotations.AutomationStatus;
  14. import com.provectus.kafka.ui.utilities.qaseIoUtils.annotations.Suite;
  15. import com.provectus.kafka.ui.utilities.qaseIoUtils.enums.Status;
  16. import io.qameta.allure.Issue;
  17. import io.qase.api.annotation.CaseId;
  18. import java.util.ArrayList;
  19. import java.util.List;
  20. import org.assertj.core.api.SoftAssertions;
  21. import org.junit.jupiter.api.AfterAll;
  22. import org.junit.jupiter.api.Assertions;
  23. import org.junit.jupiter.api.BeforeAll;
  24. import org.junit.jupiter.api.Disabled;
  25. import org.junit.jupiter.api.DisplayName;
  26. import org.junit.jupiter.api.Test;
  27. import org.junit.jupiter.api.TestInstance;
  28. @TestInstance(TestInstance.Lifecycle.PER_CLASS)
  29. public class TopicTests extends BaseTest {
  30. private static final long SUITE_ID = 2;
  31. private static final String SUITE_TITLE = "Topics";
  32. private static final Topic TOPIC_TO_CREATE = new Topic()
  33. .setName("new-topic-"+ randomAlphabetic(5))
  34. .setPartitions("1")
  35. .setCleanupPolicyValue(DELETE);
  36. private static final Topic TOPIC_FOR_UPDATE = new Topic()
  37. .setName("topic-to-update-" + randomAlphabetic(5))
  38. .setCleanupPolicyValue(COMPACT)
  39. .setTimeToRetainData("604800001")
  40. .setMaxSizeOnDisk(SIZE_20_GB)
  41. .setMaxMessageBytes("1000020")
  42. .setMessageKey(fileToString(System.getProperty("user.dir") + "/src/test/resources/producedkey.txt"))
  43. .setMessageContent(fileToString(System.getProperty("user.dir") + "/src/test/resources/testData.txt"));
  44. private static final Topic TOPIC_FOR_MESSAGES = new Topic()
  45. .setName("topic-with-clean-message-attribute-" + randomAlphabetic(5))
  46. .setMessageKey(fileToString(System.getProperty("user.dir") + "/src/test/resources/producedkey.txt"))
  47. .setMessageContent(fileToString(System.getProperty("user.dir") + "/src/test/resources/testData.txt"));
  48. private static final Topic TOPIC_FOR_DELETE = new Topic().setName("topic-to-delete-" + randomAlphabetic(5));
  49. private static final List<Topic> TOPIC_LIST = new ArrayList<>();
  50. @BeforeAll
  51. public void beforeAll() {
  52. TOPIC_LIST.addAll(List.of(TOPIC_FOR_UPDATE, TOPIC_FOR_DELETE, TOPIC_FOR_MESSAGES));
  53. TOPIC_LIST.forEach(topic -> apiHelper.createTopic(CLUSTER_NAME, topic.getName()));
  54. }
  55. @DisplayName("should create a topic")
  56. @Suite(suiteId = 4, title = "Create new Topic")
  57. @AutomationStatus(status = Status.AUTOMATED)
  58. @CaseId(199)
  59. @Test
  60. public void createTopic() {
  61. naviSideBar
  62. .openSideMenu(TOPICS);
  63. topicsList
  64. .waitUntilScreenReady()
  65. .clickAddTopicBtn();
  66. topicCreateEditForm
  67. .waitUntilScreenReady()
  68. .setTopicName(TOPIC_TO_CREATE.getName())
  69. .setPartitions(TOPIC_TO_CREATE.getPartitions())
  70. .selectCleanupPolicy(TOPIC_TO_CREATE.getCleanupPolicyValue())
  71. .clickCreateTopicBtn();
  72. topicDetails
  73. .waitUntilScreenReady();
  74. naviSideBar
  75. .openSideMenu(TOPICS);
  76. topicsList
  77. .waitUntilScreenReady()
  78. .openTopic(TOPIC_TO_CREATE.getName());
  79. SoftAssertions softly = new SoftAssertions();
  80. softly.assertThat(topicDetails.isTopicHeaderVisible(TOPIC_TO_CREATE.getName())).as("isTopicHeaderVisible()").isTrue();
  81. softly.assertThat(topicDetails.getCleanUpPolicy()).as("getCleanUpPolicy()").isEqualTo(TOPIC_TO_CREATE.getCleanupPolicyValue().toString());
  82. softly.assertThat(topicDetails.getPartitions()).as("getPartitions()").isEqualTo(TOPIC_TO_CREATE.getPartitions());
  83. softly.assertAll();
  84. naviSideBar
  85. .openSideMenu(TOPICS);
  86. topicsList
  87. .waitUntilScreenReady();
  88. Assertions.assertTrue(topicsList.isTopicVisible(TOPIC_TO_CREATE.getName()), "isTopicVisible");
  89. TOPIC_LIST.add(TOPIC_TO_CREATE);
  90. }
  91. @Disabled("https://github.com/provectus/kafka-ui/issues/2625")
  92. @DisplayName("should update a topic")
  93. @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
  94. @AutomationStatus(status = Status.AUTOMATED)
  95. @CaseId(197)
  96. @Test
  97. public void updateTopic() {
  98. naviSideBar
  99. .openSideMenu(TOPICS);
  100. topicsList
  101. .waitUntilScreenReady()
  102. .openTopic(TOPIC_FOR_UPDATE.getName());
  103. topicDetails
  104. .waitUntilScreenReady()
  105. .openDotMenu()
  106. .clickEditSettingsMenu();
  107. topicCreateEditForm
  108. .waitUntilScreenReady()
  109. .selectCleanupPolicy((TOPIC_FOR_UPDATE.getCleanupPolicyValue()))
  110. .setMinInsyncReplicas(10)
  111. .setTimeToRetainDataInMs(TOPIC_FOR_UPDATE.getTimeToRetainData())
  112. .setMaxSizeOnDiskInGB(TOPIC_FOR_UPDATE.getMaxSizeOnDisk())
  113. .setMaxMessageBytes(TOPIC_FOR_UPDATE.getMaxMessageBytes())
  114. .clickCreateTopicBtn();
  115. topicDetails
  116. .waitUntilScreenReady();
  117. naviSideBar
  118. .openSideMenu(TOPICS);
  119. topicsList
  120. .waitUntilScreenReady()
  121. .openTopic(TOPIC_FOR_UPDATE.getName());
  122. topicDetails
  123. .waitUntilScreenReady()
  124. .openDotMenu()
  125. .clickEditSettingsMenu();
  126. SoftAssertions softly = new SoftAssertions();
  127. softly.assertThat(topicCreateEditForm.getCleanupPolicy()).as("getCleanupPolicy()").isEqualTo(TOPIC_FOR_UPDATE.getCleanupPolicyValue().getVisibleText());
  128. softly.assertThat(topicCreateEditForm.getTimeToRetain()).as("getTimeToRetain()").isEqualTo(TOPIC_FOR_UPDATE.getTimeToRetainData());
  129. softly.assertThat(topicCreateEditForm.getMaxSizeOnDisk()).as("getMaxSizeOnDisk()").isEqualTo(TOPIC_FOR_UPDATE.getMaxSizeOnDisk().getVisibleText());
  130. softly.assertThat(topicCreateEditForm.getMaxMessageBytes()).as("getMaxMessageBytes()").isEqualTo(TOPIC_FOR_UPDATE.getMaxMessageBytes());
  131. softly.assertAll();
  132. }
  133. @DisplayName("should delete topic")
  134. @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
  135. @AutomationStatus(status = Status.AUTOMATED)
  136. @CaseId(207)
  137. @Test
  138. public void deleteTopic() {
  139. naviSideBar
  140. .openSideMenu(TOPICS);
  141. topicsList
  142. .waitUntilScreenReady()
  143. .openTopic(TOPIC_FOR_DELETE.getName());
  144. topicDetails
  145. .waitUntilScreenReady()
  146. .openDotMenu()
  147. .clickDeleteTopicMenu()
  148. .clickConfirmDeleteBtn();
  149. naviSideBar
  150. .openSideMenu(TOPICS);
  151. topicsList
  152. .waitUntilScreenReady();
  153. Assertions.assertFalse(topicsList.isTopicVisible(TOPIC_FOR_DELETE.getName()), "isTopicVisible");
  154. TOPIC_LIST.remove(TOPIC_FOR_DELETE);
  155. }
  156. @DisplayName("produce message")
  157. @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
  158. @AutomationStatus(status = Status.AUTOMATED)
  159. @CaseId(222)
  160. @Test
  161. void produceMessage() {
  162. naviSideBar
  163. .openSideMenu(TOPICS);
  164. topicsList
  165. .waitUntilScreenReady()
  166. .openTopic(TOPIC_FOR_MESSAGES.getName());
  167. topicDetails
  168. .waitUntilScreenReady()
  169. .openDetailsTab(TopicDetails.TopicMenu.MESSAGES)
  170. .clickProduceMessageBtn();
  171. produceMessagePanel
  172. .waitUntilScreenReady()
  173. .setContentFiled(TOPIC_FOR_MESSAGES.getMessageContent())
  174. .setKeyField(TOPIC_FOR_MESSAGES.getMessageKey())
  175. .submitProduceMessage();
  176. topicDetails
  177. .waitUntilScreenReady();
  178. SoftAssertions softly = new SoftAssertions();
  179. softly.assertThat(topicDetails.isKeyMessageVisible((TOPIC_FOR_MESSAGES.getMessageKey()))).withFailMessage("isKeyMessageVisible()").isTrue();
  180. softly.assertThat(topicDetails.isContentMessageVisible((TOPIC_FOR_MESSAGES.getMessageContent()).trim())).withFailMessage("isContentMessageVisible()").isTrue();
  181. softly.assertAll();
  182. }
  183. @Issue("Uncomment last assertion after bug https://github.com/provectus/kafka-ui/issues/2778 fix")
  184. @DisplayName("clear message")
  185. @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
  186. @AutomationStatus(status = Status.AUTOMATED)
  187. @CaseId(19)
  188. @Test
  189. void clearMessage() {
  190. naviSideBar
  191. .openSideMenu(TOPICS);
  192. topicsList
  193. .waitUntilScreenReady()
  194. .openTopic(TOPIC_FOR_MESSAGES.getName());
  195. topicDetails
  196. .waitUntilScreenReady()
  197. .openDetailsTab(TopicDetails.TopicMenu.OVERVIEW)
  198. .clickProduceMessageBtn();
  199. produceMessagePanel
  200. .waitUntilScreenReady()
  201. .setContentFiled(TOPIC_FOR_MESSAGES.getMessageContent())
  202. .setKeyField(TOPIC_FOR_MESSAGES.getMessageKey())
  203. .submitProduceMessage();
  204. topicDetails
  205. .waitUntilScreenReady();
  206. String messageAmount = topicDetails.MessageCountAmount();
  207. assertThat(messageAmount)
  208. .withFailMessage("message amount not equals").isEqualTo(topicDetails.MessageCountAmount());
  209. topicDetails
  210. .openDotMenu()
  211. .clickClearMessagesMenu();
  212. // assertThat(Integer.toString(Integer.valueOf(messageAmount)-1))
  213. // .withFailMessage("message amount not decrease by one").isEqualTo(topicDetails.MessageCountAmount());
  214. }
  215. @DisplayName("Redirect to consumer from topic profile")
  216. @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
  217. @AutomationStatus(status = Status.AUTOMATED)
  218. @CaseId(20)
  219. @Test
  220. void redirectToConsumerFromTopic() {
  221. String topicName = "source-activities";
  222. String consumerGroupId = "connect-sink_postgres_activities";
  223. naviSideBar
  224. .openSideMenu(TOPICS);
  225. topicsList
  226. .waitUntilScreenReady()
  227. .openTopic(topicName);
  228. topicDetails
  229. .waitUntilScreenReady()
  230. .openDetailsTab(TopicDetails.TopicMenu.CONSUMERS)
  231. .openConsumerGroup(consumerGroupId);
  232. consumersDetails
  233. .waitUntilScreenReady();
  234. assertThat(consumersDetails.isRedirectedConsumerTitleVisible(consumerGroupId))
  235. .withFailMessage("isRedirectedConsumerTitleVisible").isTrue();
  236. assertThat(consumersDetails.isTopicInConsumersDetailsVisible(topicName))
  237. .withFailMessage("isTopicInConsumersDetailsVisible").isTrue();
  238. }
  239. @DisplayName("Checking Topic creation possibility in case of empty Topic Name")
  240. @Suite(suiteId = SUITE_ID, title = SUITE_TITLE)
  241. @AutomationStatus(status = Status.AUTOMATED)
  242. @CaseId(4)
  243. @Test
  244. void checkTopicCreatePossibility() {
  245. naviSideBar
  246. .openSideMenu(TOPICS);
  247. topicsList
  248. .waitUntilScreenReady()
  249. .clickAddTopicBtn();
  250. topicCreateEditForm
  251. .waitUntilScreenReady()
  252. .setTopicName("");
  253. assertThat(topicCreateEditForm.isCreateTopicButtonEnabled()).as("isCreateTopicButtonEnabled()").isFalse();
  254. topicCreateEditForm
  255. .setTopicName("testTopic1");
  256. assertThat(topicCreateEditForm.isCreateTopicButtonEnabled()).as("isCreateTopicButtonEnabled()").isTrue();
  257. }
  258. @AfterAll
  259. public void afterAll() {
  260. TOPIC_LIST.forEach(topic -> apiHelper.deleteTopic(CLUSTER_NAME, topic.getName()));
  261. }
  262. }