Merge pull request #558 from provectus/checks/447-creating-topic-via-api

added api interaction to topic test
This commit is contained in:
Bogdan Volodarskiy 2021-07-12 10:32:07 +03:00 committed by GitHub
commit 536d7281dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 105 additions and 5 deletions

View file

@ -48,6 +48,29 @@
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>${openapi-generator-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-kafka-ui-client</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger/kafka-ui-api.yaml
</inputSpec>
<output>${project.build.directory}/generated-sources/kafka-ui-client</output>
<generatorName>java</generatorName>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<configOptions>
<modelPackage>com.provectus.kafka.ui.api.model</modelPackage>
<apiPackage>com.provectus.kafka.ui.api.api</apiPackage>
<sourceFolder>kafka-ui-client</sourceFolder>
<asyncNative>true</asyncNative>
<library>webclient</library>
<useBeanValidation>true</useBeanValidation>
<dateLibrary>java8</dateLibrary>
</configOptions>
</configuration>
</execution>
<execution>
<id>generate-backend-api</id>
<goals>

View file

@ -11,9 +11,11 @@
<artifactId>kafka-ui-e2e-checks</artifactId>
<properties>
<kafka-ui-contract>0.1.1-SNAPSHOT</kafka-ui-contract>
<junit.version>5.7.0</junit.version>
<aspectj.version>1.9.6</aspectj.version>
<allure.version>2.13.7</allure.version>
<json-smart.version>1.1.1</json-smart.version>
<testcontainers.version>1.15.2</testcontainers.version>
<selenide.version>5.16.2</selenide.version>
<assertj.version>3.17.1</assertj.version>
@ -32,6 +34,11 @@
</properties>
<dependencies>
<dependency>
<groupId>net.minidev</groupId>
<artifactId>json-smart</artifactId>
<version>${json-smart.version}</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.13</artifactId>
@ -141,6 +148,12 @@
<artifactId>screen-diff-plugin</artifactId>
<version>${allure.screendiff-plugin.version}</version>
</dependency>
<dependency>
<groupId>com.provectus</groupId>
<artifactId>kafka-ui-contract</artifactId>
<version>${kafka-ui-contract}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View file

@ -2,6 +2,7 @@ package com.provectus.kafka.ui.base;
import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.logevents.SelenideLogger;
import com.provectus.kafka.ui.helpers.Helpers;
import com.provectus.kafka.ui.pages.Pages;
import com.provectus.kafka.ui.screenshots.Screenshooter;
import com.provectus.kafka.ui.steps.Steps;
@ -27,6 +28,7 @@ public class BaseTest {
protected Steps steps = Steps.INSTANCE;
protected Pages pages = Pages.INSTANCE;
protected Helpers helpers = Helpers.INSTANCE;
private Screenshooter screenshooter = new Screenshooter();

View file

@ -0,0 +1,47 @@
package com.provectus.kafka.ui.helpers;
import lombok.SneakyThrows;
import com.provectus.kafka.ui.api.*;
import com.provectus.kafka.ui.api.model.*;
import com.provectus.kafka.ui.api.api.TopicsApi;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class ApiHelper {
int partitions = 1;
int replicationFactor = 1;
String newTopic = "new-topic";
String baseURL = "http://localhost:8080/";
@SneakyThrows
private TopicsApi topicApi(){
ApiClient defaultClient = new ApiClient();
defaultClient.setBasePath(baseURL);
TopicsApi topicsApi = new TopicsApi(defaultClient);
return topicsApi;
}
@SneakyThrows
public void createTopic(String clusterName, String topicName) {
TopicCreation topic = new TopicCreation();
topic.setName(topicName);
topic.setPartitions(partitions);
topic.setReplicationFactor(replicationFactor);
topicApi().createTopic(clusterName,topic).block();
}
@SneakyThrows
public void deleteTopic(String clusterName, String topicName) {
topicApi().deleteTopic(clusterName,topicName).block();
}
}

View file

@ -0,0 +1,11 @@
package com.provectus.kafka.ui.helpers;
public class Helpers {
public static final Helpers INSTANCE = new Helpers();
private Helpers(){}
public ApiHelper apiHelper = new ApiHelper();
}

View file

@ -3,8 +3,12 @@ package com.provectus.kafka.ui.topics;
import com.provectus.kafka.ui.base.BaseTest;
import com.provectus.kafka.ui.pages.MainPage;
import com.provectus.kafka.ui.steps.kafka.KafkaSteps;
import com.provectus.kafka.ui.helpers.ApiHelper;
import lombok.SneakyThrows;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class TopicTests extends BaseTest {
@ -13,18 +17,18 @@ public class TopicTests extends BaseTest {
@AfterEach
@SneakyThrows
void afterEach(){
steps.kafka.deleteTopic(KafkaSteps.Cluster.SECOND_LOCAL,NEW_TOPIC);
void afterEach(){
helpers.apiHelper.deleteTopic("secondLocal","new-topic");
}
@SneakyThrows
@DisplayName("should create a topic")
@Test
void createTopic(){
steps.kafka.createTopic(KafkaSteps.Cluster.SECOND_LOCAL,NEW_TOPIC);
helpers.apiHelper.createTopic("secondLocal","new-topic");
pages.open()
.mainPage.shouldBeOnPage()
.goToSideMenu(KafkaSteps.Cluster.SECOND_LOCAL.getName(), MainPage.SideMenuOptions.TOPICS)
.goToSideMenu("secondLocal", MainPage.SideMenuOptions.TOPICS)
.shouldBeTopic(NEW_TOPIC);
}
}