Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Update the end-to-end tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
metlos committed Jul 8, 2015
1 parent 9c8c274 commit d4662f5
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 64 deletions.
17 changes: 17 additions & 0 deletions modules/end-to-end-test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@
<hawkular.log.cassandra>INFO</hawkular.log.cassandra>
<hawkular.log.ejb3>WARN</hawkular.log.ejb3>
<hawkular.log.rewrite>WARN</hawkular.log.rewrite>
<http.log>ERROR</http.log>
<http.log.wire>WARN</http.log.wire>
</properties>
<build>
<plugins>
Expand All @@ -119,7 +121,19 @@
<systemPropertyVariables>
<hawkular.bind.address>${hawkular.bind.address}</hawkular.bind.address>
<hawkular.port.offset>${hawkular.port.offset}</hawkular.port.offset>

<!-- output over-the-wire traffic -->
<org.apache.commons.logging.Log>
org.apache.commons.logging.impl.SimpleLog
</org.apache.commons.logging.Log>
<org.apache.commons.logging.simplelog.log.org.apache.http>
${http.log}
</org.apache.commons.logging.simplelog.log.org.apache.http>
<org.apache.commons.logging.simplelog.log.org.apache.http.wire>
${http.log.wire}
</org.apache.commons.logging.simplelog.log.org.apache.http.wire>
</systemPropertyVariables>
<!--<argLine>-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y</argLine>-->
</configuration>
<executions>
<execution>
Expand Down Expand Up @@ -165,6 +179,9 @@
<javaOpt>-Dhawkular.log.cassandra=${hawkular.log.cassandra}</javaOpt>
<javaOpt>-Dhawkular.log.ejb3=${hawkular.log.ejb3}</javaOpt>
<javaOpt>-Dhawkular.log.rewrite=${hawkular.log.rewrite}</javaOpt>
<javaOpt>-Dhawkular.log.rewrite=${hawkular.log.rewrite}</javaOpt>
<!--<javaOpt>-Xdebug</javaOpt>-->
<!--<javaOpt>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</javaOpt>-->
</javaOpts>
</configuration>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ import static org.junit.Assert.assertTrue
class Scenario1ITest extends AbstractTestBase {

static final String urlTypeId = "URL"
static final String urlTypePath = "/" + urlTypeId
static final String environmentId = "test"
static final String statusCodeTypeId = "status.code.type"
static final String statusCodeTypePath = "/" + statusCodeTypeId
static final String durationTypeId = "status.duration.type"
static final String durationTypePath = "/" + durationTypeId

private static List<String> pathsToDelete = new ArrayList();

Expand Down Expand Up @@ -83,30 +86,30 @@ class Scenario1ITest extends AbstractTestBase {
/* create a URL */
String resourceId = UUID.randomUUID().toString();
def newResource = Resource.Blueprint.builder().withId(resourceId)
.withResourceType(urlTypeId).withProperty("url", "http://hawkular.org").build()
.withResourceTypePath(urlTypePath).withProperty("url", "http://hawkular.org").build()
response = client.post(path: "/hawkular/inventory/$environmentId/resources", body : newResource)
assertEquals(201, response.status)
pathsToDelete.add("/hawkular/inventory/$environmentId/resources/$resourceId")


/* create the metrics */
String statusCodeId = UUID.randomUUID().toString();
def codeMetric = Metric.Blueprint.builder().withMetricTypeId(statusCodeTypeId).withId(statusCodeId).build();
def codeMetric = Metric.Blueprint.builder().withMetricTypePath(statusCodeTypePath).withId(statusCodeId).build();
response = client.post(path: "/hawkular/inventory/$environmentId/metrics", body: codeMetric)
assertEquals(201, response.status)
pathsToDelete.add("/hawkular/inventory/$environmentId/metrics/$statusCodeId")

String durationId = UUID.randomUUID().toString();
def durationMetric = Metric.Blueprint.builder().withMetricTypeId(durationTypeId).withId(durationId).build();
def durationMetric = Metric.Blueprint.builder().withMetricTypePath(durationTypePath).withId(durationId).build();
response = client.post(path: "/hawkular/inventory/$environmentId/metrics", body: durationMetric)
assertEquals(201, response.status)
pathsToDelete.add("/hawkular/inventory/$environmentId/metrics/$durationId")

/* assign metrics to the resource */
response = client.post(path: "/hawkular/inventory/$environmentId/resources/$resourceId/metrics",
body: [
statusCodeId,
durationId]
"../$statusCodeId".toString(), // relative path
"/test/$durationId".toString()] // canonical path, just for the fun of it
)
assertResponseOk(response.status)

Expand Down Expand Up @@ -180,6 +183,7 @@ class Scenario1ITest extends AbstractTestBase {
}
}
}

private void assertResponseOk(int responseCode) {
assertTrue("Response code should be 2xx or 304 but was "+ responseCode,
(responseCode >= 200 && responseCode < 300) || responseCode == 304)
Expand All @@ -199,5 +203,4 @@ class Scenario1ITest extends AbstractTestBase {
])
assertResponseOk(response.status)
}

}
}

0 comments on commit d4662f5

Please sign in to comment.