-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Plugin infrastructure * Last plugin architecture changes * Adjust some differences.
- Loading branch information
1 parent
81009be
commit a267021
Showing
8 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import java.io._ | ||
import plugins._ | ||
import io.gatling.core.Predef._ | ||
import io.gatling.core.structure._ | ||
|
||
class SakaiPluginManager { | ||
|
||
var pluginMap = Map[Any, ChainBuilder]() | ||
|
||
def getPlugins(dir: File, extensions: List[String]): List[File] = { | ||
dir.listFiles.filter(_.isFile).toList.filter(!_.getName.equals("SakaiSimulationPlugin.scala")).filter { file => | ||
extensions.exists(file.getName.endsWith(_)) | ||
} | ||
} | ||
|
||
def init() { | ||
println("Loading simulation plugins...") | ||
// We need at least 2 options to work with Switch | ||
pluginMap += ( "at-least-we-need-2a" -> exec() ) | ||
pluginMap += ( "at-least-we-need-2b" -> exec() ) | ||
val files = getPlugins(new File("./src/test/scala/computerdatabase/plugins"),List("scala")) | ||
files.foreach( | ||
f => try { | ||
val className = f.getName.replace(".scala","") | ||
val pluginObj = Class.forName("plugins."+className).newInstance.asInstanceOf[SakaiSimulationPlugin] | ||
if (pluginObj.name.matches(System.getProperty("allow-plugins"))) { | ||
if (pluginMap.contains( pluginObj.toolid ) ) { | ||
pluginMap += ( pluginObj.toolid -> exec( pluginMap(pluginObj.toolid) , pluginObj.getSimulationChain ) ) | ||
} else { | ||
pluginMap += ( pluginObj.toolid -> pluginObj.getSimulationChain ) | ||
} | ||
println("Plugin ["+className+","+pluginObj.name+"] loaded !") | ||
} | ||
} catch { | ||
case e: Exception => {} | ||
} | ||
) | ||
} | ||
|
||
def getPluginMap : List[(Any,ChainBuilder)] = { | ||
pluginMap.toList | ||
} | ||
|
||
init() | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/test/scala/computerdatabase/plugins/SakaiAnnouncementsPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package plugins | ||
|
||
import io.gatling.core.Predef._ | ||
import io.gatling.http.Predef._ | ||
|
||
class SakaiAnnouncementsPlugin extends SakaiSimulationPlugin { | ||
|
||
def name(): String = { "announcements-list-options" } | ||
|
||
def description(): String = { "List options announcements" } | ||
|
||
def toolid(): String = { "sakai-announcements" } | ||
|
||
def getSimulationChain = | ||
group("AnnouncementsListOptions") { | ||
exec(http("Announcements") | ||
.get("${tool._2}") | ||
.headers(headers) | ||
.check(status.is(successStatus)) | ||
.check(css("span.Mrphs-hierarchy--siteName","title").is("${site._1}")) | ||
.check(css("a.Mrphs-hierarchy--toolName > span[class*='${tool._1}'].Mrphs-breadcrumb--icon").exists) | ||
.check(css("a[onclick*='doOptions']","onclick").transform(_.replace("location = '","").replace("';return false;","")).optional.saveAs("annc_options"))) | ||
.doIf("${annc_options.exists()}") { | ||
exec(http("GetOptions") | ||
.get("${annc_options}") | ||
.headers(headers) | ||
.check(status.is(successStatus)) | ||
.check(css("span.Mrphs-hierarchy--siteName","title").is("${site._1}")) | ||
.check(css("a.Mrphs-hierarchy--toolName > span[class*='${tool._1}'].Mrphs-breadcrumb--icon").exists) | ||
.check(css("form[name='optionsForm']").exists)) | ||
.exec(session => { session.remove("annc_options") }) | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/test/scala/computerdatabase/plugins/SakaiResourcesPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package plugins | ||
|
||
import io.gatling.core.Predef._ | ||
import io.gatling.http.Predef._ | ||
|
||
class SakaiResourcesPlugin extends SakaiSimulationPlugin { | ||
|
||
def name(): String = { "resources-options" } | ||
|
||
def description(): String = { "List options in resources" } | ||
|
||
def toolid(): String = { "sakai-resources" } | ||
|
||
def getSimulationChain = | ||
group("ResourcesListOptions") { | ||
exec(http("Resources") | ||
.get("${tool._2}") | ||
.headers(headers) | ||
.check(status.is(successStatus)) | ||
.check(css("span.Mrphs-hierarchy--siteName","title").is("${site._1}")) | ||
.check(css("a.Mrphs-hierarchy--toolName > span[class*='${tool._1}'].Mrphs-breadcrumb--icon").exists) | ||
.check(css("a[href*='doOptions']","href").optional.saveAs("resources_options"))) | ||
.doIf("${resources_options.exists()}") { | ||
exec(http("GetOptions") | ||
.get("${annc_options}") | ||
.headers(headers) | ||
.check(status.is(successStatus)) | ||
.check(css("span.Mrphs-hierarchy--siteName","title").is("${site._1}")) | ||
.check(css("a.Mrphs-hierarchy--toolName > span[class*='${tool._1}'].Mrphs-breadcrumb--icon").exists) | ||
.check(css("form[name='optionsForm']").exists)) | ||
.exec(session => { session.remove("resources_options") }) | ||
} | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/test/scala/computerdatabase/plugins/SakaiSimulationPlugin.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package plugins | ||
|
||
import io.gatling.core.Predef._ | ||
import io.gatling.core.structure._ | ||
|
||
trait SakaiSimulationPlugin { | ||
|
||
val headers = Map( | ||
"Accept" -> "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", | ||
"Accept-Encoding" -> "gzip, deflate, sdch, br", | ||
"Accept-Language" -> "es-ES,es;q=0.8,en;q=0.6", | ||
"Cache-Control" -> "max-age=0", | ||
"Connection" -> "keep-alive", | ||
"Upgrade-Insecure-Requests" -> "1") | ||
|
||
val successStatus: Int = 200 | ||
|
||
def name: String | ||
def description: String | ||
def toolid: String | ||
def getSimulationChain: ChainBuilder | ||
} |