Skip to content

Commit

Permalink
fix(tests): Complete waiting for JNLP readiness when completed immedi…
Browse files Browse the repository at this point in the history
…ately
  • Loading branch information
olivergondza committed Oct 5, 2023
1 parent 621efac commit 80b6780
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,8 @@ protected void _terminate(TaskListener listener) {
}
}

getLauncherFactory().onNodeTerminated();

// Wrap deletion disposables into statistics tracking disposables
AsyncResourceDisposer.get().dispose(
new RecordDisposal(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ public abstract class LauncherFactory extends AbstractDescribableImpl<LauncherFa
*/
public abstract @CheckForNull String isWaitingFor(@Nonnull JCloudsSlave slave) throws JCloudsCloud.ProvisioningFailedException;

/**
* Callback run when the node is being terminated.
*
* This is before the resources are removed.
*/
public void onNodeTerminated() {
}

/**
* Launch nodes via ssh-slaves plugin.
*/
Expand Down Expand Up @@ -233,6 +241,14 @@ public static final class JNLP extends LauncherFactory {

public static final LauncherFactory JNLP = new JNLP();

/**
* Track the termination.
*
* This is needed so JNLP#isWaitingFor() reports completion when node is terminated before
* JCloudsSlaveTEmplate#provisionSlave() detects provisioning is completed.
*/
private transient boolean terminated = false;

@DataBoundConstructor // Needed for JCasC
public JNLP() {}

Expand All @@ -245,7 +261,16 @@ public ComputerLauncher createLauncher(@Nonnull JCloudsSlave slave) throws IOExc
@Override
public @CheckForNull String isWaitingFor(@Nonnull JCloudsSlave slave) {
// The address might not be visible at all so let's just wait for connection.
return slave.getChannel() != null ? null : "JNLP connection was not established yet";
return terminated || slave.getChannel() != null
? null
: "JNLP connection was not established yet"
;
}

@Override
public void onNodeTerminated() {
terminated = true;
super.onNodeTerminated();
}

@Override
Expand Down

0 comments on commit 80b6780

Please sign in to comment.