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/10/23 19:18:56 UTC
[3/5] Refactored and moved to the load tests
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala
deleted file mode 100755
index 843bc2e..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/scenarios/UserScenarios.scala
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-
-object UserScenarios {
-
- val getRandomUser = exec(
- http("GET user")
- .get("/users/user" + Utils.generateRandomInt(1, Settings.numEntities))
- .check(status.is(200))
- )
-
- val postUser = exec(
- http("POST geolocated Users")
- .post("/users")
- .body(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.is(200))
- )
-
- val postUser400ok = exec(
- http("POST geolocated Users")
- .post("/users")
- .body(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))
- )
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala
deleted file mode 100755
index 319bdcf..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Headers.scala
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-/**
- *
- */
-object Headers {
-
- /**
- * Headers for anonymous posts
- */
- val jsonAnonymous = Map(
- "Cache-Control" -> """no-cache""",
- "Content-Type" -> """application/json; charset=UTF-8"""
- )
-
- /**
- * Headers for authorized users with token and json content type
- */
- val jsonAuthorized = Map(
- "Cache-Control" -> """no-cache""",
- "Content-Type" -> """application/json; charset=UTF-8""",
- "Authorization" -> "Bearer ${authToken}"
- )
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala
deleted file mode 100755
index 5588b67..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Settings.scala
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-object Settings {
-
- // Target settings
- val org = System.getProperty("org")
- val app = System.getProperty("app")
- val baseUrl = System.getProperty("baseurl")
- val httpConf = http.baseURL(baseUrl + "/" + org + "/" + app)
-
- // Simulation settings
- val numUsers:Int = Integer.getInteger("numUsers", 10).toInt
- val numEntities:Int = Integer.getInteger("numEntities", 5000).toInt
- val numDevices:Int = Integer.getInteger("numDevices", 2000).toInt
-
- val rampTime:Int = Integer.getInteger("rampTime", 0).toInt // in seconds
- val duration:Int = Integer.getInteger("duration", 300).toInt // in seconds
- val throttle:Int = Integer.getInteger("throttle", 50).toInt // in seconds
-
- // Geolocation settings
- val centerLatitude:Double = 37.442348 // latitude of center point
- val centerLongitude:Double = -122.138268 // longitude of center point
- val userLocationRadius:Double = 32000 // location of requesting user in meters
- val geosearchRadius:Int = 8000 // search area in meters
-
- // Push Notification settings
- val pushNotifier = System.getProperty("notifier")
- val pushProvider = System.getProperty("provider")
-
- def createRandomPushNotifier:String = {
- return Utils.generateUniqueName("notifier")
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala
deleted file mode 100755
index 396f0b9..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/settings/Utils.scala
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import scala.util.Random
-import scala.math
-import Array._
-
-/**
- *
- * Utility for creating various data elements
- *
- */
-object Utils {
-
- private val RNG = new Random
-
- /**
- * Generate a new uuid and replace the '-' with empty
- */
- def generateUUIDString(): String = {
- return java.util.UUID.randomUUID.toString.replace("-", "")
- }
-
- /**
- * Generate a unique string with a prefix
- *
- * @param prefix
- * @return
- */
- def generateUniqueName(prefix : String): String = {
- return prefix + generateUUIDString()
- }
-
- // random number in between [a...b]
- def generateRandomInt(lowerBound: Int, upperBound: Int) = RNG.nextInt(upperBound - lowerBound) + lowerBound
-
- def generateRandomGeolocation(radius: Double, centerLatitude: Double, centerLongitude: Double):Map[String, String] = {
-
- var rd = radius / 111300 // Convert Radius from meters to degrees.
- var u = RNG.nextFloat()
- var v = RNG.nextFloat()
- var q = math.sqrt(u) * rd
- var w = q * rd
- var t = 2 * math.Pi * v
- var x = math.cos(t) * w
- var y = math.sin(t) * w
- var xp = x/math.cos(centerLatitude)
- var latitude = (y + centerLatitude).toString
- var longitude = (xp + centerLongitude).toString
- var geolocation: Map[String, String] = Map("latitude"->latitude,"longitude"->longitude)
-
- return geolocation
- }
-
- def generateRandomQueryString: String = {
-
- val queryParams = Array("age", "height", "weight")
- var queryString = ""
-
- for (numParams <- 1 to generateRandomInt(1, queryParams.length)) {
- queryString = "age=" + Utils.generateRandomInt(18, 65).toString
- if (numParams == 2) {
- queryString += "%20AND%20height=" + Utils.generateRandomInt(48, 84).toString
- } else if (numParams == 3) {
- queryString += "%20AND%20weight=" + Utils.generateRandomInt(120, 350).toString
- }
- }
-
- return queryString
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
deleted file mode 100644
index ac9bb7f..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class GetEntitySimulation extends Simulation {
-
- // Target settings
- val httpConf = Settings.httpConf
-
- // Simulation settings
- val numUsers:Int = Settings.numUsers
- val numEntities:Int = Settings.numEntities
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
-
- val feeder = FeederGenerator.generateEntityNameFeeder("user", numEntities).circular
-
- val scnToRun = scenario("GET entity")
- .exec(UserScenarios.getRandomUser)
-
- setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf)).maxDuration(Settings.duration)
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
deleted file mode 100755
index 0c47a32..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class PostDevicesSimulation extends Simulation {
-
- // Target settings
- val httpConf = Settings.httpConf
-
- // Simulation settings
- val numUsers:Int = Settings.numUsers
- val numEntities:Int = Settings.numEntities
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
-
- val feeder = FeederGenerator.generateEntityNameFeeder("device", numEntities)
-
- val scnToRun = scenario("POST device")
- .feed(feeder)
- .exec(DeviceScenarios.postDeviceWithNotifier)
-
- setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
deleted file mode 100755
index b49afc7..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class PostUsersSimulation extends Simulation {
-
- // Target settings
- val httpConf = Settings.httpConf
-
- // Simulation settings
- val numUsers:Int = Settings.numUsers
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
-
- // Geolocation settings
- val centerLatitude:Double = Settings.centerLatitude
- val centerLongitude:Double = Settings.centerLongitude
- val userLocationRadius:Double = Settings.userLocationRadius
- val geosearchRadius:Int = Settings.geosearchRadius
-
- val feeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude).queue
-
- val scnToRun = scenario("POST geolocated users")
- .feed(feeder)
- .exec(UserScenarios.postUser)
-
- setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
deleted file mode 100755
index 66b3c5d..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-/**
- *
- * Simple test for setting up multiple orgs and creating push notifications
- *
- */
-class PushNotificationTargetDeviceSimulation extends Simulation {
-
- val numUsers:Int = Settings.numUsers
- val numEntities:Int = Settings.numEntities
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
- val duration:Int = Settings.duration
- val httpConf = Settings.httpConf
- .acceptHeader("application/json")
-
- val createNotifier = NotifierScenarios.createNotifier
- val createDevice = DeviceScenarios.postDeviceWithNotifier
- val sendNotification = NotificationScenarios.sendNotification
-
- val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities).circular
-
- val scnToRun = scenario("Create Push Notification")
- .during(duration.seconds) {
- feed(deviceNameFeeder)
- .exec(sendNotification)
- }
-
-
- setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala b/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
deleted file mode 100644
index 67ee20a..0000000
--- a/stack/loadtests/simulations/test/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.apache.usergrid
-
-import io.gatling.core.Predef._
-import io.gatling.http.Predef._
-import scala.concurrent.duration._
-
-class PushNotificationTargetUserSimulation extends Simulation {
-
- val numUsers:Int = Settings.numUsers
- val numEntities:Int = Settings.numEntities
- val rampTime:Int = Settings.rampTime
- val throttle:Int = Settings.throttle
- val duration:Int = Settings.duration
- val httpConf = Settings.httpConf.acceptHeader("application/json")
-
- val notifier = Settings.pushNotifier
- val createDevice = DeviceScenarios.postDeviceWithNotifier400ok
- val sendNotification = NotificationScenarios.sendNotification
- val createUser = UserScenarios.postUser400ok
- val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities).circular
- val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numEntities, Settings.userLocationRadius, Settings.centerLatitude, Settings.centerLongitude)
-
- val scnToRun = scenario("Create Push Notification")
- .feed(userFeeder)
- .exec(createUser)
-// .pause(1000)
- .exec(http("Check user and user devices")
- .get("/users/${username}/devices")
- .check(status.is(200))
- )
- .feed(deviceNameFeeder)
- .exec(createDevice)
-// .pause(1000)
- .exec(http("Check device connections")
- .get("/devices/${entityName}/users")
- .check(status.is(200))
- )
- .exec(http("Connect user with device")
- .post("/users/${username}/devices/${deviceId}")
- .check(status.is(200))
- )
- .exec(http("Send Notification to All Devices")
- .post("/users/${username}/notifications")
- .body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
- .check(status.is(200))
- )
-
-
- setUp(scnToRun.inject(constantUsersPerSec(numUsers) during (duration)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
new file mode 100755
index 0000000..4a6ef3d
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/EntityDataGenerator.scala
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.datagenerators
+
+ import org.apache.usergrid.settings.Utils
+
+ import scala.collection.mutable.ArrayBuffer
+
+object EntityDataGenerator {
+
+ def generateBlockUserLists(numUsers: Int): Map[String, String] = {
+
+ var blocks: ArrayBuffer[String] = new ArrayBuffer[String]
+ var blockedBy: ArrayBuffer[String] = new ArrayBuffer[String]
+
+ for (numBlock <- 1 to Utils.generateRandomInt(1, 7)) {
+ blocks += "user".concat(Utils.generateRandomInt(1, numUsers).toString)
+ }
+
+ for (numBlockedBy <- 1 to Utils.generateRandomInt(1, 7)) {
+ blockedBy += "user".concat(Utils.generateRandomInt(1, numUsers).toString)
+ }
+
+ return Map("blocks" -> blocks.toArray.mkString(","), "blockedBy" -> blockedBy.toArray.mkString(","))
+
+ }
+
+ def generateUser(userId: Int): Map[String,String] = {
+
+ return Map("username" -> "user".concat(userId.toString),
+ "profileId" -> Utils.generateRandomInt(10000, 1000000).toString,
+ "displayName" -> Utils.generateRandomInt(10000, 1000000).toString,
+ "showAge" -> Utils.generateRandomInt(0, 1).toString,
+ "ethnicity" -> Utils.generateRandomInt(1, 15).toString,
+ "relationshipStatus" -> Utils.generateRandomInt(1, 4).toString,
+ "headline" -> "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
+ "aboutMe" -> "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
+ "age" -> Utils.generateRandomInt(18, 65).toString,
+ "height" -> Utils.generateRandomInt(48, 84).toString,
+ "weight" -> Utils.generateRandomInt(120, 350).toString,
+ "seen" -> Utils.generateRandomInt(50, 100000).toString
+ )
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
new file mode 100755
index 0000000..8bedb01
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/datagenerators/FeederGenerator.scala
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.datagenerators
+
+import io.gatling.core.Predef._
+ import org.apache.usergrid.settings.Utils
+ import scala.collection.mutable.ArrayBuffer
+
+object FeederGenerator {
+
+ def generateUserWithGeolocationFeeder(numUsers: Int, radius: Double, centerLatitude: Double, centerLongitude: Double): Array[Map[String, String]] = {
+ var userArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
+ for (userCount <- 1 to numUsers) {
+ var user: Map[String, String] = EntityDataGenerator.generateUser(userCount)
+ var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
+ var blockLists: Map[String, String] = EntityDataGenerator.generateBlockUserLists(numUsers)
+
+ user = user ++ geolocation ++ blockLists
+
+ userArray += user
+ }
+ return userArray.toArray
+ }
+
+ def generateGeolocationFeeder(radius: Double, centerLatitude: Double, centerLongitude: Double): Feeder[String] = {
+
+ val geolocationFeeder = new Feeder[String] {
+
+ // always return true as this feeder can be polled infinitively
+ override def hasNext = true
+
+ override def next: Map[String, String] = {
+ var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
+ Map("latitude" -> geolocation("latitude"), "longitude" -> geolocation("longitude"))
+ }
+ }
+
+ return geolocationFeeder
+
+ }
+
+ def generateGeolocationWithQueryFeeder(radius: Double, centerLatitude: Double, centerLongitude: Double): Feeder[String] = {
+
+ val geolocationFeeder = new Feeder[String] {
+
+ // always return true as this feeder can be polled infinitively
+ override def hasNext = true
+
+ override def next: Map[String, String] = {
+ var geolocation: Map[String, String] = Utils.generateRandomGeolocation(radius, centerLatitude, centerLongitude)
+ var queryParams = Utils.generateRandomQueryString
+ Map("latitude" -> geolocation("latitude"), "longitude" -> geolocation("longitude"), "queryParams" -> queryParams)
+ }
+ }
+
+ return geolocationFeeder
+
+ }
+
+ def generateUserConnectionFeeder(numUsers: Int): Feeder[String] = {
+
+ val userIdFeeder = new Feeder[String] {
+
+ // always return true as this feeder can be polled infinitively
+ override def hasNext = true
+
+ override def next: Map[String, String] = {
+ Map("user1" -> "user".concat(Utils.generateRandomInt(1, numUsers).toString), "user2" -> "user".concat(Utils.generateRandomInt(1, numUsers).toString))
+ }
+ }
+
+ return userIdFeeder
+
+ }
+
+ def generateEntityNameFeeder(prefix: String, numEntities: Int): Array[Map[String, String]] = {
+
+ var nameArray: ArrayBuffer[Map[String, String]] = new ArrayBuffer[Map[String, String]]
+
+ for (entityCount <- 1 to numEntities) {
+ nameArray += Map("entityName" -> prefix.concat(entityCount.toString))
+ }
+
+ return nameArray.toArray
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/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
new file mode 100755
index 0000000..ffc7d96
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ApplicationScenarios.scala
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.{Settings, Headers}
+
+ /**
+ * Performs organization registration
+ *
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The organization name
+ *
+ * Produces:
+ *
+ * appName The name of the created application
+ */
+object ApplicationScenarios {
+
+ val createApplication = exec(http("Create Application")
+ .post("/management/organizations/${org}/applications")
+ .headers(Headers.jsonAuthorized)
+ .body(StringBody("{\"name\":\"" + Settings.app + "\"}"))
+ .check(status.is(200))
+
+ )
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
new file mode 100755
index 0000000..7719883
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/ConnectionScenarios.scala
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+
+object ConnectionScenarios {
+
+ val postConnection = exec(
+ http("POST connection")
+ .post("/users/${user1}/likes/users/${user2}")
+ .check(status.is(200))
+ )
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/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
new file mode 100755
index 0000000..872d700
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/DeviceScenarios.scala
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef.StringBody
+import io.gatling.http.Predef._
+import io.gatling.http.request.StringBody
+
+
+/**
+ *
+ * Creates a new device
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The name of the org
+ * appName The name of the app
+ * notifierName The name of the created notifier
+ *
+ * Produces:
+ *
+ * deviceName the name of the device created
+ *
+ */
+object DeviceScenarios {
+
+ /**
+ * Create a device
+ */
+ val postDeviceWithNotifier = exec(http("Create device with notifier")
+ .post("/devices")
+ .body(new StringBody("""{\"name\":\"${entityName}\"," +
+ "\"deviceModel\":\"Fake Device\"," +
+ " \"deviceOSVerion\":\"Negative Version\", " +
+ "\"${notifier}.notifier.id\":\"${entityName}\"}"""))
+ .check(status.is(200), jsonPath("$.entities[0].uuid").saveAs("deviceId")))
+
+
+ val postDeviceWithNotifier400ok = exec(http("Create device with notifier")
+ .post("/devices")
+ .body(new StringBody("""{\"name\":\"${entityName}\"," +
+ "\"deviceModel\":\"Fake Device\"," +
+ " \"deviceOSVerion\":\"Negative Version\", " +
+ "\"${notifier}.notifier.id\":\"${entityName}\"}"""))
+ .check(status.in(200 to 400), jsonPath("$.entities[0].uuid").saveAs("deviceId")))
+
+
+ /**
+ * Requires: entityName to feed to the device name. If it exists, it will be created
+ */
+ val maybeCreateDevice = exec(
+ //try to do a GET on device name, if it 404's create it
+ http("Check and create device").get("/devices/${entityName}").check(status.not(404).saveAs("deviceExists")))
+ //create the device if we got a 404
+ .doIf("${deviceExists}", "404") {
+
+ exec(
+
+ http("Create device and save deviceId").post("/devices").body(new StringBody("""{\"name\":\"${entityName}\"," +
+ "\"deviceModel\":\"Fake Device\"," +
+ " \"deviceOSVerion\":\"Negative Version\", " +
+ "\"${notifier}.notifier.id\":\"${entityName}\"}"""))
+ .check(status.is(200), jsonPath("$.entities[0].uuid").saveAs("deviceId"))
+ )
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
new file mode 100755
index 0000000..2954abd
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/GeoScenarios.scala
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.{Utils, Settings}
+
+ object GeoScenarios {
+
+ val getGeolocation = exec(
+ http("GET geolocated user")
+ .get("/users?ql=location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
+ .check(status.is(200))
+ )
+
+ val getGeolocationWithQuery = exec(
+ http("GET geolocated user with query")
+ .get("/users?ql=${queryParams}%20AND%20location%20within%20" + Settings.geosearchRadius + "%20of%20${latitude},${longitude}")
+ .check(status.is(200))
+ )
+
+ val updateGeolocation = exec(
+ http("PUT user location")
+ .put("/users/user" + Utils.generateRandomInt(1, Settings.numUsers))
+ .body(StringBody("{\"location\":{\"latitude\":\"${latitude}\",\"longitude\":\"${longitude}\"}}"))
+ .check(status.is(200))
+ )
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
new file mode 100755
index 0000000..b5c9529
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotificationScenarios.scala
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import java.io.File
+import java.nio.file.{Paths, Files}
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+import scala.concurrent.duration._
+
+import scala.io.Source
+
+/**
+ *
+ * Creates a new device
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The name of the org
+ * appName The name of the app
+ * notifierName The name of the created notifier
+ * deviceName the name of the device created to send the notification to
+ *
+ * Produces:
+ *
+ * N/A
+ *
+ *
+ */
+object NotificationScenarios {
+
+
+ /**
+ * send the notification now
+ */
+ val sendNotification = exec(http("Send Single Notification")
+ .post("/devices/${entityName}/notifications")
+ .body(StringBody("{\"payloads\":{\"${notifier}\":\"testmessage\"}}"))
+ .check(status.is(200))
+ )
+
+ val sendNotificationToUser= exec(http("Send Notification to All Devices")
+ .post("/users/${user}/notifications")
+ .body(StringBody("{\"payloads\":{\"${notifier}\":\"testmessage\"}}"))
+ .check(status.is(200))
+ )
+
+ /**
+ * TODO: Add posting to users, which would expect a user in the session
+ */
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
new file mode 100755
index 0000000..4708523
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/NotifierScenarios.scala
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+/**
+ *
+ * Creates a new no-op notifier
+ *
+ *
+ * Expects:
+ *
+ * authToken The auth token to use when creating the application
+ * orgName The name of the org
+ * appName The name of the app
+ *
+ * Produces:
+ *
+ * notifierName The name of the created notifier
+ *
+ */
+object NotifierScenarios {
+
+ val notifier = Settings.pushNotifier
+ val provider = Settings.pushProvider
+
+ /**
+ * Create a notifier
+ */
+ val createNotifier = exec(
+ session => {
+ session.set("notifier", notifier)
+ session.set("provider", provider)
+ }
+ )
+
+ .exec(http("Create Notifier")
+ .post("/notifiers")
+ .body(StringBody("{\"name\":\"${notifier}\",\"provider\":\"${provider}\"}"))
+ //remnants of trying to upload an apple certificate
+// .param("name", "${notifierName}")
+// .param("provider", "apple")
+// .param("environment", "mock")
+// .fileBody("p12Certificate", Map).fileBody(pkcs12Cert)
+ .check(status.is(200)))
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/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
new file mode 100755
index 0000000..01a2857
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/OrganizationScenarios.scala
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.{Settings, Headers}
+ import scala.concurrent.duration._
+
+/**
+ * Performs organization registration
+ *
+ *
+ * Produces:
+ *
+ * orgName The name of the created organization
+ * userName The user name of the admin to log in with
+ * password The password of the admin to use
+ */
+object OrganizationScenarios {
+
+ //register the org with the randomly generated org
+ val createOrgAndAdmin = exec(http("Create Organization")
+ .post("/management/organizations")
+ .headers(Headers.jsonAnonymous)
+ .body(StringBody("{\"organization\":\"" + Settings.org + "\",\"username\":\"${username}\",\"name\":\"${username}\",\"email\":\"${username}@apigee.com\",\"password\":\"${password}\"}"))
+ .check(status.is(200)))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
new file mode 100755
index 0000000..3508d6f
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/TokenScenarios.scala
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.Headers
+ import scala.concurrent.duration._
+
+/**
+ * Class that will get the token and insert it into the test session.
+ * Assumes that the following values are present in the session.
+ *
+ * Expects:
+ *
+ * userName The user name to log in with
+ * password The password to use
+ *
+ * Produces:
+ *
+ * authToken A valid access token if the login attempt is successful
+ */
+
+object TokenScenarios {
+
+
+ val getManagementToken =
+ exec(
+ http("POST Org Token")
+ .post("/management/token")
+ .headers(Headers.jsonAnonymous)
+ //pass in the the username and password, store the "access_token" json response element as the var "authToken" in the session
+ .body(StringBody("{\"username\":\"${username}\",\"password\":\"${password}\",\"grant_type\":\"password\"}"))
+ .check(jsonPath("access_token")
+ .saveAs("authToken"))
+ )
+
+ val getUserToken =
+ exec(
+ http("POST user token")
+ .post("/token")
+ .body(StringBody("{\"grant_type\":\"password\",\"username\":\"${user1}\",\"password\":\"password\"}"))
+ .check(status.is(200))
+ )
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/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
new file mode 100755
index 0000000..4989973
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/scenarios/UserScenarios.scala
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.scenarios
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.settings.{Settings, Utils}
+
+ object UserScenarios {
+
+ val getRandomUser = exec(
+ http("GET user")
+ .get("/users/user" + Utils.generateRandomInt(1, Settings.numEntities))
+ .check(status.is(200))
+ )
+
+ val postUser = exec(
+ http("POST geolocated Users")
+ .post("/users")
+ .body(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.is(200))
+ )
+
+ val postUser400ok = exec(
+ http("POST geolocated Users")
+ .post("/users")
+ .body(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))
+ )
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
new file mode 100755
index 0000000..9b735e5
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Headers.scala
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.settings
+
+/**
+ *
+ */
+object Headers {
+
+ /**
+ * Headers for anonymous posts
+ */
+ val jsonAnonymous = Map(
+ "Cache-Control" -> """no-cache""",
+ "Content-Type" -> """application/json; charset=UTF-8"""
+ )
+
+ /**
+ * Headers for authorized users with token and json content type
+ */
+ val jsonAuthorized = Map(
+ "Cache-Control" -> """no-cache""",
+ "Content-Type" -> """application/json; charset=UTF-8""",
+ "Authorization" -> "Bearer ${authToken}"
+ )
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/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
new file mode 100755
index 0000000..13fa045
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Settings.scala
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.settings
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+import scala.concurrent.duration._
+
+object Settings {
+
+ // Target settings
+ val org = System.getProperty("org")
+ val app = System.getProperty("app")
+ val baseUrl = System.getProperty("baseurl")
+ val httpConf = http.baseURL(baseUrl + "/" + org + "/" + app)
+
+ // Simulation settings
+ val numUsers:Int = Integer.getInteger("numUsers", 10).toInt
+ val numEntities:Int = Integer.getInteger("numEntities", 5000).toInt
+ val numDevices:Int = Integer.getInteger("numDevices", 2000).toInt
+
+ val rampTime:Int = Integer.getInteger("rampTime", 0).toInt // in seconds
+ val duration:Int = Integer.getInteger("duration", 300).toInt // in seconds
+ val throttle:Int = Integer.getInteger("throttle", 50).toInt // in seconds
+
+ // Geolocation settings
+ val centerLatitude:Double = 37.442348 // latitude of center point
+ val centerLongitude:Double = -122.138268 // longitude of center point
+ val userLocationRadius:Double = 32000 // location of requesting user in meters
+ val geosearchRadius:Int = 8000 // search area in meters
+
+ // Push Notification settings
+ val pushNotifier = System.getProperty("notifier")
+ val pushProvider = System.getProperty("provider")
+
+ def createRandomPushNotifier:String = {
+ return Utils.generateUniqueName("notifier")
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
new file mode 100755
index 0000000..750f0e4
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/settings/Utils.scala
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.settings
+
+import scala.util.Random
+import scala.math
+import Array._
+
+/**
+ *
+ * Utility for creating various data elements
+ *
+ */
+object Utils {
+
+ private val RNG = new Random
+
+ /**
+ * Generate a new uuid and replace the '-' with empty
+ */
+ def generateUUIDString(): String = {
+ return java.util.UUID.randomUUID.toString.replace("-", "")
+ }
+
+ /**
+ * Generate a unique string with a prefix
+ *
+ * @param prefix
+ * @return
+ */
+ def generateUniqueName(prefix : String): String = {
+ return prefix + generateUUIDString()
+ }
+
+ // random number in between [a...b]
+ def generateRandomInt(lowerBound: Int, upperBound: Int) = RNG.nextInt(upperBound - lowerBound) + lowerBound
+
+ def generateRandomGeolocation(radius: Double, centerLatitude: Double, centerLongitude: Double):Map[String, String] = {
+
+ var rd = radius / 111300 // Convert Radius from meters to degrees.
+ var u = RNG.nextFloat()
+ var v = RNG.nextFloat()
+ var q = math.sqrt(u) * rd
+ var w = q * rd
+ var t = 2 * math.Pi * v
+ var x = math.cos(t) * w
+ var y = math.sin(t) * w
+ var xp = x/math.cos(centerLatitude)
+ var latitude = (y + centerLatitude).toString
+ var longitude = (xp + centerLongitude).toString
+ var geolocation: Map[String, String] = Map("latitude"->latitude,"longitude"->longitude)
+
+ return geolocation
+ }
+
+ def generateRandomQueryString: String = {
+
+ val queryParams = Array("age", "height", "weight")
+ var queryString = ""
+
+ for (numParams <- 1 to generateRandomInt(1, queryParams.length)) {
+ queryString = "age=" + Utils.generateRandomInt(18, 65).toString
+ if (numParams == 2) {
+ queryString += "%20AND%20height=" + Utils.generateRandomInt(48, 84).toString
+ } else if (numParams == 3) {
+ queryString += "%20AND%20weight=" + Utils.generateRandomInt(120, 350).toString
+ }
+ }
+
+ return queryString
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
new file mode 100644
index 0000000..7b9df21
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/GetEntitySimulation.scala
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.UserScenarios
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+class GetEntitySimulation extends Simulation {
+
+ // Target settings
+ val httpConf = Settings.httpConf
+
+ // Simulation settings
+ val numUsers:Int = Settings.numUsers
+ val numEntities:Int = Settings.numEntities
+ val rampTime:Int = Settings.rampTime
+ val throttle:Int = Settings.throttle
+
+ val feeder = FeederGenerator.generateEntityNameFeeder("user", numEntities).circular
+
+ val scnToRun = scenario("GET entity")
+ .exec(UserScenarios.getRandomUser)
+
+ setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf)).maxDuration(Settings.duration)
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
new file mode 100755
index 0000000..d7c6dd8
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostDevicesSimulation.scala
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.DeviceScenarios
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+class PostDevicesSimulation extends Simulation {
+
+ // Target settings
+ val httpConf = Settings.httpConf
+
+ // Simulation settings
+ val numUsers:Int = Settings.numUsers
+ val numEntities:Int = Settings.numEntities
+ val rampTime:Int = Settings.rampTime
+ val throttle:Int = Settings.throttle
+
+ val feeder = FeederGenerator.generateEntityNameFeeder("device", numEntities)
+
+ val scnToRun = scenario("POST device")
+ .feed(feeder)
+ .exec(DeviceScenarios.postDeviceWithNotifier)
+
+ setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
new file mode 100755
index 0000000..cbac041
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PostUsersSimulation.scala
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.UserScenarios
+ import org.apache.usergrid.settings.Settings
+
+ import scala.concurrent.duration._
+
+class PostUsersSimulation extends Simulation {
+
+ // Target settings
+ val httpConf = Settings.httpConf
+
+ // Simulation settings
+ val numUsers:Int = Settings.numUsers
+ val rampTime:Int = Settings.rampTime
+ val throttle:Int = Settings.throttle
+
+ // Geolocation settings
+ val centerLatitude:Double = Settings.centerLatitude
+ val centerLongitude:Double = Settings.centerLongitude
+ val userLocationRadius:Double = Settings.userLocationRadius
+ val geosearchRadius:Int = Settings.geosearchRadius
+
+ val feeder = FeederGenerator.generateUserWithGeolocationFeeder(numUsers, userLocationRadius, centerLatitude, centerLongitude).queue
+
+ val scnToRun = scenario("POST geolocated users")
+ .feed(feeder)
+ .exec(UserScenarios.postUser)
+
+ setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
new file mode 100755
index 0000000..731423c
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetDeviceSimulation.scala
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.{NotificationScenarios, DeviceScenarios, NotifierScenarios}
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+/**
+ *
+ * Simple test for setting up multiple orgs and creating push notifications
+ *
+ */
+class PushNotificationTargetDeviceSimulation extends Simulation {
+
+ val numUsers:Int = Settings.numUsers
+ val numEntities:Int = Settings.numEntities
+ val rampTime:Int = Settings.rampTime
+ val throttle:Int = Settings.throttle
+ val duration:Int = Settings.duration
+ val httpConf = Settings.httpConf
+ .acceptHeader("application/json")
+
+ val createNotifier = NotifierScenarios.createNotifier
+ val createDevice = DeviceScenarios.postDeviceWithNotifier
+ val sendNotification = NotificationScenarios.sendNotification
+
+ val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities).circular
+
+ val scnToRun = scenario("Create Push Notification")
+ .during(duration.seconds) {
+ feed(deviceNameFeeder)
+ .exec(sendNotification)
+ }
+
+
+ setUp(scnToRun.inject(atOnceUsers(numUsers)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/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
new file mode 100644
index 0000000..ea2d484
--- /dev/null
+++ b/stack/loadtests/src/main/scala/org/apache/usergrid/simulations/PushNotificationTargetUserSimulation.scala
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ package org.apache.usergrid.simulations
+
+import io.gatling.core.Predef._
+import io.gatling.http.Predef._
+ import org.apache.usergrid._
+ import org.apache.usergrid.datagenerators.FeederGenerator
+ import org.apache.usergrid.scenarios.{NotificationScenarios, UserScenarios, DeviceScenarios}
+ import org.apache.usergrid.settings.Settings
+ import scala.concurrent.duration._
+
+class PushNotificationTargetUserSimulation extends Simulation {
+
+ val numUsers:Int = Settings.numUsers
+ val numEntities:Int = Settings.numEntities
+ val rampTime:Int = Settings.rampTime
+ val throttle:Int = Settings.throttle
+ val duration:Int = Settings.duration
+ val httpConf = Settings.httpConf.acceptHeader("application/json")
+
+ val notifier = Settings.pushNotifier
+ val createDevice = DeviceScenarios.postDeviceWithNotifier400ok
+ val sendNotification = NotificationScenarios.sendNotification
+ val createUser = UserScenarios.postUser400ok
+ val deviceNameFeeder = FeederGenerator.generateEntityNameFeeder("device", numEntities).circular
+ val userFeeder = FeederGenerator.generateUserWithGeolocationFeeder(numEntities, Settings.userLocationRadius, Settings.centerLatitude, Settings.centerLongitude)
+
+ val scnToRun = scenario("Create Push Notification")
+ .feed(userFeeder)
+ .exec(createUser)
+// .pause(1000)
+// .exec(http("Check user and user devices")
+// .get("/users/${username}/devices")
+// .check(status.is(200))
+// )
+ .feed(deviceNameFeeder)
+ .exec(createDevice)
+// .pause(1000)
+ .exec(http("Check device connections")
+ .get("/devices/${entityName}/users")
+ .check(status.is(200))
+ )
+// .exec(http("Connect user with device")
+// .post("/users/${username}/devices/${deviceId}")
+// .check(status.is(200))
+// )
+// .exec(http("Send Notification to All Devices")
+// .post("/users/${username}/notifications")
+// .body(StringBody("{\"payloads\":{\"" + notifier + "\":\"testmessage\"}}"))
+// .check(status.is(200))
+// )
+
+
+ setUp(scnToRun.inject(constantUsersPerSec(numUsers) during (duration)).throttle(reachRps(throttle) in (rampTime.seconds)).protocols(httpConf))
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/336cb2eb/stack/loadtests/src/main/scripts/gatling-ug.sh
----------------------------------------------------------------------
diff --git a/stack/loadtests/src/main/scripts/gatling-ug.sh b/stack/loadtests/src/main/scripts/gatling-ug.sh
new file mode 100755
index 0000000..67f1392
--- /dev/null
+++ b/stack/loadtests/src/main/scripts/gatling-ug.sh
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+die () {
+ echo >&2 "$@"
+ exit 1
+}
+
+[ "$#" -eq 5 ] || die "5 arguments required, $# provided. Arguments are URL ORG APP NUM_USERS RAMP_TIME"
+
+OLDDIR=`pwd`
+BIN_DIR=`dirname $0`
+cd "${BIN_DIR}/.." && DEFAULT_GATLING_HOME=`pwd` && cd "${OLDDIR}"
+
+GATLING_HOME="${GATLING_HOME:=${DEFAULT_GATLING_HOME}}"
+GATLING_CONF="${GATLING_CONF:=$GATLING_HOME/conf}"
+URL="$1"
+ORG="$2"
+APP="$3"
+USERS="$4"
+RAMP="$5"
+
+#Shift off our first operation
+shift 5
+
+export GATLING_HOME GATLING_CONF
+
+echo "GATLING_HOME is set to ${GATLING_HOME}"
+
+curl -X POST "${URL}/usergrid/sandbox/notifiers" -d '{"name":"notifier82e05787a8c24361a2992c64436b6e6a","provider":"noop"}'
+
+JAVA_OPTS="-Dthrottle=3000 -Dduration=300 -Dorg=${ORG} -Dbaseurl=${URL} -Dnotifier=notifier82e05787a8c24361a2992c64436b6e6a -DnumEntities=10000 -DnumUsers=${USERS} -DrampTime=${RAMP} -Dapp=${APP} -server -XX:+UseThreadPriorities -XX:ThreadPriorityPolicy=42 -Xms512M -Xmx512M -Xmn100M -XX:+HeapDumpOnOutOfMemoryError -XX:+AggressiveOpts -XX:+OptimizeStringConcat -XX:+UseFastAccessorMethods -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -Djava.net.preferIPv4Stack=true -Djava.net.preferIPv6Addresses=false ${JAVA_OPTS}"
+
+echo $JAVA_OPTS
+
+CLASSPATH="$GATLING_HOME/lib/*:$GATLING_CONF:$GATLING_HOME/user-files:${JAVA_CLASSPATH}"
+
+java $JAVA_OPTS -cp "$CLASSPATH" io.gatling.app.Gatling "$@"