Skip to content

Commit

Permalink
add feature 3862
Browse files Browse the repository at this point in the history
  • Loading branch information
SbloodyS committed Jul 16, 2024
1 parent 8a2f39f commit c7328ae
Show file tree
Hide file tree
Showing 31 changed files with 1,031 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
const status = parseInt(res.status);
if (status === 0) {
const resp = await fetchCreateCluster(params);
if (resp.data.code == 200) {
Swal.fire({
if (resp) {
await Swal.fire({
icon: 'success',
title: values.clusterName.concat(
t('setting.flinkCluster.operateMessage.createFlinkSessionClusterSuccessful'),
Expand All @@ -64,7 +64,7 @@
});
go('/flink/cluster');
} else {
Swal.fire(
await Swal.fire(
'Failed',
t('setting.flinkCluster.operateMessage.createFlinkSessionClusterFailed'),
'error',
Expand Down
4 changes: 2 additions & 2 deletions streampark-e2e/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
</modules>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<junit.version>5.8.1</junit.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.e2e.cases;

import org.apache.streampark.e2e.core.StreamPark;
import org.apache.streampark.e2e.pages.LoginPage;
import org.apache.streampark.e2e.pages.common.Constants;
import org.apache.streampark.e2e.pages.flink.ApacheFlinkPage;
import org.apache.streampark.e2e.pages.flink.FlinkHomePage;
import org.apache.streampark.e2e.pages.flink.clusters.ClusterDetailForm;
import org.apache.streampark.e2e.pages.flink.clusters.FlinkClustersPage;
import org.apache.streampark.e2e.pages.flink.clusters.YarnSessionForm;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testcontainers.shaded.org.awaitility.Awaitility;

import static org.assertj.core.api.Assertions.assertThat;

@StreamPark(composeFiles = "docker/flink-1.16-on-yarn/docker-compose.yaml")
public class Flink116OnYarnClustersTest {

private static RemoteWebDriver browser;

private static final String userName = "admin";

private static final String password = "streampark";

private static final String teamName = "default";

private static final String flinkName = "flink-1.16.3";

private static final String flinkHome = "/flink-1.16.3";

private static final String flinkDescription = "description test";

private static final String flinkClusterName = "flink_1.16.3_cluster_e2e";

private static final String flinkClusterNameEdited = "flink_1.16.3_cluster_e2e_edited";

private static final ClusterDetailForm.ExecutionMode executionMode = ClusterDetailForm.ExecutionMode.YARN_SESSION;

@BeforeAll
public static void setup() {
FlinkHomePage flinkHomePage = new LoginPage(browser)
.login(userName, password, teamName)
.goToNav(ApacheFlinkPage.class)
.goToTab(FlinkHomePage.class);

flinkHomePage.createFlinkHome(flinkName, flinkHome, flinkDescription);

flinkHomePage.goToNav(ApacheFlinkPage.class)
.goToTab(FlinkClustersPage.class);
}

@Test
@Order(10)
public void testCreateFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.createFlinkCluster()
.<YarnSessionForm>addCluster(executionMode)
.resolveOrder(YarnSessionForm.ResolveOrder.CHILD_FIRST)
.clusterName(flinkClusterName)
.flinkVersion(flinkName)
.submit();

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain newly-created application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains(flinkClusterName)));
}

@Test
@Order(20)
public void testEditFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.editFlinkCluster(flinkClusterName)
.<YarnSessionForm>addCluster(executionMode)
.clusterName(flinkClusterNameEdited)
.submit();

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain edited application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains(flinkClusterNameEdited)));
}

@Test
@Order(30)
public void testStartFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.startFlinkCluster(flinkClusterNameEdited);

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain running application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains("RUNNING")));
}

@Test
@Order(40)
public void testStopFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.stopFlinkCluster(flinkClusterNameEdited);

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain canceled application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains("CANCELED")));
}

@Test
@Order(50)
public void testDeleteFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.deleteFlinkCluster(flinkClusterNameEdited);

Awaitility.await()
.untilAsserted(
() -> {
browser.navigate().refresh();
Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS);
assertThat(flinkClustersPage.flinkClusterList())
.noneMatch(it -> it.getText().contains(flinkClusterNameEdited));
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.streampark.e2e.cases;

import org.apache.streampark.e2e.core.StreamPark;
import org.apache.streampark.e2e.pages.LoginPage;
import org.apache.streampark.e2e.pages.common.Constants;
import org.apache.streampark.e2e.pages.flink.ApacheFlinkPage;
import org.apache.streampark.e2e.pages.flink.FlinkHomePage;
import org.apache.streampark.e2e.pages.flink.clusters.ClusterDetailForm;
import org.apache.streampark.e2e.pages.flink.clusters.FlinkClustersPage;
import org.apache.streampark.e2e.pages.flink.clusters.YarnSessionForm;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testcontainers.shaded.org.awaitility.Awaitility;

import static org.assertj.core.api.Assertions.assertThat;

@StreamPark(composeFiles = "docker/flink-1.17-on-yarn/docker-compose.yaml")
public class Flink117OnYarnClustersTest {

private static RemoteWebDriver browser;

private static final String userName = "admin";

private static final String password = "streampark";

private static final String teamName = "default";

private static final String flinkName = "flink-1.17.2";

private static final String flinkHome = "/flink-1.17.2";

private static final String flinkDescription = "description test";

private static final String flinkClusterName = "flink_1.17.2_cluster_e2e";

private static final String flinkClusterNameEdited = "flink_1.17.2_cluster_e2e_edited";

private static final ClusterDetailForm.ExecutionMode executionMode = ClusterDetailForm.ExecutionMode.YARN_SESSION;

@BeforeAll
public static void setup() {
FlinkHomePage flinkHomePage = new LoginPage(browser)
.login(userName, password, teamName)
.goToNav(ApacheFlinkPage.class)
.goToTab(FlinkHomePage.class);

flinkHomePage.createFlinkHome(flinkName, flinkHome, flinkDescription);

flinkHomePage.goToNav(ApacheFlinkPage.class)
.goToTab(FlinkClustersPage.class);
}

@Test
@Order(10)
public void testCreateFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.createFlinkCluster()
.<YarnSessionForm>addCluster(executionMode)
.resolveOrder(YarnSessionForm.ResolveOrder.CHILD_FIRST)
.clusterName(flinkClusterName)
.flinkVersion(flinkName)
.submit();

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain newly-created application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains(flinkClusterName)));
}

@Test
@Order(20)
public void testEditFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.editFlinkCluster(flinkClusterName)
.<YarnSessionForm>addCluster(executionMode)
.clusterName(flinkClusterNameEdited)
.submit();

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain edited application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains(flinkClusterNameEdited)));
}

@Test
@Order(30)
public void testStartFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.startFlinkCluster(flinkClusterNameEdited);

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain running application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains("RUNNING")));
}

@Test
@Order(40)
public void testStopFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.stopFlinkCluster(flinkClusterNameEdited);

Awaitility.await()
.untilAsserted(
() -> assertThat(flinkClustersPage.flinkClusterList())
.as("Flink clusters list should contain canceled application")
.extracting(WebElement::getText)
.anyMatch(it -> it.contains("CANCELED")));
}

@Test
@Order(50)
public void testDeleteFlinkCluster() {
final FlinkClustersPage flinkClustersPage = new FlinkClustersPage(browser);

flinkClustersPage.deleteFlinkCluster(flinkClusterNameEdited);

Awaitility.await()
.untilAsserted(
() -> {
browser.navigate().refresh();
Thread.sleep(Constants.DEFAULT_SLEEP_MILLISECONDS);
assertThat(flinkClustersPage.flinkClusterList())
.noneMatch(it -> it.getText().contains(flinkClusterNameEdited));
});
}
}
Loading

0 comments on commit c7328ae

Please sign in to comment.