Skip to content

Commit

Permalink
Use a better option to check site and tool pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
juanjmerono committed Jul 28, 2016
1 parent 84892a6 commit b07d6af
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 20 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ There are several things you can tune in this test:

```$mvn test -Dtestname=test-server-x```

- **Instance Name**: Set the name of your instance in order to check html response titles properly.

```$mvn test -DinstanceName=mysakai```

- **Target URL**: You can change the URL for the test by typing

```$mvn test -Dtesturl=https://my-sakai-instance```
Expand Down Expand Up @@ -101,6 +97,7 @@ You can set the log level to review later requests or responses made during test

```$mvn test -DlogLevel=trace```

**NOTE**: You'll find a file with name _${logLevel}.log_ inside the result folder at the end of the simulation.

Exploring the results
=====================
Expand Down
7 changes: 3 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
<version>${gatling-plugin.version}</version>
<configuration>
<runMultipleSimulations>true</runMultipleSimulations>
<runDescription> #${instanceName}(${testname}) RU:[${randomUsers}] EU:[${exhausUsers}] UP:[${rampUpTime}] LOOP:[${userLoop},${siteLoop},${toolLoop}]</runDescription>
<runDescription> #${testname} RU:[${randomUsers}] EU:[${exhausUsers}] UP:[${rampUpTime}] LOOP:[${userLoop},${siteLoop},${toolLoop}] ${feedStrategy}</runDescription>
<resultsFolder>${resultsFolder}</resultsFolder>
<jvmArgs>
<jvmArg>-Dtest-name=${testname}</jvmArg>
Expand All @@ -113,7 +113,6 @@
<jvmArg>-Dsite-loop=${siteLoop}</jvmArg>
<jvmArg>-Dtool-loop=${toolLoop}</jvmArg>
<jvmArg>-Dimpersonate-users=${impersonateUsers}</jvmArg>
<jvmArg>-Dinstance-name=${instanceName}</jvmArg>
<jvmArg>-Dprivate-prefix=${privateCredentials}</jvmArg>
<jvmArg>-Dfeed-strategy=${feedStrategy}</jvmArg>
<jvmArg>-Dlog-level=${logLevel}</jvmArg>
Expand Down Expand Up @@ -142,15 +141,15 @@
<configuration>
<tasks>
<echo>Moving results from temp to definitive folder</echo>
<mkdir dir="target/gatling/${instanceName}/${testname}"/>
<mkdir dir="target/gatling/${testname}"/>
<dirset id="temp.folder" dir="${resultsFolder}" includes="*"/>
<property name="simulation.folder" refid="temp.folder"/>
<move todir="${resultsFolder}/${simulation.folder}">
<fileset dir="${resultsFolder}">
<include name="*.log"/>
</fileset>
</move>
<move todir="target/gatling/${instanceName}/${testname}">
<move todir="target/gatling/${testname}">
<fileset dir="${resultsFolder}">
<include name="**/*"/>
</fileset>
Expand Down
2 changes: 0 additions & 2 deletions src/test/resources/stresstest.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ siteLoop=1
toolLoop=1
# Impersonate Users to bypass credentials
impersonateUsers=false
# Instance Name
instanceName=Sakai
# Private Files
privateCredentials=false
# Feed strategy
Expand Down
16 changes: 6 additions & 10 deletions src/test/scala/computerdatabase/SakaiSimulation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class SakaiSimulation extends Simulation {
val siteLoop: Int = Integer.getInteger("site-loop",1)
val toolLoop: Int = Integer.getInteger("tool-loop",1)
val userLoop: Int = Integer.getInteger("user-loop",1)
val sakaiInstanceName = System.getProperty("instance-name")
val privatePrefix = System.getProperty("private-prefix")

val httpProtocol = http
Expand Down Expand Up @@ -54,7 +53,7 @@ class SakaiSimulation extends Simulation {
val admins = getFeeder(prefix+"admin_credentials.csv",System.getProperty("feed-strategy"))
val jsfViewStateCheck = css("input[name=com\\.sun\\.faces\\.VIEW]", "value").saveAs("viewState")

def join(first: Vector[String], second: Vector[String]) : Vector[(String,String)] = (first zip second.map(s => URLDecoder.decode(s,"UTF-8")))
def join(first: Vector[String], second: Vector[String]) : Vector[(String,String)] = (first.map(s => s.replace("My Workspace","Home")) zip second.map(s => URLDecoder.decode(s,"UTF-8")))
def checkAttrs(cssSelector: String, attrName: String, varName: String) = css(cssSelector,attrName).findAll.saveAs(varName)
def checkElement(cssSelector: String, varName: String) = css(cssSelector).findAll.saveAs(varName)

Expand Down Expand Up @@ -139,7 +138,7 @@ class SakaiSimulation extends Simulation {
.headers(headers)
.check(status.is(successStatus))
.check(checkAttrs("div.fav-title > a","href","siteUrls"))
.check(checkElement("div.fav-title > a > span.fullTitle","siteTitles")))
.check(checkAttrs("div.fav-title > a","title","siteTitles")))
.exec(session => { joinInSession(session,"siteTitles","siteUrls","sites") })
}
}
Expand All @@ -153,7 +152,7 @@ class SakaiSimulation extends Simulation {
.formParam("submit", "Log+In")
.check(status.is(successStatus))
.check(checkAttrs("div.fav-title > a","href","siteUrls"))
.check(checkElement("div.fav-title > a > span.fullTitle","siteTitles")))
.check(checkAttrs("div.fav-title > a","title","siteTitles")))
.pause(pauseMin,pauseMax)
.exec(session => { joinInSession(session,"siteTitles","siteUrls","sites") })
.exec(checkItsMe("${username}"))
Expand All @@ -168,9 +167,8 @@ class SakaiSimulation extends Simulation {
.get("${tool._2}")
.headers(headers)
.check(status.is(successStatus))
.check(css("title").transform( (x,session) => {
x.replace(" : My Workspace : "," : Home : ").indexOf(sakaiInstanceName+" : " + session("site").as[(String,String)]._1 + " : " + session("tool").as[(String,String)]._1)
}).greaterThan(-1))
.check(css("span.Mrphs-hierarchy--siteName","title").is("${site._1}"))
.check(css("a.Mrphs-hierarchy--toolName > span:last-child").is("${tool._1}"))
.check(css("iframe[title]","src").findAll.optional.saveAs("frameUrls"))
.check(css("iframe[title]","title").findAll.optional.saveAs("frameNames")))
.pause(pauseMin,pauseMax)
Expand Down Expand Up @@ -216,9 +214,7 @@ class SakaiSimulation extends Simulation {
.get("${site._2}")
.headers(headers)
.check(status.is(successStatus))
.check(css("title").transform( (x,session) => {
x.replace(" : My Workspace : "," : Home : ").indexOf(sakaiInstanceName+" : " + session("site").as[(String,String)]._1 + " : ")
}).greaterThan(-1))
.check(css("span.Mrphs-hierarchy--siteName","title").is("${site._1}"))
.check(checkAttrs("a[title].Mrphs-toolsNav__menuitem--link","href","toolUrls"))
.check(checkElement("a[title] > span.Mrphs-toolsNav__menuitem--title","toolNames")))
.pause(pauseMin,pauseMax)
Expand Down

0 comments on commit b07d6af

Please sign in to comment.