You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by to...@apache.org on 2014/11/17 21:12:32 UTC
[22/50] [abbrv] incubator-usergrid git commit: check and create
devices
check and create devices
Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/84b83651
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/84b83651
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/84b83651
Branch: refs/heads/two-dot-o-events
Commit: 84b836515ac213d5492788bfa7db55cd7cc5ee2f
Parents: 2fd6716
Author: Shawn Feldman <sf...@apache.org>
Authored: Tue Nov 11 13:00:44 2014 -0700
Committer: Shawn Feldman <sf...@apache.org>
Committed: Tue Nov 11 13:00:44 2014 -0700
----------------------------------------------------------------------
.../usergrid/scenarios/DeviceScenarios.scala | 34 ++++++++--------
.../usergrid/scenarios/UserScenarios.scala | 42 ++++++++++----------
.../org/apache/usergrid/settings/Settings.scala | 2 +-
3 files changed, 41 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/84b83651/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
index ad1b821..9385123 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
@@ -66,22 +66,24 @@ object DeviceScenarios {
/**
* Requires: entityName to feed to the device name. If it exists, it will be created
*/
- val maybeCreateDevice = exec(
+ val maybeCreateDevices = exec(
//try to do a GET on device name, if it 404's create it
- http("Check and create device").get("/devices/${entityName}").headers(Headers.jsonAuthorized).check(status.not(404).saveAs("deviceExists")))
+ http("Check and create device")
+ .get("/users/${username}/devices")
+ .headers(Headers.jsonAuthorized)
+ .check(jsonPath("$.entities").exists, jsonPath("$.entities").saveAs("devices"))
+ )
+ .exec(session =>{
+ println("found "+session.attributes.get("devices").get+ " devices")
+ session
+ } )
//create the device if we got a 404
- .doIf("${deviceExists}", "404") {
-
- exec(
-
- http("Create device and save deviceId").post("/devices").headers(Headers.jsonAuthorized).body(StringBody(
- """{"name":"${entityName}",
- "deviceModel":"Fake Device",
- "deviceOSVerion":"Negative Version",
- "${notifier}.notifier.id":"${entityName}"}"""))
- .check(status.is(200), jsonPath("$.entities[0].uuid").saveAs("deviceId"))
- )
- }
-
-
+ .doIf("${devices}","[]") {
+ exec(session =>{
+ println("adding devices")
+ session
+ } )
+ .exec(postDeviceWithNotifier)
+ .exec(ConnectionScenarios.postUserToDeviceConnection)
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/84b83651/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
index 496079f..6fc5655 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@ -35,34 +35,37 @@ import io.gatling.core.Predef._
http("GET user")
.get("/users/${username}")
.headers(Headers.jsonAuthorized)
- .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
+ .check(status.saveAs("userStatus"), jsonPath("$..entities[0].uuid").exists, jsonPath("$..entities[0].uuid").saveAs("userId"))
)
- val postUser = exec(
- http("POST geolocated Users")
- .post("/users")
- .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ val postUser =
+ exec(getUserByUsername)
+ .doIf ("${userStatus}", "404") {
+ exec(
+ http("POST geolocated Users")
+ .post("/users")
+ .body(new StringBody("""{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
"displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
"height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
"showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
- .check(status.in(200 to 400), status.saveAs("userStatus"))
- .check( jsonPath("$..entities[0].uuid").saveAs("userId"))
- )
- .doIf ("${userStatus}", "400") {
- exec(getUserByUsername)
+ .check(status.saveAs("userStatus"))
+ .check(status.is(200),jsonPath("$..entities[0].uuid").saveAs("userId"))
+ )
}
- val putUser = exec(
- http("POST geolocated Users")
- .put("/users")
- .body(new StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
+ val putUser =
+ exec(getUserByUsername)
+ .doIf("${userStatus}", "200") {
+ exec(
+ http("POST geolocated Users")
+ .put("/users")
+ .body(new StringBody( """{"location":{"latitude":"${latitude}","longitude":"${longitude}"},"username":"${username}",
"displayName":"${displayName}","age":"${age}","seen":"${seen}","weight":"${weight}",
"height":"${height}","aboutMe":"${aboutMe}","profileId":"${profileId}","headline":"${headline}",
"showAge":"${showAge}","relationshipStatus":"${relationshipStatus}","ethnicity":"${ethnicity}","password":"password"}"""))
- .check(status.in(200 to 400), status.saveAs("userStatus"), jsonPath("$..entities[0].uuid").saveAs("userId"))
- )
- .doIf("${userStatus}", "400") {
- exec(getUserByUsername)
+ .check(status.is(200), jsonPath("$..entities[0].uuid").saveAs("userId"))
+
+ )
}
val deleteUserByUsername = exec(
@@ -80,7 +83,6 @@ import io.gatling.core.Predef._
.exec(UserScenarios.getUserByUsername)
.repeat(2){
feed(FeederGenerator.generateEntityNameFeeder("device", Settings.numDevices))
- .exec( DeviceScenarios.postDeviceWithNotifier)
- .exec(ConnectionScenarios.postUserToDeviceConnection)
+ .exec( DeviceScenarios.maybeCreateDevices)
}
}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/84b83651/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
index 3e6b998..570b404 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
@@ -38,7 +38,7 @@ object Settings {
// Simulation settings
- val maxPossibleUsers:Int = Integer.getInteger("maxPossibleUsers", 10).toInt
+ val maxPossibleUsers:Int = Integer.getInteger("maxPossibleUsers", 1).toInt
val numUsers:Int = maxPossibleUsers
val userSeed:Int = Integer.getInteger("userSeed",1).toInt