Skip to content

Commit

Permalink
Fixed tests which became broken with 1ffe374.
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelkiessling committed Nov 14, 2016
1 parent 1ffe374 commit 6eff35c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 27 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ On the production cluster master:
- `./bin/spark-shell --packages com.datastax.spark:spark-cassandra-connector_2.11:1.5.0-M2,org.json4s:json4s-native_2.11:3.3.0 --master spark://service-misc-experiments-1:7077 --conf spark.cassandra.connection.host=$JOURNEYMONITOR_ANALYZE_SPARK_CASSANDRAHOST`


#### Run API with JMX exposed

- `/usr/bin/nohup /bin/su -s /bin/bash -c ". /etc/journeymonitor/app-analyze-env.sh && /opt/journeymonitor/analyze/api-1.0-SNAPSHOT/bin/api -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=1098 >> /var/tmp/journeymonitor-analyze-api.log 2>&1" journeymonitor &`


### Spark behaviour

This is how an executor queries the database:
Expand Down
60 changes: 33 additions & 27 deletions api/test/IntegrationSpec.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.journeymonitor.analyze.api.test

import java.io.File
import java.text.SimpleDateFormat
import java.util.Calendar

import com.journeymonitor.analyze.api.AppLoader
import com.journeymonitor.analyze.common.{CassandraClient, CassandraConnectionUri}
Expand All @@ -11,6 +13,10 @@ import play.api.{ApplicationLoader, Environment, Mode}

