mirror of
https://github.com/rife2/bld
synced 2026-07-25 17:07:47 +02:00
Use @RetryTest to retry downloading resposilite (#93)
Some checks are pending
bld-ci / build (./bld, 17, macos-latest, false) (push) Waiting to run
bld-ci / build (./bld, 21, macos-latest, false) (push) Waiting to run
bld-ci / build (./bld, 25, macos-latest, false) (push) Waiting to run
bld-ci / build (./bld, 26, macos-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 17, windows-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 21, windows-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 25, windows-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 26, windows-latest, false) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 17, ubuntu-latest, true) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 21, ubuntu-latest, true) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 25, ubuntu-latest, true) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 26, ubuntu-latest, true) (push) Waiting to run
javadocs-pages / deploy (push) Waiting to run
Some checks are pending
bld-ci / build (./bld, 17, macos-latest, false) (push) Waiting to run
bld-ci / build (./bld, 21, macos-latest, false) (push) Waiting to run
bld-ci / build (./bld, 25, macos-latest, false) (push) Waiting to run
bld-ci / build (./bld, 26, macos-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 17, windows-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 21, windows-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 25, windows-latest, false) (push) Waiting to run
bld-ci / build (.\bld.bat, 26, windows-latest, false) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 17, ubuntu-latest, true) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 21, ubuntu-latest, true) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 25, ubuntu-latest, true) (push) Waiting to run
bld-ci / build (unittests, password, unittests, mariadb:10.9, mysql:8, gvenzl/oracle-free:latest, gvenzl/oracle-xe:18-slim, postgres:15, ./bld, 26, ubuntu-latest, true) (push) Waiting to run
javadocs-pages / deploy (push) Waiting to run
This commit is contained in:
parent
df66774338
commit
47740a114e
|
|
@ -32,7 +32,10 @@ public class BldBuild extends AbstractRife2Build {
|
|||
mainClass = "rife.bld.Cli";
|
||||
version = VersionNumber.parse(FileUtils.readString(new File(srcMainResourcesDirectory(), "BLD_VERSION")));
|
||||
|
||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES);
|
||||
repositories = List.of(MAVEN_CENTRAL, RIFE2_RELEASES, RIFE2_SNAPSHOTS);
|
||||
|
||||
scope(test)
|
||||
.include(dependency("com.uwyn.rife2", "bld-testing-helpers", version(1, 1, 0, "SNAPSHOT")));
|
||||
|
||||
var core_dir = new File(workDirectory(), "core");
|
||||
var core_src_dir = new File(core_dir, "src");
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
*/
|
||||
package rife.bld.operations;
|
||||
|
||||
import rife.bld.testing.RetryTest;
|
||||
import rife.json.Json;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||
import org.junit.jupiter.api.condition.OS;
|
||||
|
|
@ -32,46 +32,39 @@ import java.util.List;
|
|||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestPublishOperation {
|
||||
static File reposiliteJar_ = null;
|
||||
static volatile File reposiliteJar_ = null;
|
||||
|
||||
static synchronized void ensureReposilite() throws Exception {
|
||||
if (reposiliteJar_ != null && reposiliteJar_.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
static void downloadReposilite()
|
||||
throws Exception {
|
||||
reposiliteJar_ = File.createTempFile("reposilite", "jar");
|
||||
reposiliteJar_.deleteOnExit();
|
||||
var url = "https://maven.reposilite.com/releases/com/reposilite/reposilite/3.4.0/reposilite-3.4.0-all.jar";
|
||||
var url = new URL("https://maven.reposilite.com/releases/com/reposilite/reposilite/3.4.0/reposilite-3.4.0-all.jar");
|
||||
System.out.print("Downloading: " + url + " ...");
|
||||
System.out.flush();
|
||||
|
||||
// the reposilite CDN intermittently rate-limits with a 403 when
|
||||
// several matrix jobs download at the same time, retry with a
|
||||
// backoff before giving up
|
||||
var attempts = 5;
|
||||
for (var attempt = 1; ; ++attempt) {
|
||||
try {
|
||||
var connection = (HttpURLConnection) new URL(url).openConnection();
|
||||
connection.setRequestProperty("User-Agent", "bld-tests");
|
||||
connection.setConnectTimeout(30_000);
|
||||
connection.setReadTimeout(60_000);
|
||||
try (var input = connection.getInputStream()) {
|
||||
FileUtils.copy(input, reposiliteJar_);
|
||||
}
|
||||
break;
|
||||
} catch (IOException e) {
|
||||
if (attempt >= attempts) {
|
||||
throw e;
|
||||
}
|
||||
System.out.print(" retrying (" + e.getMessage() + ") ...");
|
||||
System.out.flush();
|
||||
Thread.sleep(attempt * 3_000L);
|
||||
}
|
||||
var connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestProperty("User-Agent", "bld-tests");
|
||||
connection.setConnectTimeout(30_000);
|
||||
connection.setReadTimeout(60_000);
|
||||
|
||||
int code = connection.getResponseCode();
|
||||
if (code >= 400) {
|
||||
throw new IOException("Server returned HTTP response code: " + code + " for URL: " + url);
|
||||
}
|
||||
|
||||
try (var in = connection.getInputStream()) {
|
||||
FileUtils.copy(in, reposiliteJar_);
|
||||
} finally {
|
||||
connection.disconnect();
|
||||
}
|
||||
System.out.println("done");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
static void deleteReposilite()
|
||||
throws Exception {
|
||||
static void deleteReposilite() {
|
||||
if (reposiliteJar_ != null) {
|
||||
reposiliteJar_.delete();
|
||||
reposiliteJar_ = null;
|
||||
|
|
@ -154,10 +147,12 @@ public class TestPublishOperation {
|
|||
assertEquals(19, operation3.publishProperties().mavenCompilerTarget());
|
||||
}
|
||||
|
||||
@Test
|
||||
@RetryTest(value = 5, delay = 5)
|
||||
@DisabledOnOs({OS.WINDOWS})
|
||||
void testPublishRelease()
|
||||
throws Exception {
|
||||
ensureReposilite();
|
||||
|
||||
var tmp1 = Files.createTempDirectory("test1").toFile();
|
||||
var tmp2 = Files.createTempDirectory("test2").toFile();
|
||||
var tmp_reposilite = Files.createTempDirectory("test").toFile();
|
||||
|
|
@ -421,10 +416,12 @@ public class TestPublishOperation {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@RetryTest(value = 5, delay = 5)
|
||||
@DisabledOnOs({OS.WINDOWS})
|
||||
void testPublishSnapshot()
|
||||
throws Exception {
|
||||
ensureReposilite();
|
||||
|
||||
var tmp1 = Files.createTempDirectory("test1").toFile();
|
||||
var tmp2 = Files.createTempDirectory("test2").toFile();
|
||||
var tmp_reposilite = Files.createTempDirectory("test").toFile();
|
||||
|
|
|
|||
Loading…
Reference in a new issue