Skip to content

Commit

Permalink
Merge pull request #855 from burmanm/test_fixes
Browse files Browse the repository at this point in the history
Add missing DataAccess.shutdown() requests
  • Loading branch information
stefannegrea committed Jul 27, 2017
2 parents 1bb8126 + d0db2f3 commit 55c1d9a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.joda.time.Duration;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -182,6 +183,11 @@ public void initTest(Method method) {
public void tearDown() {
}

@AfterClass(alwaysRun = true)
public void shutdown() {
dataAccess.shutdown();
}

@Test(priority = 1)
public void testCompressJob() throws Exception {
long now = jobScheduler.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@

import org.hawkular.metrics.core.service.BaseITest;
import org.hawkular.metrics.core.service.DataAccess;
import org.hawkular.metrics.core.service.DataAccessImpl;
import org.hawkular.metrics.core.service.MetricsServiceImpl;
import org.hawkular.metrics.core.service.TestDataAccessFactory;
import org.hawkular.metrics.datetime.DateTimeService;
import org.hawkular.metrics.model.DataPoint;
import org.hawkular.metrics.model.Metric;
Expand All @@ -44,6 +44,7 @@
import org.hawkular.metrics.sysconfig.ConfigurationService;
import org.jboss.logging.Logger;
import org.joda.time.DateTime;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
Expand Down Expand Up @@ -75,7 +76,7 @@ public class DeleteExpiredMetricsJobITest extends BaseITest {

@BeforeClass
public void initClass() {
dataAccess = new DataAccessImpl(session);
dataAccess = TestDataAccessFactory.newInstance(session);

resetConfig = session.prepare("DELETE FROM sys_config WHERE config_id = 'org.hawkular.metrics.jobs." +
DeleteExpiredMetrics.JOB_NAME + "'");
Expand Down Expand Up @@ -117,6 +118,11 @@ public void tearDown() {
jobsService.shutdown();
}

@AfterClass(alwaysRun = true)
public void shutdown() {
dataAccess.shutdown();
}

@Test
public void testOnDemandDeleteExpiredMetricsJobCompressionEnabled() throws Exception {
configurationService.save(CompressData.CONFIG_ID, "enabled", Boolean.TRUE.toString()).toBlocking();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.hawkular.metrics.sysconfig.ConfigurationService;
import org.jboss.logging.Logger;
import org.joda.time.DateTime;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
Expand All @@ -67,6 +68,7 @@ public class DeleteTenantITest extends BaseITest {

private static Logger logger = Logger.getLogger(DeleteTenantITest.class);

private DataAccess dataAccess;
private MetricsServiceImpl metricsService;

private ConfigurationService configurationService;
Expand All @@ -91,7 +93,7 @@ public void initClass() {
"SELECT tvalue, type, metric FROM metrics_tags_idx WHERE tenant_id = ? AND tname = ?");
getRetentions = session.prepare("SELECT metric FROM retentions_idx WHERE tenant_id = ? AND type = ?");

DataAccess dataAccess = TestDataAccessFactory.newInstance(session);
dataAccess = TestDataAccessFactory.newInstance(session);

configurationService = new ConfigurationService() ;
configurationService.init(rxSession);
Expand Down Expand Up @@ -124,6 +126,11 @@ public void tearDown() {
jobsService.shutdown();
}

@AfterClass(alwaysRun = true)
public void shutdown() {
dataAccess.shutdown();
}

@Test
public void deleteTenantHavingGaugesAndNoMetricTags() throws Exception {
String tenantId = nextTenantId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,15 +268,4 @@ void testFindAllDataFromBucket() throws Exception {
tsr.assertNoErrors();
tsr.assertValueCount(amountOfMetrics * datapointsPerMetric);
}

// @Test
// public void testBucketIndexes() throws Exception {
// ZonedDateTime of = ZonedDateTime.of(2017, 1, 1, 0, 0, 0, 0, ZoneOffset.UTC);
// ZonedDateTime limit = ZonedDateTime.of(2017, 1, 1, 23, 59, 0, 0, ZoneOffset.UTC);
// int bucketIndex = dataAccess.getBucketIndex(of.toInstant().toEpochMilli());
// assertEquals(0, bucketIndex);
//
// bucketIndex = dataAccess.getBucketIndex(limit.toInstant().toEpochMilli());
// assertEquals(11, bucketIndex);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void prepareTempStatements(String tableName, Long mapKey) {
* Create few temporary tables for tests
*/
static Set<Long> tableListForTesting() {
Set<Long> tempTables = new HashSet<>(2);
Set<Long> tempTables = new HashSet<>(3);
DateTime now = DateTimeService.now.get();
tempTables.add(now.getMillis());
tempTables.add(now.minusHours(2).getMillis());
Expand Down

0 comments on commit 55c1d9a

Please sign in to comment.