usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [26/50] git commit: modularize tests
Date Thu, 06 Nov 2014 00:15:12 GMT
modularize tests


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/45416984
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/45416984
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/45416984

Branch: refs/heads/two-dot-o
Commit: 45416984b3fa71772d754b2df20942ca7b8ec5c1
Parents: 4e107f3
Author: Shawn Feldman <sfeldman@apache.org>
Authored: Mon Nov 3 11:29:11 2014 -0700
Committer: Shawn Feldman <sfeldman@apache.org>
Committed: Mon Nov 3 11:29:11 2014 -0700

----------------------------------------------------------------------
 .../scenarios/ApplicationScenarios.scala        |  6 +--
 .../scenarios/OrganizationScenarios.scala       | 17 +++++++
 .../PushNotificationTargetUserSimulation.scala  | 52 ++++----------------
 3 files changed, 29 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/45416984/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
index 2db49ff..7d11a49 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
@@ -43,10 +43,10 @@ object ApplicationScenarios {
 
     )
 
-   val checkApplication = exec(http("Create Application")
-     .get(Settings.baseUrl +  "/management/organizations/"+Settings.org+"/applications/"+Settings.app)
+   val checkApplication = exec(http("Get Application")
+     .get(Settings.baseAppUrl)
      .headers(Headers.jsonAnonymous)
-     .check(status.not(400).saveAs("applicationStatus"))
+     .check(status.saveAs("applicationStatus"))
    )
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/45416984/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
index c7ba274..27d23c7 100755
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
@@ -18,6 +18,7 @@
 
 import io.gatling.core.Predef._
 import io.gatling.http.Predef._
+ import org.apache.usergrid.datagenerators.FeederGenerator
  import org.apache.usergrid.settings.{Settings, Headers}
  import scala.concurrent.duration._
 
@@ -41,5 +42,21 @@ object OrganizationScenarios {
       .body(StringBody("{\"organization\":\"" + Settings.org + "\",\"username\":\"" + Settings.admin
+ "\",\"name\":\"${entityName}\",\"email\":\"${entityName}@apigee.com\",\"password\":\"" +
Settings.password + "\"}"))
       .check(status.in(200 to 400))
     )
+  val createOrgBatch =
+    feed(FeederGenerator.generateRandomEntityNameFeeder("org", 1))
+      .exec(OrganizationScenarios.createOrgAndAdmin)
+      .exec(TokenScenarios.getManagementToken)
+      .exec(session => {
+      // print the Session for debugging, don't do that on real Simulations
+      println(session)
+      session
+    })
+      .exec(ApplicationScenarios.createApplication)
+      .exec(NotifierScenarios.createNotifier)
+
+  val createOrgScenario = scenario("Create org")
+    .exec(OrganizationScenarios.createOrgBatch)
+    .inject(atOnceUsers(1))
+    .protocols(http.baseURL(Settings.baseUrl))
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/45416984/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
index 31e78dc..c1143b7 100644
--- a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
@@ -14,11 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- package org.apache.usergrid.simulations
+package org.apache.usergrid.simulations
 
 import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import org.apache.usergrid.settings.Utils
 import org.apache.usergrid.datagenerators.FeederGenerator
 import org.apache.usergrid.scenarios._
 import org.apache.usergrid.settings.Settings
@@ -29,60 +27,28 @@ class PushNotificationTargetUserSimulation extends Simulation {
   val duration:Int = Settings.duration
   val numUsersPerSecond:Int = Settings.numUsers
   val numEntities:Int = numUsersPerSecond * 3 * duration
-  val rampTime:Int = Settings.rampTime
-  val throttle:Int = Settings.throttle
-
   val httpConf = Settings.httpConf.acceptHeader("application/json")
-  val notifier = Settings.pushNotifier
-
-  val createNotifier = NotifierScenarios.createNotifier
-  val createDevice = DeviceScenarios.postDeviceWithNotifier
-  val sendNotification = NotificationScenarios.sendNotificationToUser
-  val createUser = UserScenarios.postUser
-  val createOrg = OrganizationScenarios.createOrgAndAdmin
-  val connectUserToDevice = ConnectionScenarios.postUserToDeviceConnection
-  val createApp = ApplicationScenarios.createApplication
-
-  val getManagementToken = TokenScenarios.getManagementToken
-
-  val getUserToken = TokenScenarios.getUserToken
-
-  val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities)
   val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsersPerSecond *
duration, Settings.userLocationRadius, Settings.centerLatitude, Settings.centerLongitude)
-  val orgFeeder = FeederGenerator.generateRandomEntityNameFeeder("org", 1)
-
-  val scnCreateOrg = scenario("Create org")
-    .feed(orgFeeder)
-    .exec(createOrg)
-    .exec(getManagementToken)
-    .exec(session => {
-      // print the Session for debugging, don't do that on real Simulations
-      println(session)
-      session
-    })
-    .exec(createApp)
-    .exec(createNotifier).inject(atOnceUsers(1))
-    .protocols(http.baseURL(Settings.baseUrl))
 
   val scnToRun = scenario("Create Push Notification")
     .feed(userFeeder)
-    .exec(createUser)
-    .exec(getUserToken)
+    .exec( UserScenarios.postUser)
+    .exec(TokenScenarios.getUserToken)
     .repeat(2){
-      feed(deviceNameFeeder)
-        .exec(createDevice)
-        .exec(connectUserToDevice)
+      feed(FeederGenerator.generateEntityNameFeeder("device", numEntities))
+        .exec( DeviceScenarios.postDeviceWithNotifier)
+        .exec(ConnectionScenarios.postUserToDeviceConnection)
       }
     .exec(session => {
       // print the Session for debugging, don't do that on real Simulations
       println(session)
       session
     })
-    .exec(sendNotification)
+    .exec( NotificationScenarios.sendNotificationToUser)
     .inject(nothingFor(15),constantUsersPerSec(numUsersPerSecond) during (duration))
-    .throttle(reachRps(throttle) in (rampTime.seconds))
+    .throttle(reachRps(Settings.throttle) in ( Settings.rampTime.seconds))
     .protocols(httpConf)
 
-  setUp(scnCreateOrg,scnToRun)
+  setUp(OrganizationScenarios.createOrgScenario,scnToRun)
 
 }


Mime
View raw message