diff --git a/distribution/build.gradle b/distribution/build.gradle index 356aaa269e106..21b7d85a7ef2b 100644 --- a/distribution/build.gradle +++ b/distribution/build.gradle @@ -217,7 +217,7 @@ ext.restTestExpansions = [ // loop over modules to also setup cross task dependencies and increment our modules counter project.rootProject.subprojects.findAll { it.parent.path == ':modules' }.each { Project module -> if (module.name == 'systemd') { - // the systemd module is only included in the package distributions + // the systemd module is only included in the package distributions or in linux and freebsd archives return } File licenses = new File(module.projectDir, 'licenses') @@ -367,7 +367,7 @@ configure(subprojects.findAll { ['archives', 'packages'].contains(it.name) }) { if (BuildParams.isSnapshotBuild()) { from(buildExternalTestModulesTaskProvider) } - if (project.path.startsWith(':distribution:packages')) { + if (project.path.startsWith(':distribution:packages') || ['freebsd-x64','linux-x64', 'linux-arm64'].contains(platform)) { from(buildSystemdModuleTaskProvider) } } diff --git a/modules/systemd/src/main/java/org/opensearch/systemd/SystemdPlugin.java b/modules/systemd/src/main/java/org/opensearch/systemd/SystemdPlugin.java index 3a2d51950f0be..8abdbbb74ae7f 100644 --- a/modules/systemd/src/main/java/org/opensearch/systemd/SystemdPlugin.java +++ b/modules/systemd/src/main/java/org/opensearch/systemd/SystemdPlugin.java @@ -35,7 +35,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.lucene.util.SetOnce; -import org.opensearch.Build; import org.opensearch.client.Client; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; import org.opensearch.cluster.service.ClusterService; @@ -68,20 +67,10 @@ final boolean isEnabled() { @SuppressWarnings("unused") public SystemdPlugin() { - this(true, Build.CURRENT.type(), System.getenv("OPENSEARCH_SD_NOTIFY")); + this(System.getenv("OPENSEARCH_SD_NOTIFY")); } - SystemdPlugin(final boolean assertIsPackageDistribution, final Build.Type buildType, final String esSDNotify) { - final boolean isPackageDistribution = buildType == Build.Type.DEB || buildType == Build.Type.RPM; - if (assertIsPackageDistribution) { - // our build is configured to only include this module in the package distributions - assert isPackageDistribution : buildType; - } - if (isPackageDistribution == false) { - logger.debug("disabling sd_notify as the build type [{}] is not a package distribution", buildType); - enabled = false; - return; - } + SystemdPlugin(final String esSDNotify) { logger.trace("OPENSEARCH_SD_NOTIFY is set to [{}]", esSDNotify); if (esSDNotify == null) { enabled = false; diff --git a/modules/systemd/src/test/java/org/opensearch/systemd/SystemdPluginTests.java b/modules/systemd/src/test/java/org/opensearch/systemd/SystemdPluginTests.java index cc8ee649ab782..63d97a7486f58 100644 --- a/modules/systemd/src/test/java/org/opensearch/systemd/SystemdPluginTests.java +++ b/modules/systemd/src/test/java/org/opensearch/systemd/SystemdPluginTests.java @@ -32,7 +32,6 @@ package org.opensearch.systemd; -import org.opensearch.Build; import org.opensearch.common.CheckedConsumer; import org.opensearch.common.unit.TimeValue; import org.opensearch.test.OpenSearchTestCase; @@ -58,13 +57,6 @@ import static org.mockito.Mockito.when; public class SystemdPluginTests extends OpenSearchTestCase { - - private final Build.Type randomPackageBuildType = randomFrom(Build.Type.DEB, Build.Type.RPM); - private final Build.Type randomNonPackageBuildType = randomValueOtherThanMany( - t -> t == Build.Type.DEB || t == Build.Type.RPM, - () -> randomFrom(Build.Type.values()) - ); - final Scheduler.Cancellable extender = mock(Scheduler.Cancellable.class); final ThreadPool threadPool = mock(ThreadPool.class); @@ -74,29 +66,15 @@ public class SystemdPluginTests extends OpenSearchTestCase { .thenReturn(extender); } - public void testIsEnabled() { - final SystemdPlugin plugin = new SystemdPlugin(false, randomPackageBuildType, Boolean.TRUE.toString()); - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null, null); - assertTrue(plugin.isEnabled()); - assertNotNull(plugin.extender()); - } - - public void testIsNotPackageDistribution() { - final SystemdPlugin plugin = new SystemdPlugin(false, randomNonPackageBuildType, Boolean.TRUE.toString()); - plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null, null); - assertFalse(plugin.isEnabled()); - assertNull(plugin.extender()); - } - public void testIsImplicitlyNotEnabled() { - final SystemdPlugin plugin = new SystemdPlugin(false, randomPackageBuildType, null); + final SystemdPlugin plugin = new SystemdPlugin(null); plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null, null); assertFalse(plugin.isEnabled()); assertNull(plugin.extender()); } public void testIsExplicitlyNotEnabled() { - final SystemdPlugin plugin = new SystemdPlugin(false, randomPackageBuildType, Boolean.FALSE.toString()); + final SystemdPlugin plugin = new SystemdPlugin(Boolean.FALSE.toString()); plugin.createComponents(null, null, threadPool, null, null, null, null, null, null, null, null); assertFalse(plugin.isEnabled()); assertNull(plugin.extender()); @@ -107,7 +85,7 @@ public void testInvalid() { s -> Boolean.TRUE.toString().equals(s) || Boolean.FALSE.toString().equals(s), () -> randomAlphaOfLength(4) ); - final RuntimeException e = expectThrows(RuntimeException.class, () -> new SystemdPlugin(false, randomPackageBuildType, esSDNotify)); + final RuntimeException e = expectThrows(RuntimeException.class, () -> new SystemdPlugin(esSDNotify)); assertThat(e, hasToString(containsString("OPENSEARCH_SD_NOTIFY set to unexpected value [" + esSDNotify + "]"))); } @@ -174,7 +152,7 @@ private void runTest( final AtomicBoolean invoked = new AtomicBoolean(); final AtomicInteger invokedUnsetEnvironment = new AtomicInteger(); final AtomicReference invokedState = new AtomicReference<>(); - final SystemdPlugin plugin = new SystemdPlugin(false, randomPackageBuildType, esSDNotify) { + final SystemdPlugin plugin = new SystemdPlugin(esSDNotify) { @Override int sd_notify(final int unset_environment, final String state) {