-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 6.x: SQL: Preserve scoring in bool queries (#30730) QA: Switch rolling upgrade to 3 nodes [ML] Don't install empty ML metadata on startup (#30751) bump lucene version for 6_3_0 [DOCS] Mark painless execute api as experimental (#30710) Add more script contexts (#30721)
- Loading branch information
Showing
54 changed files
with
505 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/AbstractRollingTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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.elasticsearch.upgrades; | ||
|
||
import org.apache.http.entity.ContentType; | ||
import org.apache.http.entity.StringEntity; | ||
import org.elasticsearch.Version; | ||
import org.elasticsearch.action.support.PlainActionFuture; | ||
import org.elasticsearch.client.Response; | ||
import org.elasticsearch.cluster.metadata.IndexMetaData; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.util.concurrent.AbstractRunnable; | ||
import org.elasticsearch.test.rest.ESRestTestCase; | ||
import org.elasticsearch.test.rest.yaml.ObjectPath; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.Future; | ||
import java.util.function.Predicate; | ||
|
||
import static com.carrotsearch.randomizedtesting.RandomizedTest.randomAsciiOfLength; | ||
import static java.util.Collections.emptyMap; | ||
import static org.elasticsearch.cluster.routing.UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING; | ||
import static org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE_SETTING; | ||
import static org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.notNullValue; | ||
|
||
public abstract class AbstractRollingTestCase extends ESRestTestCase { | ||
protected enum ClusterType { | ||
OLD, | ||
MIXED, | ||
UPGRADED; | ||
|
||
public static ClusterType parse(String value) { | ||
switch (value) { | ||
case "old_cluster": | ||
return OLD; | ||
case "mixed_cluster": | ||
return MIXED; | ||
case "upgraded_cluster": | ||
return UPGRADED; | ||
default: | ||
throw new AssertionError("unknown cluster type: " + value); | ||
} | ||
} | ||
} | ||
|
||
protected static final ClusterType CLUSTER_TYPE = ClusterType.parse(System.getProperty("tests.rest.suite")); | ||
|
||
@Override | ||
protected final boolean preserveIndicesUponCompletion() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected final boolean preserveReposUponCompletion() { | ||
return true; | ||
} | ||
|
||
@Override | ||
protected final Settings restClientSettings() { | ||
return Settings.builder().put(super.restClientSettings()) | ||
// increase the timeout here to 90 seconds to handle long waits for a green | ||
// cluster health. the waits for green need to be longer than a minute to | ||
// account for delayed shards | ||
.put(ESRestTestCase.CLIENT_RETRY_TIMEOUT, "90s") | ||
.put(ESRestTestCase.CLIENT_SOCKET_TIMEOUT, "90s") | ||
.build(); | ||
} | ||
} |
135 changes: 135 additions & 0 deletions
135
qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you 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.elasticsearch.upgrades; | ||
|
||
import org.apache.http.util.EntityUtils; | ||
import org.elasticsearch.common.Booleans; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.Response; | ||
|
||
import java.io.IOException; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
/** | ||
* Basic test that indexed documents survive the rolling restart. See | ||
* {@link RecoveryIT} for much more in depth testing of the mechanism | ||
* by which they survive. | ||
*/ | ||
public class IndexingIT extends AbstractRollingTestCase { | ||
public void testIndexing() throws IOException { | ||
switch (CLUSTER_TYPE) { | ||
case OLD: | ||
break; | ||
case MIXED: | ||
Request waitForYellow = new Request("GET", "/_cluster/health"); | ||
waitForYellow.addParameter("wait_for_nodes", "3"); | ||
waitForYellow.addParameter("wait_for_status", "yellow"); | ||
client().performRequest(waitForYellow); | ||
break; | ||
case UPGRADED: | ||
Request waitForGreen = new Request("GET", "/_cluster/health/test_index,index_with_replicas,empty_index"); | ||
waitForGreen.addParameter("wait_for_nodes", "3"); | ||
waitForGreen.addParameter("wait_for_status", "green"); | ||
// wait for long enough that we give delayed unassigned shards to stop being delayed | ||
waitForGreen.addParameter("timeout", "70s"); | ||
waitForGreen.addParameter("level", "shards"); | ||
client().performRequest(waitForGreen); | ||
break; | ||
default: | ||
throw new UnsupportedOperationException("Unknown cluster type [" + CLUSTER_TYPE + "]"); | ||
} | ||
|
||
if (CLUSTER_TYPE == ClusterType.OLD) { | ||
Request createTestIndex = new Request("PUT", "/test_index"); | ||
createTestIndex.setJsonEntity("{\"settings\": {\"index.number_of_replicas\": 0}}"); | ||
client().performRequest(createTestIndex); | ||
|
||
String recoverQuickly = "{\"settings\": {\"index.unassigned.node_left.delayed_timeout\": \"100ms\"}}"; | ||
Request createIndexWithReplicas = new Request("PUT", "/index_with_replicas"); | ||
createIndexWithReplicas.setJsonEntity(recoverQuickly); | ||
client().performRequest(createIndexWithReplicas); | ||
|
||
Request createEmptyIndex = new Request("PUT", "/empty_index"); | ||
// Ask for recovery to be quick | ||
createEmptyIndex.setJsonEntity(recoverQuickly); | ||
client().performRequest(createEmptyIndex); | ||
|
||
bulk("test_index", "_OLD", 5); | ||
bulk("index_with_replicas", "_OLD", 5); | ||
} | ||
|
||
int expectedCount; | ||
switch (CLUSTER_TYPE) { | ||
case OLD: | ||
expectedCount = 5; | ||
break; | ||
case MIXED: | ||
if (Booleans.parseBoolean(System.getProperty("tests.first_round"))) { | ||
expectedCount = 5; | ||
} else { | ||
expectedCount = 10; | ||
} | ||
break; | ||
case UPGRADED: | ||
expectedCount = 15; | ||
break; | ||
default: | ||
throw new UnsupportedOperationException("Unknown cluster type [" + CLUSTER_TYPE + "]"); | ||
} | ||
|
||
assertCount("test_index", expectedCount); | ||
assertCount("index_with_replicas", 5); | ||
assertCount("empty_index", 0); | ||
|
||
if (CLUSTER_TYPE != ClusterType.OLD) { | ||
bulk("test_index", "_" + CLUSTER_TYPE, 5); | ||
Request toBeDeleted = new Request("PUT", "/test_index/doc/to_be_deleted"); | ||
toBeDeleted.addParameter("refresh", "true"); | ||
toBeDeleted.setJsonEntity("{\"f1\": \"delete-me\"}"); | ||
client().performRequest(toBeDeleted); | ||
assertCount("test_index", expectedCount + 6); | ||
|
||
Request delete = new Request("DELETE", "/test_index/doc/to_be_deleted"); | ||
delete.addParameter("refresh", "true"); | ||
client().performRequest(delete); | ||
|
||
assertCount("test_index", expectedCount + 5); | ||
} | ||
} | ||
|
||
private void bulk(String index, String valueSuffix, int count) throws IOException { | ||
StringBuilder b = new StringBuilder(); | ||
for (int i = 0; i < count; i++) { | ||
b.append("{\"index\": {\"_index\": \"").append(index).append("\", \"_type\": \"doc\"}}\n"); | ||
b.append("{\"f1\": \"v").append(i).append(valueSuffix).append("\", \"f2\": ").append(i).append("}\n"); | ||
} | ||
Request bulk = new Request("POST", "/_bulk"); | ||
bulk.addParameter("refresh", "true"); | ||
bulk.setJsonEntity(b.toString()); | ||
client().performRequest(bulk); | ||
} | ||
|
||
private void assertCount(String index, int count) throws IOException { | ||
Request searchTestIndexRequest = new Request("POST", "/" + index + "/_search"); | ||
searchTestIndexRequest.addParameter("filter_path", "hits.total"); | ||
Response searchTestIndexResponse = client().performRequest(searchTestIndexRequest); | ||
assertEquals("{\"hits\":{\"total\":" + count + "}}", | ||
EntityUtils.toString(searchTestIndexResponse.getEntity(), StandardCharsets.UTF_8)); | ||
} | ||
} |
Oops, something went wrong.