Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update-tests #103

Merged
merged 4 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ See the [wiki](https://github.com/NASA-AMMOS/common-workflow-service/wiki) for m

## Prerequisites

- [**Maven**](https://docs.docker.com/get-docker/): Used to dynamically download libraries and other required project dependencies.
- [**Maven**](https://maven.apache.org/download.cgi): Used to dynamically download libraries and other required project dependencies.
- For Home-brew users:
- Install Maven using: `brew install maven`
- Verify installation using: `mvn -v`
- [**Docker**](https://maven.apache.org/download.cgi): Used to run external Elasticsearch, and create and configure mariaDB database container
- MariaDB or MySQL database set up on either your local machine or a remote host. You will also need to create the following:
- A database for CWS to use. `cws_dev` is a good default name.
- A database user with full access to the above database.
- Recommended minimum system requirements from Docker Resources window:
- [**Docker**](https://docs.docker.com/get-docker/): Used to run external Elasticsearch, and create and configure mariaDB database container
- Recommended minimum system requirements from Docker Resources window:
- CPUs: 4
- Memory: 5.00 GB
- Swap: 1 GB
- Disk image size: 59.6 GB
- MariaDB or MySQL database set up on either your local machine or a remote host. You will also need to create the following:
- A database for CWS to use. `cws_dev` is a good default name.
- A database user with full access to the above database.
- [**ITerm2**](https://iterm2.com/): Currently these build scripts include commands to open new terminal windows using ITerm2, so they are best run from that terminal.
- **Logstash 7.16.2+**: Download Logstash (OSS version) for the Windows platform. Rename the ZIP file from 'logstash-oss-7.16.2-windows-x86_64.zip' to 'logstash-7.16.2.zip' and place in `install/logging/`. This is a temporary workaround while we clean up our installation process. You can find the zip download [here](https://www.elastic.co/downloads/past-releases/logstash-oss-7-16-2).
- **Elasticsearch 7.16.2+**: CWS requires an externally-configured elasticsearch cluster to be set up. You can use an SSL Secure Elasticsearch with or without authentication, or an Insecure HTTP Elasticsearch.
Expand Down
11 changes: 9 additions & 2 deletions cws-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,14 @@
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>


<dependency>
<groupId>io.github.bonigarcia</groupId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the official source for this library?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, according to Selenium documentation

<artifactId>webdrivermanager</artifactId>
<version>5.2.0</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down Expand Up @@ -379,7 +386,7 @@
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>

</project>
11 changes: 4 additions & 7 deletions cws-test/src/test/java/jpl/cws/test/WebTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public class WebTest extends WebTestUtil {
private static final Logger log = LoggerFactory.getLogger(WebTest.class);

@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void loginTest() {
log.info("------ START loginTest ------");
gotoLoginPage();
Expand All @@ -25,7 +24,6 @@ public void loginTest() {
}

@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void deployTest() {
log.info("------ START deployTest ------");
gotoLoginPage();
Expand All @@ -36,7 +34,6 @@ public void deployTest() {
}

@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void runProcessTest() {
log.info("------ START runProcessTest ------");
gotoLoginPage();
Expand All @@ -47,21 +44,21 @@ public void runProcessTest() {
}

private void uploadProcessDefinitionFile() {
WebElement fileUploadInput = findElById("file");
WebElement fileUploadInput = findElById("file-input");
fileUploadInput.sendKeys(TEST_BPMN_DIR+"/test_simplest.bpmn");

WebElement deployProcDefBtn = findElById("deployProcDefBtn");
WebElement deployProcDefBtn = findElById("bpmn-form");
deployProcDefBtn.click();
findOnPage("Deployed process definition");
findOnPage("test_simplest");
}

private void startProcessFromConsole(String procDefKey) {
findOnPage(procDefKey);
WebElement startIcon = findElById("start_"+procDefKey+"_icon");
WebElement startIcon = findElById("pv-external_pwd");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't be hardcoded in here. Please fix this.

log.info("Clicking on " + startIcon);
startIcon.click();
findOnPage("Scheduled the '"+procDefKey+"' process.");
findOnPage("numPending_external_pwd");
}


Expand Down
53 changes: 29 additions & 24 deletions cws-test/src/test/java/jpl/cws/test/WebTestIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public class WebTestIT extends WebTestUtil {


@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void testGoogleSearch() throws InterruptedException, IOException {

driver.get("http://www.google.com");
Expand All @@ -44,7 +43,6 @@ public void testGoogleSearch() throws InterruptedException, IOException {
}

@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void loginTest() {
log.info("------ START loginTest ------");
gotoLoginPage();
Expand All @@ -54,7 +52,6 @@ public void loginTest() {
}

@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void deployTest() {
log.info("------ START deployTest ------");
gotoLoginPage();
Expand All @@ -66,7 +63,6 @@ public void deployTest() {
}

@Test
@Ignore (value="Not portable (specific to Wood/local-setup)")
public void runDeployTest() {
log.info("------ START deployTest ------");
gotoLoginPage();
Expand Down Expand Up @@ -98,7 +94,11 @@ public void runDeployTest() {
WebElement start = driver.findElement(By.xpath("//*[contains(@class,'start-process-action')]"));
start.click();
sleep(5000);


WebElement searchProcessField = driver.findElement(By.xpath("//input[contains(@class,'form-control')]"));
searchProcessField.sendKeys("Test Set Variables");
sleep(5000);

WebElement li = driver.findElement(By.xpath("//*[contains(text(),'Test Set Variables')]"));
li.click();
sleep(5000);
Expand All @@ -111,10 +111,10 @@ public void runDeployTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Dashboard</title>");

findOnPage("<title>CWS - Deployments</title>");

gotoDeployments();

// gotoDeployments();

// Wait for Finish
sleep(25000);
Expand All @@ -124,7 +124,6 @@ public void runDeployTest() {
}

@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void runErrorHandlingTest() {
log.info("------ START deployTest ------");
gotoLoginPage();
Expand Down Expand Up @@ -158,7 +157,11 @@ public void runErrorHandlingTest() {
WebElement start = driver.findElement(By.xpath("//*[contains(@class,'start-process-action')]"));
start.click();
sleep(5000);


WebElement searchProcessField = driver.findElement(By.xpath("//input[contains(@class,'form-control')]"));
searchProcessField.sendKeys("Test Error Handling");
sleep(5000);

WebElement li = driver.findElement(By.xpath("//*[contains(text(),'Test Error Handling')]"));
li.click();
sleep(5000);
Expand All @@ -171,9 +174,9 @@ public void runErrorHandlingTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Dashboard</title>");
findOnPage("<title>CWS - Deployments</title>");

gotoDeployments();
//gotoDeployments();

// Wait for Finish
sleep(90000);
Expand All @@ -184,7 +187,6 @@ public void runErrorHandlingTest() {
}

@Test
@Ignore (value="Not portable (specific to Hasan/local-setup)")
public void runHelloWorldTest() {
log.info("------ START deployTest ------");
gotoLoginPage();
Expand Down Expand Up @@ -219,7 +221,11 @@ public void runHelloWorldTest() {
WebElement start = driver.findElement(By.xpath("//*[contains(@class,'start-process-action')]"));
start.click();
sleep(5000);


WebElement searchProcessField = driver.findElement(By.xpath("//input[contains(@class,'form-control')]"));
searchProcessField.sendKeys("Test Hello World");
sleep(5000);

WebElement li = driver.findElement(By.xpath("//*[contains(text(),'Test Hello World')]"));
li.click();
sleep(5000);
Expand All @@ -232,7 +238,7 @@ public void runHelloWorldTest() {
// Go back to CWS
WebElement cws = driver.findElement(By.xpath("//a[@href='/cws-ui']"));
cws.click();
findOnPage("<title>CWS - Dashboard</title>");
findOnPage("<title>CWS - Deployments</title>");


/*
Expand Down Expand Up @@ -266,7 +272,7 @@ public void runHelloWorldTest() {
sleep(1000);
*/

goToPage("deployments");
// goToPage("deployments");


if(findOnPage("completed")) {
Expand All @@ -285,10 +291,10 @@ public void runHelloWorldTest() {
WebElement filterSubmit = findElById("filter-submit-btn");
filterSubmit.click();
sleep(1000);
WebElement logCheck = findElById("processes-table");
logCheck.click();
sleep(1000);

WebElement historyButton = driver.findElement(By.xpath("//button[contains(text(),'History')]"));
historyButton.click();
sleep(5000);

findOnPage("ls");
findOnPage("Hello World");
Expand All @@ -306,12 +312,11 @@ public void runHelloWorldTest() {
log.info("------ END deployTest ------");
}
@Test
@Ignore (value="Not portable (specific to Hollins/local-setup)")
public void runProcessTest() {
log.info("------ START runProcessTest ------");
gotoLoginPage();
login();
startProcessFromConsole("test_simplest");
startProcessFromConsole("test_set_vars");
logout();
log.info("------ END runProcessTest ------");
}
Expand Down Expand Up @@ -349,10 +354,10 @@ private void uploadErrorHandlingProcessDefinitionFile() {

private void startProcessFromConsole(String procDefKey) {
findOnPage(procDefKey);
WebElement startIcon = findElById("start_"+procDefKey+"_icon");
WebElement startIcon = findElById("pv-test_set_vars");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Model names shouldn't be hardcoded in functions that can be used in different places. Please fix this. Thanks!

log.info("Clicking on " + startIcon);
startIcon.click();
findOnPage("Scheduled the '"+procDefKey+"' process.");
findOnPage("numPending_test_set_vars");
}

//Demo for Sarjil
Expand Down
13 changes: 8 additions & 5 deletions cws-test/src/test/java/jpl/cws/test/WebTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.github.bonigarcia.wdm.WebDriverManager;

/**
*
Expand Down Expand Up @@ -119,13 +120,14 @@ public void quitDriver() {

protected void initChromeDriver() {

//System.setProperty("webdriver.chrome.driver", "/Users/path/to/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();

// Turn on headless mode for Bamboo
chromeOptions.setHeadless(true);
chromeOptions.setHeadless(false);
chromeOptions.setAcceptInsecureCerts(true);

driver = new ChromeDriver(chromeOptions);
WebDriverManager.chromedriver().setup();
driver = new ChromeDriver(chromeOptions);

log.info("Driver initialized: " + driver);
}
Expand Down Expand Up @@ -206,8 +208,9 @@ protected void login() {

protected void logout() {
waitForElementID("logoutLink");
WebElement submitBtn = driver.findElement(By.id("logoutLink")); //findElById("logoutLink");
submitBtn.click();
// WebElement submitBtn = driver.findElement(By.id("logoutLink")); //findElById("logoutLink");
// submitBtn.click();
driver.get("http://"+HOSTNAME+":"+PORT + "/cws-ui/logout");

// Verify we have moved to the login page
findOnPage("Please log in");
Expand Down
40 changes: 20 additions & 20 deletions cws-test/src/test/resources/bpmn/test_simplest.bpmn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://activiti.org/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="__WZTQBNfEeSVM_LOn5uAmg" targetNamespace="http://activiti.org/bpmn">
<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="__WZTQBNfEeSVM_LOn5uAmg" targetNamespace="http://camunda.org/schema/1.0/bpmn" exporter="Camunda Modeler" exporterVersion="4.1.1" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd">
<bpmn2:process id="test_simplest" name="Test Simplest" isExecutable="true">
<bpmn2:startEvent id="StartEvent_1">
<bpmn2:startEvent id="StartEvent_1" camunda:asyncBefore="true">
<bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:endEvent id="EndEvent_1">
Expand All @@ -16,32 +16,32 @@
<bpmn2:incoming>SequenceFlow_1</bpmn2:incoming>
<bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing>
</bpmn2:serviceTask>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="log_message"/>
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="log_message" targetRef="EndEvent_1"/>
<bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="StartEvent_1" targetRef="log_message" />
<bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="log_message" targetRef="EndEvent_1" />
</bpmn2:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="test_simplest">
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ServiceTask_7" targetElement="_BPMNShape_EndEvent_4">
<di:waypoint x="327" y="122" />
<di:waypoint x="343" y="122" />
<di:waypoint x="343" y="203" />
<di:waypoint x="360" y="203" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_4" targetElement="_BPMNShape_ServiceTask_7">
<di:waypoint x="195" y="204" />
<di:waypoint x="211" y="204" />
<di:waypoint x="211" y="122" />
<di:waypoint x="227" y="122" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_4" bpmnElement="StartEvent_1">
<dc:Bounds height="36.0" width="36.0" x="659.0" y="366.0"/>
<dc:Bounds x="159" y="186" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_EndEvent_4" bpmnElement="EndEvent_1">
<dc:Bounds height="36.0" width="36.0" x="860.0" y="365.0"/>
<dc:Bounds x="360" y="185" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_ServiceTask_7" bpmnElement="log_message">
<dc:Bounds height="80.0" width="100.0" x="727.0" y="262.0"/>
<dc:Bounds x="227" y="82" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_StartEvent_4" targetElement="_BPMNShape_ServiceTask_7">
<di:waypoint xsi:type="dc:Point" x="695.0" y="384.0"/>
<di:waypoint xsi:type="dc:Point" x="711.0" y="384.0"/>
<di:waypoint xsi:type="dc:Point" x="711.0" y="302.0"/>
<di:waypoint xsi:type="dc:Point" x="727.0" y="302.0"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ServiceTask_7" targetElement="_BPMNShape_EndEvent_4">
<di:waypoint xsi:type="dc:Point" x="827.0" y="302.0"/>
<di:waypoint xsi:type="dc:Point" x="843.0" y="302.0"/>
<di:waypoint xsi:type="dc:Point" x="843.0" y="383.0"/>
<di:waypoint xsi:type="dc:Point" x="860.0" y="383.0"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn2:definitions>
</bpmn2:definitions>