• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ESIntegTestCase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.test.ESIntegTestCase的典型用法代码示例。如果您正苦于以下问题:Java ESIntegTestCase类的具体用法?Java ESIntegTestCase怎么用?Java ESIntegTestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ESIntegTestCase类属于org.elasticsearch.test包,在下文中一共展示了ESIntegTestCase类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setupRepo

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
private BlobStoreRepository setupRepo() {
    final Client client = client();
    final Path location = ESIntegTestCase.randomRepoPath(node().settings());
    final String repositoryName = "test-repo";

    PutRepositoryResponse putRepositoryResponse =
        client.admin().cluster().preparePutRepository(repositoryName)
                                .setType("fs")
                                .setSettings(Settings.builder().put(node().settings()).put("location", location))
                                .get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));

    final RepositoriesService repositoriesService = getInstanceFromNode(RepositoriesService.class);
    @SuppressWarnings("unchecked") final BlobStoreRepository repository =
        (BlobStoreRepository) repositoriesService.repository(repositoryName);
    return repository;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:BlobStoreRepositoryTests.java


示例2: MockEngineSupport

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
public MockEngineSupport(EngineConfig config, Class<? extends FilterDirectoryReader> wrapper) {
    Settings settings = config.getIndexSettings().getSettings();
    shardId = config.getShardId();
    filterCache = config.getQueryCache();
    filterCachingPolicy = config.getQueryCachingPolicy();
    final long seed =  config.getIndexSettings().getValue(ESIntegTestCase.INDEX_TEST_SEED_SETTING);
    Random random = new Random(seed);
    final double ratio = WRAP_READER_RATIO.get(settings);
    boolean wrapReader = random.nextDouble() < ratio;
    if (logger.isTraceEnabled()) {
        logger.trace("Using [{}] for shard [{}] seed: [{}] wrapReader: [{}]", this.getClass().getName(), shardId, seed, wrapReader);
    }
    mockContext = new MockContext(random, wrapReader, wrapper, settings);
    this.searcherCloseable = new SearcherCloseable();
    LuceneTestCase.closeAfterSuite(searcherCloseable); // only one suite closeable per Engine
    this.disableFlushOnClose = DISABLE_FLUSH_ON_CLOSE.get(settings);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:MockEngineSupport.java


示例3: MockFSDirectoryService

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
@Inject
public MockFSDirectoryService(IndexSettings idxSettings, IndexStore indexStore, final ShardPath path) {
    super(idxSettings, indexStore, path);
    Settings indexSettings = idxSettings.getSettings();
    final long seed = idxSettings.getValue(ESIntegTestCase.INDEX_TEST_SEED_SETTING);
    this.random = new Random(seed);

    randomIOExceptionRate = RANDOM_IO_EXCEPTION_RATE_SETTING.get(indexSettings);
    randomIOExceptionRateOnOpen = RANDOM_IO_EXCEPTION_RATE_ON_OPEN_SETTING.get(indexSettings);
    preventDoubleWrite = RANDOM_PREVENT_DOUBLE_WRITE_SETTING.get(indexSettings);
    noDeleteOpenFile = RANDOM_NO_DELETE_OPEN_FILE_SETTING.exists(indexSettings) ? RANDOM_NO_DELETE_OPEN_FILE_SETTING.get(indexSettings) : random.nextBoolean();
    random.nextInt(shardId.getId() + 1); // some randomness per shard
    throttle = MockDirectoryWrapper.Throttling.NEVER;
    crashIndex = CRASH_INDEX_SETTING.get(indexSettings);

    if (logger.isDebugEnabled()) {
        logger.debug("Using MockDirWrapper with seed [{}] throttle: [{}] crashIndex: [{}]", SeedUtils.formatSeed(seed),
                throttle, crashIndex);
    }
    delegateService = randomDirectorService(indexStore, path);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:MockFSDirectoryService.java


示例4: checkSignificantTermsAggregationCorrect

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
private static void checkSignificantTermsAggregationCorrect(ESIntegTestCase testCase) {
    SearchResponse response = client().prepareSearch(INDEX_NAME).setTypes(DOC_TYPE).addAggregation(
            terms("class").field(CLASS_FIELD).subAggregation(significantTerms("sig_terms").field(TEXT_FIELD)))
            .execute().actionGet();
    assertSearchResponse(response);
    StringTerms classes = response.getAggregations().get("class");
    Assert.assertThat(classes.getBuckets().size(), equalTo(2));
    for (Terms.Bucket classBucket : classes.getBuckets()) {
        Map<String, Aggregation> aggs = classBucket.getAggregations().asMap();
        Assert.assertTrue(aggs.containsKey("sig_terms"));
        SignificantTerms agg = (SignificantTerms) aggs.get("sig_terms");
        Assert.assertThat(agg.getBuckets().size(), equalTo(1));
        SignificantTerms.Bucket sigBucket = agg.iterator().next();
        String term = sigBucket.getKeyAsString();
        String classTerm = classBucket.getKeyAsString();
        Assert.assertTrue(term.equals(classTerm));
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:19,代码来源:SharedSignificantTermsTestMethods.java


示例5: index01Docs

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
public static void index01Docs(String type, String settings, ESIntegTestCase testCase) throws ExecutionException, InterruptedException {
    String textMappings = "type=" + type;
    if (type.equals("text")) {
        textMappings += ",fielddata=true";
    }
    assertAcked(testCase.prepareCreate(INDEX_NAME).setSettings(settings, XContentType.JSON)
            .addMapping("doc", "text", textMappings, CLASS_FIELD, "type=keyword"));
    String[] gb = {"0", "1"};
    List<IndexRequestBuilder> indexRequestBuilderList = new ArrayList<>();
    indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "1")
            .setSource(TEXT_FIELD, "1", CLASS_FIELD, "1"));
    indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "2")
            .setSource(TEXT_FIELD, "1", CLASS_FIELD, "1"));
    indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "3")
            .setSource(TEXT_FIELD, "0", CLASS_FIELD, "0"));
    indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "4")
            .setSource(TEXT_FIELD, "0", CLASS_FIELD, "0"));
    indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "5")
            .setSource(TEXT_FIELD, gb, CLASS_FIELD, "1"));
    indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "6")
            .setSource(TEXT_FIELD, gb, CLASS_FIELD, "0"));
    indexRequestBuilderList.add(client().prepareIndex(INDEX_NAME, DOC_TYPE, "7")
            .setSource(TEXT_FIELD, "0", CLASS_FIELD, "0"));
    testCase.indexRandom(true, false, indexRequestBuilderList);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:SharedSignificantTermsTestMethods.java


