Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup Go with cache
uses: jfrog/.github/actions/install-go-with-cache@main

Expand All @@ -43,5 +44,18 @@ jobs:
java-version: "8"
distribution: "zulu"

- name: Wait for Artifactory
run: |
for i in {1..30}; do
if curl -sf http://localhost:8081/artifactory/api/system/ping; then
echo "Artifactory is up!"
exit 0
fi
echo "Waiting for Artifactory..."
sleep 10
done
echo "Artifactory did not start in time"
exit 1

- name: Run tests
run: ./gradlew${{ matrix.gradlewSuffix }} clean test
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ subprojects {
exclude group: 'commons-codec', module: 'commons-codec'
}
implementation 'commons-codec:commons-codec:1.13'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.14.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.1'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.14.1'
api 'org.jfrog.filespecs:file-specs-java:1.1.1'
implementation 'org.apache.commons:commons-lang3:3.18.0'
implementation 'com.fasterxml.jackson.core:jackson-core:2.19.1'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.19.1'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.19.1'
api 'org.jfrog.filespecs:file-specs-java:1.1.2'
}

task sourcesJar(type: Jar, dependsOn: classes) {
Expand Down
2 changes: 1 addition & 1 deletion httpClient/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ repositories {

dependencies {
testImplementation group: 'org.testng', name: 'testng', version: '7.5.1'
testImplementation group: 'com.github.tomakehurst', name: 'wiremock-jre8', version: '2.35.1'
testImplementation group: 'com.github.tomakehurst', name: 'wiremock-jre8', version: '2.35.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private SSLContext buildSslContext() {
sslContext = sslBuilder.build();
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Error building SSLContext: " + e.getMessage(), e);
}
return sslContext != null ? sslContext : SSLContexts.createDefault();
}
Expand Down
2 changes: 1 addition & 1 deletion services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
* https://github.com/jfrog/artifactory-client-java/issues/43
* https://github.com/jfrog/artifactory-client-java/issues/232
*/
testRuntimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
testRuntimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: '1.3.15'
}

task createReleasePropertiesFile(type: Exec) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ abstract class BaseRepositoryTests extends ArtifactoryTestsBase {
@BeforeMethod
protected void setUp() {
String id = Long.toString(repoUniqueId)
println "[SETUP] Starting test setup for repo id: $id at ${new Date()}"
if (prepareGenericRepo) {
RepositorySettings settings = getRepositorySettings(RepositoryTypeImpl.LOCAL)

Expand Down Expand Up @@ -174,12 +175,12 @@ abstract class BaseRepositoryTests extends ArtifactoryTestsBase {

@AfterMethod
protected void tearDown() {
// Invoking sequence is important!
deleteRepoIfExists(genericRepo?.getKey())
deleteRepoIfExists(localRepo?.getKey())
deleteRepoIfExists(remoteRepo?.getKey())
deleteRepoIfExists(federatedRepo?.getKey())
deleteRepoIfExists(virtualRepo?.getKey())
// Invoking sequence is important! Delete in reverse dependency order
deleteRepoWithRetry(virtualRepo?.getKey()) // Delete virtual repo first (depends on generic)
deleteRepoWithRetry(federatedRepo?.getKey())
deleteRepoWithRetry(remoteRepo?.getKey())
deleteRepoWithRetry(localRepo?.getKey())
deleteRepoWithRetry(genericRepo?.getKey()) // Delete generic repo last (after dependents)
repoUniqueId++
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TerraformPackageTypeRepositoryTests extends BaseRepositoryTests {

TerraformPackageTypeRepositoryTests() {
remoteRepoUrl = "https://github.com"
storeArtifactsLocallyInRemoteRepo = true
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,32 @@ protected String textFrom(InputStream is) throws IOException {
}
}

protected void deleteRepoWithRetry(String repoKey) {
Comment thread
nitinp19 marked this conversation as resolved.
for (int attempt = 1; attempt <= 3; attempt++) {
try {
deleteRepoIfExists(repoKey);
return;
} catch (RuntimeException e) {
Throwable cause = e.getCause();
if (cause instanceof HttpResponseException &&
((HttpResponseException) cause).getStatusCode() == 500 &&
cause.getMessage() != null && cause.getMessage().contains("Lock on LockEntryId")) {

if (attempt < 3) {
try {
Thread.sleep(5000);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();
return;
}
}
} else {
return; // Non-lock error, don't retry
}
}
}
}

protected String deleteRepoIfExists(String repoName) {
if (isEmpty(repoName)) {
return null;
Expand All @@ -220,7 +246,8 @@ protected String deleteRepoIfExists(String repoName) {
//if repo wasn't found - that's ok.
return e.getMessage();
} else {
throw e;
// Wrap checked exception in a RuntimeException to avoid signature changes
throw new RuntimeException(e);
}
}
}
Expand Down
Loading