Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Modify tests for CreateSeries #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion java/run_single_test.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
mvn exec:java -Dexec.mainClass="org.junit.runner.JUnitCore" -Dexec.args="com.rockstor.test.webdriver.CreateShareinGb"
mvn exec:java -Dexec.mainClass="org.junit.runner.JUnitCore" -Dexec.args="com.rockstor.test.webdriver.CreateSeriesTestSuite"

Original file line number Diff line number Diff line change
@@ -1,14 +1,92 @@
package com.rockstor.test.webdriver;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({AddPoolRaid0with2Disks.class,CreateShareinGb.class,
SambaExport.class,NFSExport.class,CreateSnapshotFromShares.class
})

public class CreateSeriesTestSuite {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileInputStream;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.Select; // Dropdown menu
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;// Explicit Waits
import org.openqa.selenium.support.ui.WebDriverWait;
import org.apache.commons.io.FileUtils; // Screenshots
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;

import com.rockstor.test.util.RSProps;
import com.rockstor.test.util.RsUtil;

import java.io.IOException;
import java.util.List;
import java.util.Properties;

//@RunWith(Suite.class)
//@SuiteClasses({AddPoolRaid0with2Disks.class,CreateShareinGb.class,
//SambaExport.class,NFSExport.class,CreateSnapshotFromShares.class
//})

public class CreateSeriesTestSuite extends RsTestBase {

@Test
public void testCreate() throws Exception {
// Pool
String poolName = "pool_" + RsUtil.generateRandomString(10);
int raidLevel = 0;
// Share
String shareName = "share_" + RsUtil.generateRandomString(10);
int shareSizeGb = 1;
// Samba
String adminUser = "admin";
boolean browsable = true;
boolean guestOk = false;
boolean readOnly = false;
String comment = "Samba share";
// NFS
// Snapshot
String snapName = "snap_" + RsUtil.generateRandomString(10);
boolean snapVisible = true;

try {
RsWebUtil.login(driver, RSProps.getProperty("username"),
RSProps.getProperty("password"));

// Create Pool
RsWebUtil.createPool(driver, poolName, raidLevel);

// Create Share
RsWebUtil.createShare(driver, poolName, shareName, shareSizeGb);

// Create Samba export
RsWebUtil.createSambaExport(driver, shareName, adminUser,
browsable, guestOk, readOnly, comment);

// Create NFS export
//RsWebUtil.createNfsExport(driver, shares, hostStr, adminHost,
//writable, sync) {

// Create snapshot
RsWebUtil.createSnapshot(driver, shareName, snapName, snapVisible);

// Logout
RsWebUtil.logout(driver);

} catch(Exception e){
handleException(e);
}

}

}

//CreateUserWebUI.class
//CreateUserWebUI.class
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testShareSizeGb() throws Exception {
RsWebUtil.login(driver, RSProps.getProperty("username"),
RSProps.getProperty("password"));

String poolName = "pool1";
String poolName = "p1";

// Create 3 shares
for (int i=0; i < 3; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,121 +21,32 @@
import org.openqa.selenium.TakesScreenshot;

import com.rockstor.test.util.RSProps;
import com.rockstor.test.util.RsUtil;

import java.io.IOException;
import java.util.List;
import java.util.Properties;


public class CreateSnapshotFromShares {

private static WebDriver driver;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
driver = new FirefoxDriver();
}
public class CreateSnapshotFromShares extends RsTestBase {

@Test
public void testUserNoWebUI() throws Exception {
String shareName = "share1";
String snapName = "snap_" + RsUtil.generateRandomString(10);
boolean visible = true;
try{

driver.get(RSProps.getProperty("RockstorVm"));

//User Login Input Forms
WebElement username = driver.findElement(
By.id("username"));
username.sendKeys("admin");

WebElement password = driver.findElement(
By.id("password"));
password.sendKeys("admin");

WebElement submitButton = driver.findElement(
By.id("sign_in"));
submitButton.click();

// Select Storage from Navigation bar
WebElement systemNav = driver.findElement(By.id("storage_nav"));
systemNav.click();


// Select shares from storage side bar
WebElement sharesNav = driver.findElement(By.xpath("//div[@id='sidebar-inner']/ul/li/a[contains(@href,'shares')]"));
sharesNav.click();

WebElement myWaitElement = (new WebDriverWait(driver, 150))
.until(ExpectedConditions.elementToBeClickable(By.id("add_share")));


// Share link
WebElement shareLink = driver.findElement(By.linkText("share3"));
shareLink.click();

// wait for newshare page to load
myWaitElement = (new WebDriverWait(driver, 150))
.until(ExpectedConditions.elementToBeClickable(By.id("js-delete")));

//Select Snapshot from navigation

WebElement snapNav = driver.findElement(By.xpath("//div/ul/li/a[contains(text(),'Snapshots')]"));
snapNav.click();

// Wait for snapshot page to load
myWaitElement = (new WebDriverWait(driver, 150))
.until(ExpectedConditions.elementToBeClickable(By.id("js-snapshot-add")));

// Create snapshot
WebElement snapshotButton = driver.findElement(By.id("js-snapshot-add"));
snapshotButton.click();

///Fill up Snapshot form

//Snapshot Name
WebElement snapshotName = driver.findElement(By.id("snapshot-name"));
snapshotName.sendKeys("newsnapshot");

// Check box to make visible for users
WebElement makeVisible = driver.findElement(By.cssSelector("input[id='snapshot-visible']"));
makeVisible.click();

// Submit button
WebElement createSnapshot = driver.findElement(By.id("js-snapshot-save"));
createSnapshot.click();

// Wait for snapshot page to load
myWaitElement = (new WebDriverWait(driver, 150))
.until(ExpectedConditions.elementToBeClickable(By.id("js-snapshot-add")));

//verify that snapshot is created
List <WebElement> verifySnapCreated = driver.findElements(
By.xpath("//*[@id='snapshots-table']/tbody/tr[td[contains(text(),'newsnapshot')]]"));
assertEquals(verifySnapCreated.size(), 1);


//Logout
WebElement logoutSubmit = driver.findElement(
By.id("logout_user"));

logoutSubmit.click();


RsWebUtil.login(driver, RSProps.getProperty("username"),
RSProps.getProperty("password"));
RsWebUtil.createSnapshot(driver, shareName, snapName, visible);
RsWebUtil.logout(driver);
}
//catch any exceptions by taking screenshots
catch(Exception e){
File screenshotFile = ((TakesScreenshot)driver)
.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile,
new File(RSProps.getProperty("screenshotDir")
+ "/" + this.getClass().getName()+".png"));
throw e;
handleException(e);
}

}
@AfterClass
public static void tearDownAfterClass() throws Exception {
driver.quit();
}
}


Expand Down
109 changes: 14 additions & 95 deletions java/src/main/java/com/rockstor/test/webdriver/NFSExport.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,113 +18,32 @@

import com.rockstor.test.util.RSProps;

public class NFSExport {

private static WebDriver driver;

@BeforeClass
public static void setUpBeforeClass() throws Exception {
driver = new FirefoxDriver();
}
public class NFSExport extends RsTestBase {

@Test
public void nfsExport() throws Exception {
String shareName = "share1";
String[] shares = new String[] {"share1"};
String hostStr = "192.168.56.101";
String adminHost = "192.168.56.101";
boolean writable = true;
boolean sync = true;
try{

driver.get(RSProps.getProperty("RockstorVm"));

//User Login Input Forms
WebElement username = driver.findElement(
By.id("username"));
username.sendKeys("admin");

WebElement password = driver.findElement(
By.id("password"));
password.sendKeys("admin");

WebElement submitButton = driver.findElement(
By.id("sign_in"));
submitButton.click();

// Select System from Navigation bar
WebElement systemNav = driver.findElement(By.id("storage_nav"));
systemNav.click();

// Select NFS from system side bar
WebElement usersNav = driver.findElement(By.xpath("//div[@class='subnav']/ul/li/a[contains(@href,'nfs-exports')]"));
usersNav.click();

// Wait for add nfs-export button to appear
WebElement myWaitElement = (new WebDriverWait(driver, 150))
.until(ExpectedConditions.elementToBeClickable(
By.id("add-nfs-export")));

WebElement addSambaBtn = driver.findElement(By.id("add-nfs-export"));
addSambaBtn.click();

myWaitElement = (new WebDriverWait(driver, 150))
.until(ExpectedConditions.elementToBeClickable(
By.id("create-nfs-export")));

// Create NFS Export
RsWebUtil.login(driver, RSProps.getProperty("username"),
RSProps.getProperty("password"));

// Fillup form
RsWebUtil.createNfsExport(driver, shares, hostStr, adminHost,
writable, sync);

//Select Share from combo box
Select shareCombobox = new Select(driver.findElement(By.id("shares")));
shareCombobox.selectByValue("share2");

// Host String
WebElement hostString = driver.findElement(By.id("host_str"));
hostString.sendKeys("192.168.1.20");

// Writable
Select guestOk = new Select(driver.findElement(By.id("mod_choice")));
guestOk.selectByIndex(1);

// Sync
Select readOnly = new Select(driver.findElement(By.id("sync_choice")));
readOnly.selectByIndex(0);

submitButton = driver.findElement(By.id("create-nfs-export"));
submitButton.click();

//wait until the page loads
myWaitElement = (new WebDriverWait(driver, 150))
.until(ExpectedConditions.elementToBeClickable(
By.id("add-nfs-export")));

/* WebElement element1 = driver.findElement(By.id("nfs-exports-table"));
List<WebElement> rowCollection = element1.findElements(By.xpath("//*[@id='nfs-exports-table']/tbody/tr/td[contains(.,"+hostString+")]"));
RsWebUtil.logout(driver);


if(rowCollection.size() > 0)
{
assert true;
}

else {

assert false;
}

*/

}
//catch any exceptions by taking screenshots
catch(Exception e){
File screenshotFile = ((TakesScreenshot)driver)
.getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshotFile,
new File(RSProps.getProperty("screenshotDir")
+ "/" + this.getClass().getName()+".png"));
throw e;
handleException(e);
}
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
driver.quit();
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public static void tearDownAfterClass() throws Exception {
}

public void handleException(Exception e) throws Exception {
e.printStackTrace();
// take a screenshot
String filename = this.getClass().getName()+".png";
RsWebUtil.takeScreenshot(driver, filename);
throw e;
Expand Down
Loading