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

Commit

Permalink
datamining integration
Browse files Browse the repository at this point in the history
  • Loading branch information
pavolloffay committed Jan 12, 2016
1 parent 575ca73 commit 4d97ee2
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 1 deletion.
11 changes: 11 additions & 0 deletions dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@
<version>${version.org.hawkular.agent}</version>
</dependency>

<dependency>
<groupId>org.hawkular.datamining</groupId>
<artifactId>hawkular-datamining-dist</artifactId>
<type>war</type>
</dependency>
<dependency>
<groupId>org.hawkular.inventory</groupId>
<artifactId>hawkular-inventory-dist</artifactId>
Expand Down Expand Up @@ -305,6 +310,12 @@
<version>${version.org.hawkular.inventory}</version>
<type>war</type>
</artifactItem>
<artifactItem>
<groupId>org.hawkular.datamining</groupId>
<artifactId>hawkular-datamining-dist</artifactId>
<version>${version.org.hawkular.datamining}</version>
<type>war</type>
</artifactItem>

</artifactItems>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* 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.
*/

package org.hawkular.integration.test
import org.hawkular.inventory.api.model.Metric
import org.hawkular.inventory.api.model.MetricDataType
import org.hawkular.inventory.api.model.MetricType
import org.hawkular.inventory.api.model.MetricUnit
import org.junit.Assert
import org.junit.BeforeClass
import org.junit.Test

import static org.junit.Assert.assertEquals

class DataminingITest extends AbstractTestBase {

private static final String invBasePath = "/hawkular/inventory"
private static final String dtmBasePath = "/hawkular/datamining"

private static final String predictionRelationshipName = "__inPrediction"

private static final String environmentId = "test"
private static final String feedId = "itest-dtm-feed"
private static final String metricTypeId = "itest-dtm-mt"
private static final String metricId = "itest-dtm-m"

private static String tenantId;

@BeforeClass
public static void setUpData() {

def payload = null;
def response = null
String path = "/hawkular/inventory/environments/$environmentId";
int attemptCount = 5;
int delay = 500;
for (int i = 0; i < attemptCount; i++) {
try {
response = client.get(path: path)
/* all is well, we can leave the loop */
break;
} catch (groovyx.net.http.HttpResponseException e) {
/* some initial attempts may fail */
}
println "'$path' not ready yet, about to retry after $delay ms"
/* sleep one second */
Thread.sleep(delay);
}
if (response.status != 200) {
Assert.fail("Getting path '$path' returned status ${response.status}, tried $attemptCount times");
}
assertEquals(environmentId, response.data.id)

String path2 = "/hawkular/inventory/tenant"
for (int i = 0; i < attemptCount; i++) {
try {
response = client.get(path: path2)
/* all is well, we can leave the loop */
break;
} catch (groovyx.net.http.HttpResponseException e) {
/* some initial attempts may fail */
}
println "'$path2' not ready yet, about to retry after $delay ms"
/* sleep one second */
Thread.sleep(delay);
}
if (response.status != 200) {
Assert.fail("Getting path '$path2' returned status ${response.status}, tried $attemptCount times");
}
tenantId = response.data.id


/**
* Create Feed
*/
payload = [
id: "$feedId".toString()
]
response = client.post(path: "$invBasePath/feeds", body: payload)
assertEquals(201, response.status)

/**
* Create metricType
*/
def metricType = MetricType.Blueprint.builder(MetricDataType.GAUGE)
.withId(metricTypeId).withUnit(MetricUnit.BYTES).withInterval(2000).build()
response = client.post(path: "$invBasePath/feeds/$feedId/metricTypes", body: metricType)
assertEquals(201, response.status)

/**
* Create metric
*/
def metric = Metric.Blueprint.builder().withId(metricId).withMetricTypePath(metricTypeId).build()
response = client.post(path: "$invBasePath/feeds/$feedId/metrics", body: metric)
assertEquals(201, response.status)

/**
* Create prediction relationship
*/
payload = [
name: "$predictionRelationshipName".toString(),
source: "/t;$tenantId".toString(),
target: "/t;$tenantId/f;$feedId/m;$metricId".toString()
]
response = client.post(path: "$invBasePath/tenants/relationships", body: payload)
assertEquals(201, response.status)


Thread.sleep(2000);
}


@Test
public void testSubscriptionExists() {
def response = client.get(path: "$dtmBasePath/subscriptions", headers: ["Hawkular-Tenant": tenantId])
assertEquals(200, response.status)
}
}


38 changes: 37 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
<version.org.hawkular.alerts>0.8.1.Final</version.org.hawkular.alerts>
<version.org.hawkular.cmdgw>0.10.7.Final</version.org.hawkular.cmdgw>
<version.org.hawkular.commons>0.3.2.Final</version.org.hawkular.commons>
<version.org.hawkular.inventory>0.12.0.Final</version.org.hawkular.inventory>
<version.org.hawkular.datamining>0.0.1.Alpha1-SRC-branch-master</version.org.hawkular.datamining>
<version.org.hawkular.inventory>0.13.0.Final-SRC-branch-HWKINVENT-163</version.org.hawkular.inventory>
<version.org.hawkular.metrics>0.11.0.Final-SRC-revision-7a90403c761cc446b1bc357eaac351d58ded00f4</version.org.hawkular.metrics>
<version.org.keycloak.secretstore>1.0.4.Final</version.org.keycloak.secretstore>
<version.rxjava>1.0.16</version.rxjava>
Expand Down Expand Up @@ -144,6 +145,13 @@
<type>ear</type>
</dependency>

<dependency>
<groupId>org.hawkular.datamining</groupId>
<artifactId>hawkular-datamining-dist</artifactId>
<version>${version.org.hawkular.datamining}</version>
<type>war</type>
</dependency>

<dependency>
<groupId>org.hawkular.inventory</groupId>
<artifactId>hawkular-inventory-api</artifactId>
Expand Down Expand Up @@ -218,4 +226,32 @@
</dependencies>
</dependencyManagement>

<build>
<plugins>
<!-- TODO REMOVE when inventory Query gets to master -->
<plugin>
<groupId>org.l2x6.maven.srcdeps</groupId>
<artifactId>srcdeps-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<repositories>
<repository>
<id>org.hawkular.inventory</id>
<selectors>
<selector>org.hawkular.inventory</selector>
</selectors>
<url>scm:git:https://github.com/pavolloffay/hawkular-inventory.git</url>
</repository>
<repository>
<id>org.hawkular.datamining</id>
<selectors>
<selector>org.hawkular.datamining</selector>
</selectors>
<url>scm:git:https://github.com/hawkular/hawkular-datamining.git</url>
</repository>
</repositories>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit 4d97ee2

Please sign in to comment.