Skip to content

Commit

Permalink
Integration test update (opendistro-for-elasticsearch#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmazanec15 committed Jul 30, 2020
1 parent 9027509 commit 3fc88f3
Show file tree
Hide file tree
Showing 11 changed files with 615 additions and 735 deletions.
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ allprojects {
}

apply plugin: 'elasticsearch.esplugin'
apply plugin: 'idea'
apply plugin: 'jacoco'
apply from: 'build-tools/knnplugin-coverage.gradle'
if (!System.properties.containsKey('tests.rest.cluster') && !System.properties.containsKey('tests.cluster')) {
apply from: 'build-tools/knnplugin-coverage.gradle'
}

jacoco {
toolVersion = "0.8.3"
Expand Down Expand Up @@ -108,6 +111,7 @@ es_tmp_dir.mkdirs()

test {
systemProperty 'tests.security.manager', 'false'
systemProperty "java.library.path", "$rootDir/buildSrc"
}

integTestRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.util.Optional;
import java.util.function.Supplier;

import static com.amazon.opendistroforelasticsearch.knn.plugin.stats.KNNStatsConfig.KNN_STATS;
import static java.util.Collections.singletonList;

/**
Expand Down Expand Up @@ -127,29 +128,7 @@ public Collection<Object> createComponents(Client client, ClusterService cluster
KNNIndexCache.setResourceWatcherService(resourceWatcherService);
KNNSettings.state().initialize(client, clusterService);
KNNCircuitBreaker.getInstance().initialize(threadPool, clusterService, client);

Map<String, KNNStat<?>> stats = ImmutableMap.<String, KNNStat<?>>builder()
.put(StatNames.HIT_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::hitCount)))
.put(StatNames.MISS_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::missCount)))
.put(StatNames.LOAD_SUCCESS_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::loadSuccessCount)))
.put(StatNames.LOAD_EXCEPTION_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::loadExceptionCount)))
.put(StatNames.TOTAL_LOAD_TIME.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::totalLoadTime)))
.put(StatNames.EVICTION_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::evictionCount)))
.put(StatNames.GRAPH_MEMORY_USAGE.getName(), new KNNStat<>(false,
new KNNCacheSupplier<>(KNNIndexCache::getWeightInKilobytes)))
.put(StatNames.CACHE_CAPACITY_REACHED.getName(), new KNNStat<>(false,
new KNNCacheSupplier<>(KNNIndexCache::isCacheCapacityReached)))
.put(StatNames.CIRCUIT_BREAKER_TRIGGERED.getName(), new KNNStat<>(true,
new KNNCircuitBreakerSupplier())).build();

knnStats = new KNNStats(stats);

knnStats = new KNNStats(KNN_STATS);
return ImmutableList.of(knnStats);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* or in the "license" file accompanying this file. This file 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 com.amazon.opendistroforelasticsearch.knn.plugin.stats;

import com.amazon.opendistroforelasticsearch.knn.index.KNNIndexCache;
import com.amazon.opendistroforelasticsearch.knn.plugin.stats.suppliers.KNNCacheSupplier;
import com.amazon.opendistroforelasticsearch.knn.plugin.stats.suppliers.KNNCircuitBreakerSupplier;
import com.amazon.opendistroforelasticsearch.knn.plugin.stats.suppliers.KNNInnerCacheStatsSupplier;
import com.google.common.cache.CacheStats;
import com.google.common.collect.ImmutableMap;

import java.util.Map;

public class KNNStatsConfig {
public static Map<String, KNNStat<?>> KNN_STATS = ImmutableMap.<String, KNNStat<?>>builder()
.put(StatNames.HIT_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::hitCount)))
.put(StatNames.MISS_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::missCount)))
.put(StatNames.LOAD_SUCCESS_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::loadSuccessCount)))
.put(StatNames.LOAD_EXCEPTION_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::loadExceptionCount)))
.put(StatNames.TOTAL_LOAD_TIME.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::totalLoadTime)))
.put(StatNames.EVICTION_COUNT.getName(), new KNNStat<>(false,
new KNNInnerCacheStatsSupplier(CacheStats::evictionCount)))
.put(StatNames.GRAPH_MEMORY_USAGE.getName(), new KNNStat<>(false,
new KNNCacheSupplier<>(KNNIndexCache::getWeightInKilobytes)))
.put(StatNames.CACHE_CAPACITY_REACHED.getName(), new KNNStat<>(false,
new KNNCacheSupplier<>(KNNIndexCache::isCacheCapacityReached)))
.put(StatNames.CIRCUIT_BREAKER_TRIGGERED.getName(), new KNNStat<>(true,
new KNNCircuitBreakerSupplier())).build();
}
Loading

0 comments on commit 3fc88f3

Please sign in to comment.