forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mark read-only flush and verify (elastic#119743)
When marking read-only now flush and mark index as verified guaranteeing that we can upgrade safely to next version with N-1 indices (becoming N-2). Use this in the deprecation check.
- Loading branch information
1 parent
ba57820
commit 1f26512
Showing
15 changed files
with
296 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 119743 | ||
summary: POC mark read-only | ||
area: Engine | ||
type: enhancement | ||
issues: [] |
70 changes: 70 additions & 0 deletions
70
...grade/src/javaRestTest/java/org/elasticsearch/upgrades/AddIndexBlockRollingUpgradeIT.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,70 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.upgrades; | ||
|
||
import io.netty.handler.codec.http.HttpMethod; | ||
|
||
import com.carrotsearch.randomizedtesting.annotations.Name; | ||
|
||
import org.elasticsearch.TransportVersions; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.client.ResponseException; | ||
import org.elasticsearch.cluster.metadata.MetadataIndexStateService; | ||
import org.hamcrest.Matchers; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
public class AddIndexBlockRollingUpgradeIT extends AbstractRollingUpgradeTestCase { | ||
|
||
private static final String INDEX_NAME = "test_add_block"; | ||
|
||
public AddIndexBlockRollingUpgradeIT(@Name("upgradedNodes") int upgradedNodes) { | ||
super(upgradedNodes); | ||
} | ||
|
||
public void testAddBlock() throws Exception { | ||
if (isOldCluster()) { | ||
createIndex(INDEX_NAME); | ||
} else if (isMixedCluster()) { | ||
blockWrites(); | ||
// this is used both for upgrading from 9.0.0 to current and from 8.18 to current. | ||
if (minimumTransportVersion().before(TransportVersions.ADD_INDEX_BLOCK_TWO_PHASE)) { | ||
assertNull(verifiedSettingValue()); | ||
} else { | ||
assertThat(verifiedSettingValue(), Matchers.equalTo("true")); | ||
} | ||
} else { | ||
assertTrue(isUpgradedCluster()); | ||
blockWrites(); | ||
assertThat(verifiedSettingValue(), Matchers.equalTo("true")); | ||
} | ||
} | ||
|
||
private static void blockWrites() throws IOException { | ||
client().performRequest(new Request(HttpMethod.PUT.name(), "/" + INDEX_NAME + "/_block/write")); | ||
|
||
expectThrows( | ||
ResponseException.class, | ||
() -> client().performRequest( | ||
newXContentRequest(HttpMethod.PUT, "/" + INDEX_NAME + "/_doc/test", (builder, params) -> builder.field("test", "test")) | ||
) | ||
); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
private static String verifiedSettingValue() throws IOException { | ||
final var settingsRequest = new Request(HttpMethod.GET.name(), "/" + INDEX_NAME + "/_settings?flat_settings"); | ||
final Map<String, Object> settingsResponse = entityAsMap(client().performRequest(settingsRequest)); | ||
return (String) ((Map<String, Object>) ((Map<String, Object>) settingsResponse.get(INDEX_NAME)).get("settings")).get( | ||
MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey() | ||
); | ||
} | ||
} |
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
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
Oops, something went wrong.