Fix a few more renaming issues. (#464)

This commit fixes some more missed instances where we can perform the renaming to OpenSearch.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-03-26 12:05:16 -07:00 committed by GitHub
parent 58dbb59e01
commit 3460a8c213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 38 additions and 32 deletions

View File

@ -79,7 +79,7 @@ class InternalDistributionArchiveCheckPluginFuncTest extends AbstractGradleFuncT
def "fails on unexpected notice content"() {
given:
license(file("LICENSE.txt"))
file("NOTICE.txt").text = """Elasticsearch
file("NOTICE.txt").text = """OpenSearch
Copyright 2009-2018 Acme Coorp"""
buildFile << """
apply plugin:'base'

View File

@ -53,7 +53,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
private static final String FAKE_SNAPSHOT_IVY_GROUP = "opensearch-distribution-snapshot";
private static final String DOWNLOAD_REPO_NAME = "opensearch-downloads";
private static final String SNAPSHOT_REPO_NAME = "opensearch-snapshots";
public static final String DISTRO_EXTRACTED_CONFIG_PREFIX = "es_distro_extracted_";
public static final String DISTRO_EXTRACTED_CONFIG_PREFIX = "opensearch_distro_extracted_";
private NamedDomainObjectContainer<OpenSearchDistribution> distributionsContainer;
private NamedDomainObjectContainer<DistributionResolution> distributionsResolutionStrategiesContainer;
@ -85,7 +85,7 @@ public class DistributionDownloadPlugin implements Plugin<Project> {
private void setupDistributionContainer(Project project, Provider<DockerSupportService> dockerSupport) {
distributionsContainer = project.container(OpenSearchDistribution.class, name -> {
Configuration fileConfiguration = project.getConfigurations().create("es_distro_file_" + name);
Configuration fileConfiguration = project.getConfigurations().create("opensearch_distro_file_" + name);
Configuration extractedConfiguration = project.getConfigurations().create(DISTRO_EXTRACTED_CONFIG_PREFIX + name);
extractedConfiguration.getAttributes().attribute(ArtifactAttributes.ARTIFACT_FORMAT, ArtifactTypeDefinition.DIRECTORY_TYPE);
return new OpenSearchDistribution(name, project.getObjects(), dockerSupport, fileConfiguration, extractedConfiguration);

View File

@ -96,8 +96,8 @@ import static java.util.Objects.requireNonNull;
public class OpenSearchNode implements TestClusterConfiguration {
private static final Logger LOGGER = Logging.getLogger(OpenSearchNode.class);
private static final int ES_DESTROY_TIMEOUT = 20;
private static final TimeUnit ES_DESTROY_TIMEOUT_UNIT = TimeUnit.SECONDS;
private static final int OPENSEARCH_DESTROY_TIMEOUT = 20;
private static final TimeUnit OPENSEARCH_DESTROY_TIMEOUT_UNIT = TimeUnit.SECONDS;
private static final int NODE_UP_TIMEOUT = 2;
private static final TimeUnit NODE_UP_TIMEOUT_UNIT = TimeUnit.MINUTES;
@ -916,7 +916,11 @@ public class OpenSearchNode implements TestClusterConfiguration {
if (processHandle.isAlive() == false) {
return;
}
LOGGER.info("process did not terminate after {} {}, stopping it forcefully", ES_DESTROY_TIMEOUT, ES_DESTROY_TIMEOUT_UNIT);
LOGGER.info(
"process did not terminate after {} {}, stopping it forcefully",
OPENSEARCH_DESTROY_TIMEOUT,
OPENSEARCH_DESTROY_TIMEOUT_UNIT
);
processHandle.destroyForcibly();
}
@ -1007,7 +1011,7 @@ public class OpenSearchNode implements TestClusterConfiguration {
private void waitForProcessToExit(ProcessHandle processHandle) {
try {
processHandle.onExit().get(ES_DESTROY_TIMEOUT, ES_DESTROY_TIMEOUT_UNIT);
processHandle.onExit().get(OPENSEARCH_DESTROY_TIMEOUT, OPENSEARCH_DESTROY_TIMEOUT_UNIT);
} catch (InterruptedException e) {
LOGGER.info("Interrupted while waiting for ES process", e);
Thread.currentThread().interrupt();

View File

@ -137,8 +137,8 @@ public class TestClustersPlugin implements Plugin<Project> {
private void createListClustersTask(Project project, NamedDomainObjectContainer<OpenSearchCluster> container) {
// Task is never up to date so we can pass an lambda for the task action
project.getTasks().register(LIST_TASK_NAME, task -> {
task.setGroup("ES cluster formation");
task.setDescription("Lists all ES clusters configured for this project");
task.setGroup("OpenSearch cluster formation");
task.setDescription("Lists all OpenSearch clusters configured for this project");
task.doLast(
(Task t) -> container.forEach(cluster -> logger.lifecycle(" * {}: {}", cluster.getName(), cluster.getNumberOfNodes()))
);

View File

@ -52,7 +52,7 @@ import java.util.concurrent.atomic.AtomicReference;
public class Sniffer implements Closeable {
private static final Log logger = LogFactory.getLog(Sniffer.class);
private static final String SNIFFER_THREAD_NAME = "es_rest_client_sniffer";
private static final String SNIFFER_THREAD_NAME = "opensearch_rest_client_sniffer";
private final NodesSniffer nodesSniffer;
private final RestClient restClient;

View File

@ -630,7 +630,7 @@ public class SnifferTests extends RestClientTestCase {
}
});
assertThat(thread.getName(), equalTo("es_rest_client_sniffer[T#" + i + "]"));
assertThat(thread.getName(), equalTo("opensearch_rest_client_sniffer[T#" + i + "]"));
assertThat(thread.isDaemon(), is(true));
}
} finally {

View File

@ -850,7 +850,7 @@ class InstallPluginCommand extends EnvironmentAwareCommand {
throws Exception {
final PluginInfo info = loadPluginInfo(terminal, tmpRoot, env);
// read optional security policy (extra permissions), if it exists, confirm or warn the user
Path policy = tmpRoot.resolve(PluginInfo.ES_PLUGIN_POLICY);
Path policy = tmpRoot.resolve(PluginInfo.OPENSEARCH_PLUGIN_POLICY);
final Set<String> permissions;
if (Files.exists(policy)) {
permissions = PluginSecurity.parsePermissions(policy, env.tmpFile());

View File

@ -755,7 +755,7 @@ public class InstallPluginCommandTests extends OpenSearchTestCase {
public void testContainsIntermediateDirectory() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);
Path pluginDir = createPluginDir(temp);
Files.createFile(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES));
Files.createFile(pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES));
String pluginZip = writeZip(pluginDir, "opensearch").toUri().toURL().toString();
UserException e = expectThrows(UserException.class, () -> installPlugin(pluginZip, env.v1()));
assertThat(e.getMessage(), containsString("This plugin was built with an older plugin structure"));

View File

@ -228,14 +228,14 @@ public class ListPluginsCommandTests extends OpenSearchTestCase {
final Path pluginDir = env.pluginsFile().resolve("fake1");
Files.createDirectories(pluginDir);
NoSuchFileException e = expectThrows(NoSuchFileException.class, () -> listPlugins(home));
assertEquals(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES).toString(), e.getFile());
assertEquals(pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES).toString(), e.getFile());
}
public void testPluginWithWrongDescriptorFile() throws Exception {
final Path pluginDir = env.pluginsFile().resolve("fake1");
PluginTestUtil.writePluginProperties(pluginDir, "description", "fake desc");
IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> listPlugins(home));
final Path descriptorPath = pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES);
final Path descriptorPath = pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES);
assertEquals("property [name] is missing in [" + descriptorPath.toString() + "]", e.getMessage());
}

View File

@ -219,20 +219,20 @@ public class GceSeedHostsProvider implements SeedHostsProvider {
logger.trace("current node found. Ignoring {} - {}", name, ip_private);
} else {
String address = ip_private;
// Test if we have es_port metadata defined here
if (instance.getMetadata() != null && instance.getMetadata().containsKey("es_port")) {
Object es_port = instance.getMetadata().get("es_port");
logger.trace("es_port is defined with {}", es_port);
if (es_port instanceof String) {
address = address.concat(":").concat((String) es_port);
// Test if we have opensearch_port metadata defined here
if (instance.getMetadata() != null && instance.getMetadata().containsKey("opensearch_port")) {
Object opensearch_port = instance.getMetadata().get("opensearch_port");
logger.trace("opensearch_port is defined with {}", opensearch_port);
if (opensearch_port instanceof String) {
address = address.concat(":").concat((String) opensearch_port);
} else {
// Ignoring other values
logger.trace("es_port is instance of {}. Ignoring...", es_port.getClass().getName());
logger.trace("opensearch_port is instance of {}. Ignoring...", opensearch_port.getClass().getName());
}
}
// ip_private is a single IP Address. We need to build a TransportAddress from it
// If user has set `es_port` metadata, we don't need to ping all ports
// If user has set `opensearch_port` metadata, we don't need to ping all ports
TransportAddress[] addresses = transportService.addressesFromString(address);
for (TransportAddress transportAddress : addresses) {

View File

@ -168,7 +168,7 @@ final class Security {
// now process each one
for (Path plugin : pluginsAndModules) {
Path policyFile = plugin.resolve(PluginInfo.ES_PLUGIN_POLICY);
Path policyFile = plugin.resolve(PluginInfo.OPENSEARCH_PLUGIN_POLICY);
if (Files.exists(policyFile)) {
// first get a list of URLs for the plugins' jars:
// we resolve symlinks so map is keyed on the normalize codebase name

View File

@ -1244,7 +1244,7 @@ public final class NodeEnvironment implements Closeable {
}
// package private for testing
static final String TEMP_FILE_NAME = ".es_temp_file";
static final String TEMP_FILE_NAME = ".opensearch_temp_file";
private static void tryWriteTempFile(Path path) throws IOException {
if (Files.exists(path)) {

View File

@ -133,7 +133,7 @@ public class FsHealthService extends AbstractLifecycleComponent implements NodeH
class FsHealthMonitor implements Runnable {
static final String TEMP_FILE_NAME = ".es_temp_file";
static final String TEMP_FILE_NAME = ".opensearch_temp_file";
private byte[] byteToWrite;
FsHealthMonitor(){

View File

@ -46,8 +46,8 @@ import java.util.stream.Collectors;
*/
public class PluginInfo implements Writeable, ToXContentObject {
public static final String ES_PLUGIN_PROPERTIES = "plugin-descriptor.properties";
public static final String ES_PLUGIN_POLICY = "plugin-security.policy";
public static final String OPENSEARCH_PLUGIN_PROPERTIES = "plugin-descriptor.properties";
public static final String OPENSEARCH_PLUGIN_POLICY = "plugin-security.policy";
private final String name;
private final String description;
@ -148,7 +148,7 @@ public class PluginInfo implements Writeable, ToXContentObject {
* @throws IOException if an I/O exception occurred reading the plugin descriptor
*/
public static PluginInfo readFromProperties(final Path path) throws IOException {
final Path descriptor = path.resolve(ES_PLUGIN_PROPERTIES);
final Path descriptor = path.resolve(OPENSEARCH_PLUGIN_PROPERTIES);
final Map<String, String> propsMap;
{

View File

@ -162,7 +162,8 @@ public class BootstrapForTesting {
// guarantee plugin classes are initialized first, in case they have one-time hacks.
// this just makes unit testing more realistic
for (URL url : Collections.list(BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.ES_PLUGIN_PROPERTIES))) {
for (URL url : Collections.list(
BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES))) {
Properties properties = new Properties();
try (InputStream stream = FileSystemUtils.openFileURLStream(url)) {
properties.load(stream);
@ -200,7 +201,8 @@ public class BootstrapForTesting {
*/
@SuppressForbidden(reason = "accesses fully qualified URLs to configure security")
static Map<String,Policy> getPluginPermissions() throws Exception {
List<URL> pluginPolicies = Collections.list(BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.ES_PLUGIN_POLICY));
List<URL> pluginPolicies =
Collections.list(BootstrapForTesting.class.getClassLoader().getResources(PluginInfo.OPENSEARCH_PLUGIN_POLICY));
if (pluginPolicies.isEmpty()) {
return Collections.emptyMap();
}

View File

@ -29,7 +29,7 @@ import java.util.Properties;
public class PluginTestUtil {
public static void writePluginProperties(Path pluginDir, String... stringProps) throws IOException {
writeProperties(pluginDir.resolve(PluginInfo.ES_PLUGIN_PROPERTIES), stringProps);
writeProperties(pluginDir.resolve(PluginInfo.OPENSEARCH_PLUGIN_PROPERTIES), stringProps);
}
/** convenience method to write a plugin properties file */