コード例 #1
0
  public void testUpgrade() throws Exception {
    if (backwardsCluster().numNewDataNodes() == 0) {
      backwardsCluster().startNewNode();
    }

    int numIndexes = randomIntBetween(2, 4);
    String[] indexNames = new String[numIndexes];
    for (int i = 0; i < numIndexes; ++i) {
      String indexName = "test" + i;
      indexNames[i] = indexName;

      Settings settings =
          ImmutableSettings.builder()
              .put("index.routing.allocation.exclude._name", backwardsCluster().newNodePattern())
              // don't allow any merges so that we can check segments are upgraded
              // by the upgrader, and not just regular merging
              .put("index.merge.policy.segments_per_tier", 1000000f)
              .put(indexSettings())
              .build();

      assertAcked(prepareCreate(indexName).setSettings(settings));
      ensureGreen(indexName);
      assertAllShardsOnNodes(indexName, backwardsCluster().backwardsNodePattern());

      int numDocs = scaledRandomIntBetween(100, 1000);
      List<IndexRequestBuilder> builder = new ArrayList<>();
      for (int j = 0; j < numDocs; ++j) {
        String id = Integer.toString(j);
        builder.add(client().prepareIndex(indexName, "type1", id).setSource("text", "sometext"));
      }
      indexRandom(true, builder);
      ensureGreen(indexName);
      flushAndRefresh();
    }
    backwardsCluster().allowOnAllNodes(indexNames);
    backwardsCluster().upgradeAllNodes();
    ensureGreen();

    checkNotUpgraded("/_upgrade");
    final String indexToUpgrade = "test" + randomInt(numIndexes - 1);

    runUpgrade("/" + indexToUpgrade + "/_upgrade");
    awaitBusy(
        new Predicate<Object>() {
          @Override
          public boolean apply(Object o) {
            try {
              return isUpgraded("/" + indexToUpgrade + "/_upgrade");
            } catch (Exception e) {
              throw ExceptionsHelper.convertToRuntime(e);
            }
          }
        });

    runUpgrade("/_upgrade", "wait_for_completion", "true");
    checkUpgraded("/_upgrade");
  }
コード例 #2
0
  public void testUpgrade_0_20() throws Exception {
    // If this assert trips it means we are not suppressing enough codecs up above:
    assertFalse("test infra is broken!", LuceneTestCase.OLD_FORMAT_IMPERSONATION_IS_ACTIVE);
    File dataDir =
        prepareBackwardsDataDir(new File(getClass().getResource("index-0.20.zip").toURI()));
    internalCluster()
        .startNode(
            ImmutableSettings.builder()
                .put("path.data", dataDir.getPath())
                .put("gateway.type", "local") // this is important we need to recover from gateway
                .put(InternalNode.HTTP_ENABLED, true)
                .build());

    assertIndexSanity();

    HttpRequestBuilder httpClient = httpClient();

    UpgradeTest.assertNotUpgraded(httpClient, "test");
    UpgradeTest.runUpgrade(httpClient, "test", "wait_for_completion", "true");
    UpgradeTest.assertUpgraded(httpClient, "test");
  }