-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It is possible to disable NodeAndClusterIdConverter plugin.
Signed-off-by: Lukasz Soszynski <lukasz.soszynski@eliatra.com>
- Loading branch information
1 parent
38372e1
commit 98de5e7
Showing
2 changed files
with
60 additions
and
1 deletion.
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
51 changes: 51 additions & 0 deletions
51
server/src/test/java/org/opensearch/common/logging/NodeAndClusterIdConverterTest.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,51 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.common.logging; | ||
|
||
import org.apache.lucene.util.SetOnce; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class NodeAndClusterIdConverterTest { | ||
|
||
public static final String NODE_ID = "node-id"; | ||
public static final String CLUSTER_UUID = "cluster-uuid"; | ||
|
||
@After | ||
@Before | ||
public void cleanSystemProperties() { | ||
System.clearProperty(NodeAndClusterIdConverter.ENABLED_SYSTEM_PROPERTY); | ||
} | ||
|
||
@Test(expected = SetOnce.AlreadySetException.class) | ||
public void testTryToSetClusterAndNodeIdByDefault() { | ||
NodeAndClusterIdConverter.setNodeIdAndClusterId(NODE_ID, CLUSTER_UUID); | ||
NodeAndClusterIdConverter.setNodeIdAndClusterId(NODE_ID, CLUSTER_UUID); | ||
} | ||
|
||
@Test(expected = SetOnce.AlreadySetException.class) | ||
public void testTryToSetClusterAndNodeIdWhenPluginIsEnabled() { | ||
System.setProperty(NodeAndClusterIdConverter.ENABLED_SYSTEM_PROPERTY, "true"); | ||
|
||
NodeAndClusterIdConverter.setNodeIdAndClusterId(NODE_ID, CLUSTER_UUID); | ||
NodeAndClusterIdConverter.setNodeIdAndClusterId(NODE_ID, CLUSTER_UUID); | ||
} | ||
|
||
@Test | ||
public void testNotSetClusterIdWhenPluginIsDisabled() { | ||
System.setProperty(NodeAndClusterIdConverter.ENABLED_SYSTEM_PROPERTY, "false"); | ||
|
||
NodeAndClusterIdConverter.setNodeIdAndClusterId(NODE_ID, CLUSTER_UUID); | ||
|
||
// second invocation should not throw an exception | ||
NodeAndClusterIdConverter.setNodeIdAndClusterId(NODE_ID, CLUSTER_UUID); | ||
} | ||
|
||
} |