zzzk1 commented on code in PR #3911: URL: https://github.com/apache/incubator-streampark/pull/3911#discussion_r1690125206
########## streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/setting/env/EmailSettingForm.java: ########## @@ -0,0 +1,100 @@ +/* + * 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.pages.setting.env; + +import lombok.Getter; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +import static org.apache.streampark.e2e.pages.common.CommonFactory.WebElementClick; +import static org.apache.streampark.e2e.pages.common.CommonFactory.WebElementDeleteAndInput; + +@Getter +public class EmailSettingForm extends CommonForm { + + private WebDriver driver; + + @FindBy(id = "SettingForm_host") + private WebElement inputSmtpHost; + + @FindBy(xpath = "//input[@placeholder='Smtp Port']") + private WebElement inputSmtpPort; + + @FindBy(id = "SettingForm_from") + private WebElement inputAddress; + + @FindBy(id = "SettingForm_userName") + private WebElement inputUsername; + + @FindBy(xpath = "//input[@placeholder='Email Password']") + private WebElement inputPassword; + + @FindBy(id = "SettingForm_ssl") + private WebElement btnEnableSSL; + + @FindBy(xpath = "//button[contains(@class, 'ant-btn')]//span[contains(text(), 'OK')]") + private WebElement buttonOk; + + @FindBy(xpath = "//button[contains(@class, 'ant-btn')]//span[contains(text(), 'Cancel')]") + private WebElement buttonCancel; Review Comment: cause test case failed. ########## streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/pages/setting/env/DockerSettingForm.java: ########## @@ -0,0 +1,85 @@ +/* + * 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.pages.setting.env; + +import lombok.Getter; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; + +import static org.apache.streampark.e2e.pages.common.CommonFactory.WebElementClick; +import static org.apache.streampark.e2e.pages.common.CommonFactory.WebElementDeleteAndInput; + +@Getter +public class DockerSettingForm extends CommonForm { + + private WebDriver driver; + + @FindBy(id = "SettingForm_address") + private WebElement inputAddress; + + @FindBy(id = "SettingForm_namespace") + private WebElement inputNamespace; + + @FindBy(id = "SettingForm_username") + private WebElement inputUsername; + + @FindBy(xpath = "//input[@placeholder='Docker Password']") + private WebElement inputPassword; + + @FindBy(xpath = "//button[contains(@class, 'ant-btn')]//span[contains(text(), 'OK')]") + private WebElement buttonOk; + + @FindBy(xpath = "//button[contains(@class, 'ant-btn')]//span[contains(text(), 'Cancel')]") + private WebElement buttonCancel; Review Comment: cause test case failed. ########## streampark-e2e/streampark-e2e-case/src/test/java/org/apache/streampark/e2e/cases/EnvironmentTest.java: ########## @@ -0,0 +1,176 @@ +/* + * 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.setting.SettingPage; +import org.apache.streampark.e2e.pages.setting.env.DockerSettingForm; +import org.apache.streampark.e2e.pages.setting.env.EmailSettingForm; +import org.apache.streampark.e2e.pages.setting.env.EnvironmentDetailForm; +import org.apache.streampark.e2e.pages.setting.env.EnvironmentPage; +import org.apache.streampark.e2e.pages.setting.env.IngressSettingForm; +import org.apache.streampark.e2e.pages.setting.env.MavenSettingForm; + +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.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; +import org.testcontainers.shaded.org.awaitility.Awaitility; + +import static org.assertj.core.api.Assertions.assertThat; + +@StreamPark(composeFiles = "docker/basic/docker-compose.yaml") +public class EnvironmentTest { + + private static RemoteWebDriver browser; + + private static final String userName = "admin"; + + private static final String password = "streampark"; + + private static final String teamName = "default"; + + // maven + final String mavenFilePath = "/maven/file/path"; + final String mavenCentralRepository = "https://mvnrepository.com/"; + final String mavenAuthUser = "maven_user"; + final String mavenAuthPassword = "maven_password"; + + // ingress + final String ingressDomainAddress = "https://localhost"; + + // docker + final String dockerAddress = "https://hub.docker.com/v2/"; + final String dockerNamespace = "hello"; + final String dockerUser = "docker_user"; + final String dockerPassword = "docker_password"; + + // email + final String emailHost = "smtp.163.com"; + final String emailPort = "25"; + final String emailAddress = "[email protected]"; + final String emailUser = "email_password"; + final String emailPassword = "email_password"; + + final @BeforeAll public static void setup() { + new LoginPage(browser) + .login(userName, password, teamName) + .goToNav(SettingPage.class) + .goToTab(EnvironmentPage.class); + } + + @Test + @Order(10) + public void testCreateEnvironment() { + final EnvironmentPage environmentPage = new EnvironmentPage(browser); + + environmentPage.createEnvironment(EnvironmentDetailForm.EnvSettingTypeEnum.Maven) + .<MavenSettingForm>addSetting(EnvironmentDetailForm.EnvSettingTypeEnum.Maven) + .filePath(mavenFilePath) + .centralRepository(mavenCentralRepository) + .authUser(mavenAuthUser) + .authPassword(mavenAuthPassword); + + environmentPage.createEnvironment(EnvironmentDetailForm.EnvSettingTypeEnum.Ingress) + .<IngressSettingForm>addSetting(EnvironmentDetailForm.EnvSettingTypeEnum.Ingress) + .domainAddress(ingressDomainAddress); + + Awaitility.await() + .untilAsserted( + () -> assertThat(environmentPage.settingList()) + .as("Setting list should contain newly-created setting") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(mavenFilePath)) + .anyMatch(it -> it.contains(mavenCentralRepository)) + .anyMatch(it -> it.contains(mavenAuthUser)) + .anyMatch(it -> it.contains(ingressDomainAddress))); + } + + @Test + @Order(20) + public void testCreateEmailSettingFailedWithAuth() { + final EnvironmentPage environmentPage = new EnvironmentPage(browser); + + EmailSettingForm emailSettingForm = + environmentPage.createEnvironment(EnvironmentDetailForm.EnvSettingTypeEnum.Email) + .<EmailSettingForm>addSetting(EnvironmentDetailForm.EnvSettingTypeEnum.Email) + .host(emailHost) + .port(emailPort) + .address(emailAddress) + .user(emailUser) + .password(emailPassword) + .ok(); + + String expectedErrorMessage = + "connect to target mail server failed: 535 Error: authentication failed"; + Awaitility.await() + + .untilAsserted( + () -> { + new WebDriverWait(browser, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION); + assertThat(environmentPage.errorMessageList()) + .as("Connect failed error message should be displayed") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(expectedErrorMessage)); + }); + + new WebDriverWait(browser, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) + .until(ExpectedConditions.elementToBeClickable(environmentPage.errorMessageConfirmButton())); + environmentPage.errorMessageConfirmButton().click(); + emailSettingForm.cancel(); + } + + @Test + @Order(130) + public void testCreateDockerSettingFailed() { + final EnvironmentPage environmentPage = new EnvironmentPage(browser); + + DockerSettingForm dockerSettingForm = + environmentPage.createEnvironment(EnvironmentDetailForm.EnvSettingTypeEnum.Docker) + .<DockerSettingForm>addSetting(EnvironmentDetailForm.EnvSettingTypeEnum.Docker) + .address(dockerAddress) + .namespace(dockerNamespace) + .user(dockerUser) + .password(dockerPassword) + .ok(); + + String expectedErrorMessage = String.format( + "Failed to validate Docker registry, error: Status 500: {\"message\":\"login attempt to %s failed with status: 404 Not Found\"}", + dockerAddress); + Awaitility.await() + + .untilAsserted( + () -> { + new WebDriverWait(browser, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION); + assertThat(environmentPage.errorMessageList()) + .as("Failed to validate docker registry error message should be displayed") + .extracting(WebElement::getText) + .anyMatch(it -> it.contains(expectedErrorMessage)); + }); + + new WebDriverWait(browser, Constants.DEFAULT_WEBDRIVER_WAIT_DURATION) + .until(ExpectedConditions.elementToBeClickable(environmentPage.errorMessageConfirmButton())); + environmentPage.errorMessageConfirmButton().click(); + dockerSettingForm.cancel(); + } +} Review Comment: Can't pass at the same time because `EmailSettingForm#buttonOk()` and `DockerSettingForm#buttonOk()` are unstable? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