class IntegrationSpec extends PlaySpec with OneBrowserPerSuite with OneServerPerSuite with HtmlUnitFactory with BeforeAndAfter {

val calendarToday = Calendar.getInstance(java.util.TimeZone.getTimeZone("UTC"))
val sdf = new SimpleDateFormat("yyyy-MM")
val currentYearAndMonth = sdf.format(calendarToday.getTime)

before {
val uriString = sys.env.getOrElse("JOURNEYMONITOR_ANALYZE_CASSANDRAURI_TEST", "cassandra://localhost:9042/test")
val uri = CassandraConnectionUri(uriString)
Expand All @@ -19,48 +25,48 @@ class IntegrationSpec extends PlaySpec with OneBrowserPerSuite with OneServerPer
session.execute("TRUNCATE statistics;")

session.execute(
"""
s"""
|INSERT INTO statistics
| (testcase_id, day_bucket, testresult_datetime_run, testresult_id, runtime_milliseconds, number_of_200, number_of_400, number_of_500)
| VALUES
| ('testcase1', '2016-01-01', '2016-01-01 01:32:12+0000', 'testresult1a', 111, 123, 456, 789);
| ('testcase1', '$currentYearAndMonth-01', '$currentYearAndMonth-01 01:32:12+0000', 'testresult1a', 111, 123, 456, 789);
""".stripMargin
)

session.execute(
"""
s"""
|INSERT INTO statistics
| (testcase_id, day_bucket, testresult_datetime_run, testresult_id, runtime_milliseconds, number_of_200, number_of_400, number_of_500)
| VALUES
| ('testcase1', '2016-01-01', '2016-01-01 02:32:12+0000', 'testresult1b', 111, 123, 456, 789);
| ('testcase1', '$currentYearAndMonth-01', '$currentYearAndMonth-01 02:32:12+0000', 'testresult1b', 111, 123, 456, 789);
""".stripMargin
)

session.execute(
"""
s"""
|INSERT INTO statistics
| (testcase_id, day_bucket, testresult_datetime_run, testresult_id, runtime_milliseconds, number_of_200, number_of_400, number_of_500)
| VALUES
| ('testcase1', '2016-01-02', '2016-01-02 01:32:12+0000', 'testresult2', 222, 123, 456, 789);
| ('testcase1', '$currentYearAndMonth-02', '$currentYearAndMonth-02 01:32:12+0000', 'testresult2', 222, 123, 456, 789);
""".stripMargin
)

session.execute(
"""
s"""
|INSERT INTO statistics
| (testcase_id, day_bucket, testresult_datetime_run, testresult_id, runtime_milliseconds, number_of_200, number_of_400, number_of_500)
| VALUES
| ('testcase1', '2016-01-03', '2016-01-03 01:32:12+0000', 'testresult3', 333, 123, 456, 789);
| ('testcase1', '$currentYearAndMonth-03', '$currentYearAndMonth-03 01:32:12+0000', 'testresult3', 333, 123, 456, 789);
""".stripMargin
)

// Different testcase
session.execute(
"""
s"""
|INSERT INTO statistics
| (testcase_id, day_bucket, testresult_datetime_run, testresult_id, runtime_milliseconds, number_of_200, number_of_400, number_of_500)
| VALUES
| ('testcase2', '2016-01-01', '2016-01-01 01:32:12+0000', 'testresult3', 333, 123, 456, 789);
| ('testcase2', '$currentYearAndMonth-01', '$currentYearAndMonth-01 01:32:12+0000', 'testresult3', 333, 123, 456, 789);
""".stripMargin
)
}
Expand All @@ -83,35 +89,35 @@ class IntegrationSpec extends PlaySpec with OneBrowserPerSuite with OneServerPer
"return a JSON array with all statistics entries for a given testcase id when not limited" in {
go to "http://localhost:" + port + "/testcases/testcase1/statistics/latest/"
pageSource mustBe
"""
s"""
|[
| {
| "testresultId":"testresult3",
| "testresultDatetimeRun":"2016-01-03<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-03<space>01:32:12+0000",
| "runtimeMilliseconds":333,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult2",
| "testresultDatetimeRun":"2016-01-02<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-02<space>01:32:12+0000",
| "runtimeMilliseconds":222,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult1b",
| "testresultDatetimeRun":"2016-01-01<space>02:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-01<space>02:32:12+0000",
| "runtimeMilliseconds":111,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult1a",
| "testresultDatetimeRun":"2016-01-01<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-01<space>01:32:12+0000",
| "runtimeMilliseconds":111,
| "numberOf200":123,
| "numberOf400":456,
Expand All @@ -122,37 +128,37 @@ class IntegrationSpec extends PlaySpec with OneBrowserPerSuite with OneServerPer
}

"return a JSON array with all statistics entries for a given testcase id when limited to the datetime of the earliest row" in {
go to "http://localhost:" + port + "/testcases/testcase1/statistics/latest/?minTestresultDatetimeRun=2016-01-01+01%3A32%3A12%2B0000"
go to "http://localhost:" + port + s"/testcases/testcase1/statistics/latest/?minTestresultDatetimeRun=$currentYearAndMonth-01+01%3A32%3A12%2B0000"
pageSource mustBe
"""
s"""
|[
| {
| "testresultId":"testresult3",
| "testresultDatetimeRun":"2016-01-03<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-03<space>01:32:12+0000",
| "runtimeMilliseconds":333,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult2",
| "testresultDatetimeRun":"2016-01-02<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-02<space>01:32:12+0000",
| "runtimeMilliseconds":222,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult1b",
| "testresultDatetimeRun":"2016-01-01<space>02:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-01<space>02:32:12+0000",
| "runtimeMilliseconds":111,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult1a",
| "testresultDatetimeRun":"2016-01-01<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-01<space>01:32:12+0000",
| "runtimeMilliseconds":111,
| "numberOf200":123,
| "numberOf400":456,
Expand All @@ -163,29 +169,29 @@ class IntegrationSpec extends PlaySpec with OneBrowserPerSuite with OneServerPer
}

"return a JSON array with all but the earliest statistics entries for a given testcase id when limited to the datetime of the earliest row plus 1 second" in {
go to "http://localhost:" + port + "/testcases/testcase1/statistics/latest/?minTestresultDatetimeRun=2016-01-01+01%3A32%3A13%2B0000"
go to "http://localhost:" + port + s"/testcases/testcase1/statistics/latest/?minTestresultDatetimeRun=$currentYearAndMonth-01+01%3A32%3A13%2B0000"
pageSource mustBe
"""
s"""
|[
| {
| "testresultId":"testresult3",
| "testresultDatetimeRun":"2016-01-03<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-03<space>01:32:12+0000",
| "runtimeMilliseconds":333,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult2",
| "testresultDatetimeRun":"2016-01-02<space>01:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-02<space>01:32:12+0000",
| "runtimeMilliseconds":222,
| "numberOf200":123,
| "numberOf400":456,
| "numberOf500":789
| },
| {
| "testresultId":"testresult1b",
| "testresultDatetimeRun":"2016-01-01<space>02:32:12+0000",
| "testresultDatetimeRun":"$currentYearAndMonth-01<space>02:32:12+0000",
| "runtimeMilliseconds":111,
| "numberOf200":123,
| "numberOf400":456,
Expand All @@ -196,7 +202,7 @@ class IntegrationSpec extends PlaySpec with OneBrowserPerSuite with OneServerPer
}

"return an empty JSON array when limited to a datetime for which only older entries exist" in {
go to "http://localhost:" + port + "/testcases/testcase1/statistics/latest/?minTestresultDatetimeRun=2016-01-03+01%3A32%3A13%2B0000"
go to "http://localhost:" + port + s"/testcases/testcase1/statistics/latest/?minTestresultDatetimeRun=$currentYearAndMonth-03+01%3A32%3A13%2B0000"
pageSource mustBe "[]"
}

Expand Down

0 comments on commit 6eff35c

Please sign in to comment.