示例6: appendESProperties

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
public ReproduceErrorMessageBuilder appendESProperties() {
    appendProperties("tests.es.logger.level");
    if (inVerifyPhase()) {
        // these properties only make sense for integration tests
        appendProperties(ESIntegTestCase.TESTS_ENABLE_MOCK_MODULES);
    }
    appendProperties("tests.assertion.disabled", "tests.security.manager", "tests.nightly", "tests.jvms",
                     "tests.client.ratio", "tests.heap.size", "tests.bwc", "tests.bwc.version");
    if (System.getProperty("tests.jvm.argline") != null && !System.getProperty("tests.jvm.argline").isEmpty()) {
        appendOpt("tests.jvm.argline", "\"" + System.getProperty("tests.jvm.argline") + "\"");
    }
    appendOpt("tests.locale", Locale.getDefault().toLanguageTag());
    appendOpt("tests.timezone", TimeZone.getDefault().getID());
    return this;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:16,代码来源:ReproduceInfoPrinter.java


示例7: areAllSupported

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
/**
 * Tells whether all the features provided as argument are supported
 */
public static boolean areAllSupported(List<String> features) {
    for (String feature : features) {
        if ("requires_replica".equals(feature) && ESIntegTestCase.cluster().numDataNodes() >= 2) {
            continue;
        }
        if (!SUPPORTED.contains(feature)) {
            return false;
        }
    }
    return true;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:15,代码来源:Features.java


示例8: aggregateAndCheckFromSeveralShards

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
public static void aggregateAndCheckFromSeveralShards(ESIntegTestCase testCase) throws ExecutionException, InterruptedException {
    String type = ESTestCase.randomBoolean() ? "text" : "keyword";
    String settings = "{\"index.number_of_shards\": 5, \"index.number_of_replicas\": 0}";
    index01Docs(type, settings, testCase);
    testCase.ensureGreen();
    testCase.logClusterState();
    checkSignificantTermsAggregationCorrect(testCase);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:9,代码来源:SharedSignificantTermsTestMethods.java


示例9: testPutAndFlush

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
@Test
public void testPutAndFlush() throws Exception {
  InternalTestCluster cluster = ESIntegTestCase.internalCluster();
  cluster.ensureAtLeastNumDataNodes(3);
  Map<String, String> props = createProps();

  ElasticsearchSinkTask task = new ElasticsearchSinkTask();
  task.start(props, client);
  task.open(new HashSet<>(Arrays.asList(TOPIC_PARTITION, TOPIC_PARTITION2, TOPIC_PARTITION3)));

  String key = "key";
  Schema schema = createSchema();
  Struct record = createRecord(schema);

  Collection<SinkRecord> records = new ArrayList<>();
  SinkRecord sinkRecord = new SinkRecord(TOPIC, PARTITION, Schema.STRING_SCHEMA, key, schema, record, 0);
  records.add(sinkRecord);

  sinkRecord = new SinkRecord(TOPIC, PARTITION, Schema.STRING_SCHEMA, key, schema, record, 1);
  records.add(sinkRecord);

  task.put(records);
  task.flush(null);

  refresh();

  verifySearchResults(records, true, false);
}
 
开发者ID:confluentinc,项目名称:kafka-connect-elasticsearch,代码行数:29,代码来源:ElasticsearchSinkTaskTest.java


示例10: testMapping

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testMapping() throws Exception {
  InternalTestCluster cluster = ESIntegTestCase.internalCluster();
  cluster.ensureAtLeastNumDataNodes(1);

  createIndex(INDEX);
  Schema schema = createSchema();
  Mapping.createMapping(client, INDEX, TYPE, schema);

  JsonObject mapping = Mapping.getMapping(client, INDEX, TYPE);
  assertNotNull(mapping);
  verifyMapping(schema, mapping);
}
 
开发者ID:confluentinc,项目名称:kafka-connect-elasticsearch,代码行数:15,代码来源:MappingTest.java


示例11: AssertingTransportInterceptor

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
public AssertingTransportInterceptor(Settings settings, NamedWriteableRegistry namedWriteableRegistry) {
    final long seed = ESIntegTestCase.INDEX_TEST_SEED_SETTING.get(settings);
    random = new Random(seed);
    this.namedWriteableRegistry = namedWriteableRegistry;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:AssertingTransportInterceptor.java


示例12: ThrowingSubReaderWrapper

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
ThrowingSubReaderWrapper(Settings settings) {
    final long seed = ESIntegTestCase.INDEX_TEST_SEED_SETTING.get(settings);
    this.topLevelRatio = EXCEPTION_TOP_LEVEL_RATIO_SETTING.get(settings);
    this.lowLevelRatio = EXCEPTION_LOW_LEVEL_RATIO_SETTING.get(settings);
    this.random = new Random(seed);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:RandomExceptionCircuitBreakerIT.java


示例13: testRetrieveSnapshots

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
public void testRetrieveSnapshots() throws Exception {
    final Client client = client();
    final Path location = ESIntegTestCase.randomRepoPath(node().settings());
    final String repositoryName = "test-repo";

    logger.info("-->  creating repository");
    PutRepositoryResponse putRepositoryResponse =
        client.admin().cluster().preparePutRepository(repositoryName)
                                .setType("fs")
                                .setSettings(Settings.builder().put(node().settings()).put("location", location))
                                .get();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));

    logger.info("--> creating an index and indexing documents");
    final String indexName = "test-idx";
    createIndex(indexName);
    ensureGreen();
    int numDocs = randomIntBetween(10, 20);
    for (int i = 0; i < numDocs; i++) {
        String id = Integer.toString(i);
        client().prepareIndex(indexName, "type1", id).setSource("text", "sometext").get();
    }
    client().admin().indices().prepareFlush(indexName).get();

    logger.info("--> create first snapshot");
    CreateSnapshotResponse createSnapshotResponse = client.admin()
                                                          .cluster()
                                                          .prepareCreateSnapshot(repositoryName, "test-snap-1")
                                                          .setWaitForCompletion(true)
                                                          .setIndices(indexName)
                                                          .get();
    final SnapshotId snapshotId1 = createSnapshotResponse.getSnapshotInfo().snapshotId();

    logger.info("--> create second snapshot");
    createSnapshotResponse = client.admin()
                                   .cluster()
                                   .prepareCreateSnapshot(repositoryName, "test-snap-2")
                                   .setWaitForCompletion(true)
                                   .setIndices(indexName)
                                   .get();
    final SnapshotId snapshotId2 = createSnapshotResponse.getSnapshotInfo().snapshotId();

    logger.info("--> make sure the node's repository can resolve the snapshots");
    final RepositoriesService repositoriesService = getInstanceFromNode(RepositoriesService.class);
    @SuppressWarnings("unchecked") final BlobStoreRepository repository =
        (BlobStoreRepository) repositoriesService.repository(repositoryName);
    final List<SnapshotId> originalSnapshots = Arrays.asList(snapshotId1, snapshotId2);

    List<SnapshotId> snapshotIds = repository.getRepositoryData().getSnapshotIds().stream()
        .sorted((s1, s2) -> s1.getName().compareTo(s2.getName())).collect(Collectors.toList());
    assertThat(snapshotIds, equalTo(originalSnapshots));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:53,代码来源:BlobStoreRepositoryTests.java


示例14: ThrowingSubReaderWrapper

import org.elasticsearch.test.ESIntegTestCase; //导入依赖的package包/类
ThrowingSubReaderWrapper(Settings settings) {
    final long seed = ESIntegTestCase.INDEX_TEST_SEED_SETTING.get(settings);
    this.topLevelRatio = settings.getAsDouble(EXCEPTION_TOP_LEVEL_RATIO_KEY, 0.1d);
    this.lowLevelRatio = settings.getAsDouble(EXCEPTION_LOW_LEVEL_RATIO_KEY, 0.1d);
    this.random = new Random(seed);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:7,代码来源:SearchWithRandomExceptionsIT.java



注:本文中的org.elasticsearch.test.ESIntegTestCase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AndroidUpnpService类代码示例发布时间:2022-05-21
下一篇:
Java WidgetUtil类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap