Browse Source
* add worker group manage e2e case * add worker group manage e2e case * Update dolphinscheduler-e2e/dolphinscheduler-e2e-case/src/test/java/org/apache/dolphinscheduler/e2e/cases/WorkerGroupE2ETest.java Co-authored-by: janeHe13 <438044805@qq.com> Co-authored-by: Jiajie Zhong <zhongjiajie955@gmail.com>3.0.0/version-upgrade
janeHe13
3 years ago
committed by
GitHub
8 changed files with 280 additions and 8 deletions
@ -0,0 +1,131 @@ |
|||||||
|
/* |
||||||
|
* Licensed to 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. Apache Software Foundation (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.dolphinscheduler.e2e.cases; |
||||||
|
|
||||||
|
|
||||||
|
import org.apache.dolphinscheduler.e2e.core.DolphinScheduler; |
||||||
|
import org.apache.dolphinscheduler.e2e.pages.LoginPage; |
||||||
|
import org.apache.dolphinscheduler.e2e.pages.security.SecurityPage; |
||||||
|
import org.apache.dolphinscheduler.e2e.pages.security.TenantPage; |
||||||
|
import org.apache.dolphinscheduler.e2e.pages.security.WorkerGroupPage; |
||||||
|
import org.junit.jupiter.api.AfterAll; |
||||||
|
import org.junit.jupiter.api.BeforeAll; |
||||||
|
import org.junit.jupiter.api.Order; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
import org.openqa.selenium.By; |
||||||
|
import org.openqa.selenium.WebElement; |
||||||
|
import org.openqa.selenium.remote.RemoteWebDriver; |
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat; |
||||||
|
import static org.awaitility.Awaitility.await; |
||||||
|
|
||||||
|
@DolphinScheduler(composeFiles = "docker/basic/docker-compose.yaml") |
||||||
|
class WorkerGroupE2ETest { |
||||||
|
private static final String tenant = System.getProperty("user.name"); |
||||||
|
private static final String workerGroupName = "test_worker_group"; |
||||||
|
private static final String editWorkerGroupName = "edit_worker_group"; |
||||||
|
|
||||||
|
private static RemoteWebDriver browser; |
||||||
|
|
||||||
|
@BeforeAll |
||||||
|
public static void setup() { |
||||||
|
new LoginPage(browser) |
||||||
|
.login("admin", "dolphinscheduler123") |
||||||
|
.goToNav(SecurityPage.class) |
||||||
|
.goToTab(TenantPage.class) |
||||||
|
.create(tenant) |
||||||
|
.goToNav(SecurityPage.class) |
||||||
|
.goToTab(WorkerGroupPage.class); |
||||||
|
} |
||||||
|
|
||||||
|
@AfterAll |
||||||
|
public static void cleanup() { |
||||||
|
new SecurityPage(browser) |
||||||
|
.goToTab(TenantPage.class) |
||||||
|
.delete(tenant) |
||||||
|
; |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
@Order(1) |
||||||
|
void testCreateWorkerGroup() throws InterruptedException { |
||||||
|
final WorkerGroupPage page = new WorkerGroupPage(browser); |
||||||
|
|
||||||
|
page.create(workerGroupName); |
||||||
|
|
||||||
|
await().untilAsserted(() -> { |
||||||
|
browser.navigate().refresh(); |
||||||
|
|
||||||
|
assertThat(page.workerGroupList()) |
||||||
|
.as("workerGroup list should contain newly-created workerGroup") |
||||||
|
.extracting(WebElement::getText) |
||||||
|
.anyMatch(it -> it.contains(workerGroupName)); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
@Order(20) |
||||||
|
void testCreateDuplicateWorkerGroup() throws InterruptedException { |
||||||
|
final WorkerGroupPage page = new WorkerGroupPage(browser); |
||||||
|
|
||||||
|
page.create(workerGroupName); |
||||||
|
|
||||||
|
await().untilAsserted(() -> |
||||||
|
assertThat(browser.findElement(By.tagName("body")).getText()) |
||||||
|
.contains("already exists") |
||||||
|
); |
||||||
|
|
||||||
|
page.createWorkerForm().buttonCancel().click(); |
||||||
|
} |
||||||
|
|
||||||
|
@Test |
||||||
|
@Order(30) |
||||||
|
void testEditWorkerGroup() { |
||||||
|
final WorkerGroupPage page = new WorkerGroupPage(browser); |
||||||
|
page.update(workerGroupName, editWorkerGroupName); |
||||||
|
|
||||||
|
await().untilAsserted(() -> { |
||||||
|
browser.navigate().refresh(); |
||||||
|
assertThat(page.workerGroupList()) |
||||||
|
.as("workerGroup list should contain newly-modified workerGroup") |
||||||
|
.extracting(WebElement::getText) |
||||||
|
.anyMatch(it -> it.contains(editWorkerGroupName)); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@Test |
||||||
|
@Order(40) |
||||||
|
void testDeleteWorkerGroup() { |
||||||
|
final WorkerGroupPage page = new WorkerGroupPage(browser); |
||||||
|
|
||||||
|
page.delete(editWorkerGroupName); |
||||||
|
|
||||||
|
await().untilAsserted(() -> { |
||||||
|
browser.navigate().refresh(); |
||||||
|
|
||||||
|
assertThat( |
||||||
|
page.workerGroupList() |
||||||
|
).noneMatch( |
||||||
|
it -> it.getText().contains(workerGroupName) || it.getText().contains(editWorkerGroupName) |
||||||
|
); |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,129 @@ |
|||||||
|
/* |
||||||
|
* Licensed to 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. Apache Software Foundation (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.dolphinscheduler.e2e.pages.security; |
||||||
|
|
||||||
|
import lombok.Getter; |
||||||
|
import org.apache.dolphinscheduler.e2e.pages.common.NavBarPage; |
||||||
|
import org.openqa.selenium.By; |
||||||
|
import org.openqa.selenium.WebElement; |
||||||
|
import org.openqa.selenium.remote.RemoteWebDriver; |
||||||
|
import org.openqa.selenium.support.FindBy; |
||||||
|
import org.openqa.selenium.support.FindBys; |
||||||
|
import org.openqa.selenium.support.PageFactory; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
|
||||||
|
@Getter |
||||||
|
public final class WorkerGroupPage extends NavBarPage implements SecurityPage.Tab { |
||||||
|
@FindBy(id = "btnCreateWorkerGroup") |
||||||
|
private WebElement buttonCreateWorkerGroup; |
||||||
|
|
||||||
|
@FindBy(className = "items") |
||||||
|
private List<WebElement> workerGroupList; |
||||||
|
|
||||||
|
@FindBys({ |
||||||
|
@FindBy(className = "el-popconfirm"), |
||||||
|
@FindBy(className = "el-button--primary"), |
||||||
|
}) |
||||||
|
private List<WebElement> buttonConfirm; |
||||||
|
|
||||||
|
private final WorkerGroupForm createWorkerForm = new WorkerGroupForm(); |
||||||
|
private final WorkerGroupForm editWorkerForm = new WorkerGroupForm(); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public WorkerGroupPage(RemoteWebDriver driver) { |
||||||
|
super(driver); |
||||||
|
} |
||||||
|
|
||||||
|
public WorkerGroupPage create(String workerGroupName) { |
||||||
|
buttonCreateWorkerGroup().click(); |
||||||
|
|
||||||
|
createWorkerForm().inputWorkerGroupName().sendKeys(workerGroupName); |
||||||
|
createWorkerForm().selectWorkerAddress().click(); |
||||||
|
createWorkerForm().workerAddressList().click(); |
||||||
|
|
||||||
|
createWorkerForm().buttonSubmit().click(); |
||||||
|
|
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
public WorkerGroupPage update(String workerGroupName, String editWorkerGroupName) { |
||||||
|
workerGroupList() |
||||||
|
.stream() |
||||||
|
.filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(workerGroupName)) |
||||||
|
.flatMap(it -> it.findElements(By.className("edit")).stream()) |
||||||
|
.filter(WebElement::isDisplayed) |
||||||
|
.findFirst() |
||||||
|
.orElseThrow(() -> new RuntimeException("No edit button in workerGroup list")) |
||||||
|
.click(); |
||||||
|
|
||||||
|
editWorkerForm().inputWorkerGroupName().clear(); |
||||||
|
editWorkerForm().inputWorkerGroupName().sendKeys(editWorkerGroupName); |
||||||
|
|
||||||
|
editWorkerForm().buttonSubmit().click(); |
||||||
|
|
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public WorkerGroupPage delete(String Worker) { |
||||||
|
workerGroupList() |
||||||
|
.stream() |
||||||
|
.filter(it -> it.findElement(By.className("name")).getAttribute("innerHTML").contains(Worker)) |
||||||
|
.flatMap(it -> it.findElements(By.className("delete")).stream()) |
||||||
|
.filter(WebElement::isDisplayed) |
||||||
|
.findFirst() |
||||||
|
.orElseThrow(() -> new RuntimeException("No delete button in workerGroup list")) |
||||||
|
.click(); |
||||||
|
|
||||||
|
buttonConfirm() |
||||||
|
.stream() |
||||||
|
.filter(WebElement::isDisplayed) |
||||||
|
.findFirst() |
||||||
|
.orElseThrow(() -> new RuntimeException("No confirm button when deleting")) |
||||||
|
.click(); |
||||||
|
|
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
@Getter |
||||||
|
public class WorkerGroupForm { |
||||||
|
WorkerGroupForm() { |
||||||
|
PageFactory.initElements(driver, this); |
||||||
|
} |
||||||
|
|
||||||
|
@FindBy(id = "inputWorkerGroupName") |
||||||
|
private WebElement inputWorkerGroupName; |
||||||
|
|
||||||
|
@FindBy(id = "selectWorkerAddress") |
||||||
|
private WebElement selectWorkerAddress; |
||||||
|
|
||||||
|
@FindBy(className = "vue-treeselect__menu") |
||||||
|
private WebElement workerAddressList; |
||||||
|
|
||||||
|
@FindBy(id = "btnSubmit") |
||||||
|
private WebElement buttonSubmit; |
||||||
|
|
||||||
|
@FindBy(id = "btnCancel") |
||||||
|
private WebElement buttonCancel; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue