Skip to content

Commit

Permalink
Adapt tests to the add-project changes in the UI
Browse files Browse the repository at this point in the history
 - minor tweaks regarding container hosts
Change-Id: Ib88cee9eef7560b11311bb7fa3c5717a53219b4c
Reviewed-on: https://bellevue-ci.eng.vmware.com:8080/45958
Closures-Verified: jenkins <[email protected]>
Upgrade-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
PG-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Reviewed-by: Lazarin Lazarov <[email protected]>
  • Loading branch information
Ivan Syarov committed Oct 9, 2018
1 parent 171b42d commit d28cb75
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@
import java.util.Objects;

import com.vmware.admiral.test.ui.pages.CommonWebClient;
import com.vmware.admiral.test.ui.pages.projects.AddProjectModalDialog;
import com.vmware.admiral.test.ui.pages.projects.AddProjectPage;

public class ProjectCommons {

public static void addProject(CommonWebClient<?> client, String name, String description,
boolean isPublic) {
client.projects().projectsPage().clickAddProjectButton();
AddProjectModalDialog addProjectDialog = client.projects().addProjectDialog();
addProjectDialog.waitToLoad();
addProjectDialog.setName(name);
AddProjectPage addProjectPage = client.projects().addProjectPage();
addProjectPage.waitToLoad();
addProjectPage.setName(name);
if (Objects.nonNull(description)) {
addProjectDialog.setDescription(description);
addProjectPage.setDescription(description);
}
if (isPublic) {
addProjectDialog.setIsPublic(true);
addProjectPage.setIsPublic(true);
}
addProjectDialog.submit();
addProjectPage.clickCreateButton();
client.projects().projectsPage().validate().validateProjectIsVisible(name);
}

public static void deleteProject(CommonWebClient<?> client, String projectName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

import org.openqa.selenium.By;

import com.vmware.admiral.test.ui.pages.common.ModalDialog;
import com.vmware.admiral.test.ui.pages.common.BasicPage;

public class AddProjectModalDialog
extends ModalDialog<AddProjectModalDialogValidator, AddProjectModalDialogLocators> {
public class AddProjectPage
extends BasicPage<AddProjectPageValidator, AddProjectPageLocators> {

public AddProjectModalDialog(By[] iFrameLocators, AddProjectModalDialogValidator validator,
AddProjectModalDialogLocators pageLocators) {
public AddProjectPage(By[] iFrameLocators, AddProjectPageValidator validator,
AddProjectPageLocators pageLocators) {
super(iFrameLocators, validator, pageLocators);
}

Expand All @@ -44,4 +44,13 @@ public void closeErrorMessage() {
pageActions().click(locators().alertCloseButton());
}

public void clickCreateButton() {
pageActions().click(locators().createButton());
}

@Override
public void waitToLoad() {
validate().validateIsCurrentPage();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@

import org.openqa.selenium.By;

import com.vmware.admiral.test.ui.pages.common.ModalDialogLocators;
import com.vmware.admiral.test.ui.pages.common.PageLocators;

public class AddProjectModalDialogLocators extends ModalDialogLocators {
public class AddProjectPageLocators extends PageLocators {

private final String PAGE_BASE = "app-project-create";

private final By NAME_INPUT_FIELD = By.id("name");
private final By PAGE_TITLE = By.cssSelector(PAGE_BASE + " .title");
private final By DESCRIPTION_INPUT_FIELD = By.id("description");
private final By PUBLIC_CHECKBOX = By
.cssSelector(".tooltip.tooltip-validation.tooltip-sm[for='isPublic']");
private final By ALERT_TEXT = By.cssSelector(MODAL_BASE + " .alert-text");
.cssSelector(PAGE_BASE + " .tooltip-sm[for='isPublic']");
private final By ALERT_TEXT = By.cssSelector(PAGE_BASE + " .alert-text");
private final By ALERT_CLOSE_BUTTON = By
.cssSelector(MODAL_BASE + " .alert.alert-danger .close");
.cssSelector(PAGE_BASE + " .alert.alert-danger .close");
private final By CREATE_BUTTON = By.cssSelector(PAGE_BASE + " .btn-primary");

public By nameInput() {
return NAME_INPUT_FIELD;
Expand All @@ -45,4 +49,12 @@ public By alertCloseButton() {
return ALERT_CLOSE_BUTTON;
}

public By createButton() {
return CREATE_BUTTON;
}

public By pageTitle() {
return PAGE_TITLE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

import com.vmware.admiral.test.ui.pages.common.PageValidator;

public class AddProjectModalDialogValidator extends PageValidator<AddProjectModalDialogLocators> {
public class AddProjectPageValidator extends PageValidator<AddProjectPageLocators> {

public AddProjectModalDialogValidator(By[] iFrameLocators,
AddProjectModalDialogLocators pageLocators) {
public AddProjectPageValidator(By[] iFrameLocators,
AddProjectPageLocators pageLocators) {
super(iFrameLocators, pageLocators);
}

Expand All @@ -30,7 +30,7 @@ public void validateErrorMessageIsShown() {

@Override
public void validateIsCurrentPage() {
element(locators().modalTitle()).shouldHave(Condition.exactText("New Project"));
element(locators().pageTitle()).shouldHave(Condition.exactText("New Project"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ProjectsPageLibrary(By[] iframeLocators) {
}

private ProjectsPage projectsPage;
private AddProjectModalDialog addProjectDialog;
private AddProjectPage addProjectPage;
private DeleteProjectModalDialog deleteProjectDialog;
private CertificateModalDialog certificateModalDialog;
private ProjectRegistriesTab registriesTab;
Expand All @@ -69,14 +69,14 @@ public ProjectsPage projectsPage() {
return projectsPage;
}

public AddProjectModalDialog addProjectDialog() {
if (Objects.isNull(addProjectDialog)) {
AddProjectModalDialogLocators locators = new AddProjectModalDialogLocators();
AddProjectModalDialogValidator validator = new AddProjectModalDialogValidator(
public AddProjectPage addProjectPage() {
if (Objects.isNull(addProjectPage)) {
AddProjectPageLocators locators = new AddProjectPageLocators();
AddProjectPageValidator validator = new AddProjectPageValidator(
getFrameLocators(), locators);
addProjectDialog = new AddProjectModalDialog(getFrameLocators(), validator, locators);
addProjectPage = new AddProjectPage(getFrameLocators(), validator, locators);
}
return addProjectDialog;
return addProjectPage;
}

public DeleteProjectModalDialog deleteProjectDialog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public class ContainerHost {
private String serverCertificate;
private String clientPrivateKey;
private String clientPublicKey;
private String sshUsername;
private String sshKey;
private AuthKeyType keyType;

public ContainerHost() {
}
Expand Down Expand Up @@ -74,32 +71,11 @@ public String getClientPublicKey() {
return clientPublicKey;
}

public String getSshUsername() {
return sshUsername;
}

public String getSshKey() {
return sshKey;
}

public AuthKeyType getKeyType() {
return keyType;
}

public void setServerCertificate(String serverCertificate) {
Objects.requireNonNull(serverCertificate, "Parameter 'serverCertificate' cannot be null");
this.serverCertificate = serverCertificate;
}

public void setSshCredentials(String sshUsername, String sshKey, AuthKeyType keyType) {
Objects.requireNonNull(sshUsername, "Parameter sshUsername 'sshUsername' cannot be null");
Objects.requireNonNull(sshKey, "Parameter 'sshKey' cannot be null");
Objects.requireNonNull(keyType, "Parameter 'keyType' cannot be null");
this.sshUsername = sshUsername;
this.sshKey = sshKey;
this.keyType = keyType;
}

public void setClientKeyAndCertificate(String clientKey, String clientCertificate) {
Objects.requireNonNull(clientKey, "Parameter 'clientKey' cannot be null");
Objects.requireNonNull(clientCertificate, "Parameter 'clientCertificate' cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,4 @@ public interface ContainerHostProvider {

public void killContainerHost();

public String getVmName();

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public void evaluate() throws Throwable {
PROVIDER.killContainerHost();
} catch (Throwable e) {
LOG.warning(
String.format("Could not kill VM, error: %s,%s", e.getMessage(),
String.format("Could not kill container host, error: %s,%s",
e.getMessage(),
ExceptionUtils.getStackTrace(e)));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public class NimbusPhotonProvider implements ContainerHostProvider {

private final Logger LOG = Logger.getLogger(getClass().getName());

private final String SSH_USERNAME = "root";
private final String SSH_PASSWORD = "VMware1!";
public static final String SSH_USERNAME = "root";
public static final String SSH_PASSWORD = "VMware1!";
private final int DEPLOY_TEMPLATE_TIMEOUT_SECONDS = 720;
private final int KILL_VM_TIMEOUT_SECONDS = 120;
private final String NIMBUS_TARGET = "nimbus-gateway.eng.vmware.com";
Expand Down Expand Up @@ -80,7 +80,6 @@ protected ContainerHost deployContainerHost(Boolean useServerSideSsl,
ContainerHost containerHost = new ContainerHost();
containerHost.setIp(hostIp);
containerHost.setHostType(HostType.DOCKER);
containerHost.setSshCredentials(SSH_USERNAME, SSH_PASSWORD, AuthKeyType.PASSWORD);
executor = SshCommandExecutor.createWithPasswordAuthentication(
hostIp, SSH_USERNAME, SSH_PASSWORD);
if (useServerSideSsl) {
Expand Down Expand Up @@ -194,7 +193,6 @@ private void validateResult(CommandResult result, String errorMessage) {
}
}

@Override
public String getVmName() {
return vmName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,4 @@ private String getIpFromLogs(String logs) {
return ip;
}

@Override
public String getVmName() {
return vmName;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ private void deployUtilityVm() {
ContainerHost host = provider.provide(false, false);
JsonObject json = new JsonObject();
json.addProperty(UtilityVmInfo.IP_FIELD_NAME, host.getIp());
json.addProperty(UtilityVmInfo.USERNAME_FIELD_NAME, host.getSshUsername());
json.addProperty(UtilityVmInfo.PASSWORD_FIELD_NAME, host.getSshKey());
json.addProperty(UtilityVmInfo.USERNAME_FIELD_NAME, NimbusPhotonProvider.SSH_USERNAME);
json.addProperty(UtilityVmInfo.PASSWORD_FIELD_NAME, NimbusPhotonProvider.SSH_PASSWORD);
json.addProperty(UtilityVmInfo.VM_NAME_FIED_NAME, provider.getVmName());
File resourcesDir = new File(UtilityVmInfo.INFO_FILE_RELATIVE_PATH);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import com.vmware.admiral.test.ui.commons.HostCommons;
import com.vmware.admiral.test.ui.commons.ProjectCommons;
import com.vmware.admiral.test.ui.pages.containers.ContainersPage.ContainerState;
import com.vmware.admiral.test.ui.pages.projects.AddProjectModalDialog;
import com.vmware.admiral.test.util.AdmiralEventLogRule;
import com.vmware.admiral.test.util.HostType;
import com.vmware.admiral.test.util.ScreenshotRule;
Expand Down Expand Up @@ -81,17 +80,10 @@ public void globalAndProjectRegistriesTest() {
loginAsAdmin();
main().clickAdministrationTabButton();
administration().clickProjectsButton();
projects().projectsPage().clickAddProjectButton();
AddProjectModalDialog addProjectDialog = projects().addProjectDialog();
addProjectDialog.waitToLoad();
addProjectDialog.setName(FIRST_PROJECT_NAME);
addProjectDialog.submit();

projects().projectsPage().clickAddProjectButton();
addProjectDialog = projects().addProjectDialog();
addProjectDialog.waitToLoad();
addProjectDialog.setName(SECOND_PROJECT_NAME);
addProjectDialog.submit();

ProjectCommons.addProject(getClient(), FIRST_PROJECT_NAME, null, false);

ProjectCommons.addProject(getClient(), SECOND_PROJECT_NAME, null, false);

main().clickHomeTabButton();
home().switchToProject(FIRST_PROJECT_NAME);
Expand Down

0 comments on commit d28cb75

Please sign in to comment.