Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check availability of Jenkins #434

Merged
merged 3 commits into from Jun 18, 2019

Conversation

4 participants
@praj-foss
Copy link
Member

commented Jun 18, 2019

Summary

Checks Jenkins availability during initialization and skips other tasks accordingly. Fixes #433.

Testing

Test launcher when Jenkins is offline (which I hope never happens).

Features

  • Jenkins URL in bundles
  • Check if Jenkins server is available
  • Skip launcher updates when Jenkins is unavailable
  • Skip syncing game versions when Jenkins is unavailable
Checks availability of Jenkins
- Adds Jenkins address in URI bundles
- Skips launcher update check if Jenkins is unavailable

@praj-foss praj-foss added the GSoC 2019 label Jun 18, 2019

@praj-foss praj-foss added this to In progress in GSOC 2019: Launcher via automation Jun 18, 2019

@GooeyHub

This comment has been minimized.

Copy link
Member

commented Jun 18, 2019

Uh oh, something went wrong with the build. Need to check on that

@skaldarnar
Copy link
Member

left a comment

Looks good. Only a few small changes required to make Jenkins happy, then I can hopefully merge it after lunch 😁

logger.trace("Checking Jenkins availability...");
final int timeout = 3000; // in milliseconds
HttpURLConnection connection = null;
try {

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 18, 2019

Member

Maybe you can use this pattern to use the try-with-resources feature of Java 8: https://stackoverflow.com/a/40123634

final int timeout = 3000; // in milliseconds
HttpURLConnection connection = null;
try {
final URL serverURL = Objects.requireNonNull(BundleUtils.getURI("terasology_jenkins")).toURL();

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 18, 2019

Member

I don't think this has to come from a Bundle - compare to DownloadUtils.java - you can just use a constant value.

This comment has been minimized.

Copy link
@praj-foss

praj-foss Jun 18, 2019

Author Member

Hmm... then should I turn JENKINS_JOB_URL public (inside DownloadUtils.java) or create another constant inside LauncherInitTask?

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 18, 2019

Member

See comment above. Move the method to DownloadUtils and make it public. Then just introduce another constant value and use that.

@GooeyHub

This comment has been minimized.

Copy link
Member

commented Jun 18, 2019

Hooray Jenkins reported success with all tests good!

@@ -58,6 +59,8 @@

private static final Logger logger = LoggerFactory.getLogger(DownloadUtils.class);

private static final String JENKINS_URL = "http://jenkins.terasology.org";
private static final int JENKINS_TIMEOUT = 3000; // milliseconds

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 18, 2019

Member

3 seconds might be a bit too small, but let's keep it for now - we can still adjust this value later.

throw new ConnectException();
}
}
} catch (Exception e) {

This comment has been minimized.

Copy link
@skaldarnar

skaldarnar Jun 18, 2019

Member

Please try to catch the most specific type of exception you can, e.g., IOException is better than just Exception. You could also use multiple catch (…) statements with the same try.

For instance, a NullPointerException would also be caught by this, although this is (hopefully) not intended here…

@skaldarnar skaldarnar merged commit 28a88a7 into develop Jun 18, 2019

1 check passed

default Build finished.
Details

GSOC 2019: Launcher automation moved this from In progress to Done Jun 18, 2019

@skaldarnar skaldarnar deleted the feature/online-check branch Jun 18, 2019

@Cervator Cervator added this to the v4.0.0 - GSOC 2019 milestone Jun 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.