Skip to content

Commit

Permalink
Fix the Feature Launcher test reliability
Browse files Browse the repository at this point in the history
Some of the Feature Launcher tests deploy the Gogo Shell. If the Gogo shell detects that stdin has closed then it shuts down the framework automatically. When running in CI (and elsewhere) we use batch mode with no terminal which disconnects the test run and gives it an empty stdin. This causes the tests to fail as gogo shuts things down before the test finishes. Instead we must configure gogo to be non-interactive during the tests.

Signed-off-by: Tim Ward <timothyjward@apache.org>
  • Loading branch information
timothyjward committed Oct 9, 2024
1 parent 97e333f commit 6ac0354
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion integration-test.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
bnd.identity;id='org.glassfish.jakarta.json'

-runproperties: \
localRepositoryPath=${project.build.directory}/m2Repo
localRepositoryPath=${project.build.directory}/m2Repo,\
gosh.args=-s

-resolve.effective: active

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.kentyou.featurelauncher.impl;

import static com.kentyou.featurelauncher.impl.FeatureLauncherImplConstants.FRAMEWORK_STORAGE_CLEAN_TESTONLY;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
Expand Down Expand Up @@ -396,15 +394,15 @@ private void logBundleEvent(BundleEvent bundleEvent) {
}

private void cleanup(Framework framework) {

// Stopping the framework will stop all of the bundles
try {
framework.stop();
framework.waitForStop(0);
} catch (BundleException | InterruptedException e) {
LOG.error("A problem occurred while cleaning up the framework", e);
}

Collections.reverse(installedBundles);

if (!installedBundles.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.Optional;
import java.util.ServiceLoader;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
Expand Down Expand Up @@ -80,6 +81,20 @@ public void setUp(TestInfo info) throws InterruptedException, IOException {
throw new IllegalStateException("Error loading feature launcher!");
}
}

// The use of Gogo Shell requires that Std In is connected to a live
// terminal, which breaks builds using batch mode (like CI).
// We therefore tell gogo to be non-interactive

@BeforeEach
public void replaceStdInForGogo() throws IOException {
System.setProperty("gosh.args", "-s");
}

@AfterEach
public void resetStdIn() {
System.clearProperty("gosh.args");
}

@Test
public void testLaunchFeatureWithNoConfigWithDefaultFramework()
Expand Down

0 comments on commit 6ac0354

Please sign in to comment.