Skip to content

Commit

Permalink
DOCKER-431 add backup restore status validation for readiness
Browse files Browse the repository at this point in the history
* DOCKER-431 remove solr4 support and update gradle

* DOCKER-431 add backup restore status validation for readiness
  • Loading branch information
hechmi-dammak-xenit authored Mar 9, 2023
1 parent cb61d2e commit c1c3e91
Show file tree
Hide file tree
Showing 16 changed files with 281 additions and 2,201 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: build
on:
push:
workflow_dispatch:
env:
ORG_GRADLE_PROJECT_alfresco_nexus_username: ${{ secrets.ALFRESCO_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_alfresco_nexus_password: ${{ secrets.ALFRESCO_NEXUS_PASSWORD }}
jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Login to Docker
run: |
echo "${{ secrets.CLOUDSMITH_APIKEY }}" | docker login private.docker.xenit.eu --username "${{ secrets.CLOUDSMITH_USER }}" --password-stdin
- name: Test
uses: gradle/gradle-build-action@v2
with:
cache-read-only: false
arguments: |
integrationTest
- name: Upload Test Artifact
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-result
path: /home/runner/work/**/build/reports
retention-days: 2
publish:
needs: [ integration-tests ]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v1
with:
java-version: 11
- name: Add TAG_VERSION env property
run: echo "TAG_VERSION=`echo ${GITHUB_REF#refs/tags/}`" >> $GITHUB_ENV
- name: Publish
uses: gradle/gradle-build-action@v2
env:
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_GPG_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }}
ORG_GRADLE_PROJECT_sonatype_username: ${{ secrets.SONATYPE_S01_USERNAME }}
ORG_GRADLE_PROJECT_sonatype_password: ${{ secrets.SONATYPE_S01_PASSWORD }}
with:
cache-read-only: false
arguments: |
publish -PsigningKeyId=CDE3528F -i
39 changes: 0 additions & 39 deletions Jenkinsfile

This file was deleted.

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Readiness endpoint to be used as load balancer check.

Solr is considered ready when it is "almost" ready with tracking alfresco.
This is computed subjectivelly using the lag reported by the SUMMARY screen: solr is ready when the lag is smaller than MAX_LAG.
also it is following the restore status provided by the replication handler

The script is available at:

Expand All @@ -19,6 +20,8 @@ Status code is to be used for the health check: 200 if ready or 503 if not yet r

The output of the script offers additional information if being ready as well as information about current tracker status (when parameter info is appended to the query).

the MAX_LAG can be set via environment variable `READINESS_MAX_LAG` it is set to default to 1800000 in milliseconds (30 minutes).

## How to run integration tests

./gradlew integrationTest
Expand Down
23 changes: 13 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
plugins {
id 'eu.xenit.docker' version '5.1.1' apply false
id 'eu.xenit.docker-compose' version '5.1.1' apply false
id 'de.marcphilipp.nexus-publish' version '0.4.0' apply false
id 'eu.xenit.docker' version '5.4.0' apply false
id 'eu.xenit.docker-compose' version '5.4.0' apply false
}
def copyPropertyValueIfExists(sourcePropertyName, targetPropertyName) {
if (project.hasProperty(sourcePropertyName)) {
project.ext[targetPropertyName] = project.property(sourcePropertyName)
}
}

subprojects {
version = '0.0.3'
def baseVersion = System.getenv("TAG_VERSION") ?: 'v0.0.4'
version = baseVersion[1..baseVersion.length() - 1]


copyPropertyValueIfExists('alfresco_nexus_username', 'org.alfresco.maven.nexus.username')
copyPropertyValueIfExists('alfresco_nexus_password', 'org.alfresco.maven.nexus.password')


boolean isRelease = System.env.BRANCH_NAME?.startsWith("release")
if (!isRelease)
version += "-SNAPSHOT"

repositories {
mavenCentral()
Expand All @@ -25,6 +30,4 @@ subprojects {
}
}
}

apply from: "${rootProject.projectDir}/publish.gradle"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
50 changes: 19 additions & 31 deletions integration-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ plugins {
id 'java'
id 'idea'
}

dependencies {
testImplementation group: 'io.rest-assured', name: 'rest-assured', version: '3.0.1'
testImplementation group: 'io.rest-assured', name: 'json-path', version: '3.0.1'
testImplementation group: 'io.rest-assured', name: 'rest-assured-common', version: '3.0.1'
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.4.2"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.4.2"
testRuntimeOnly group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.2'
}
test {
enabled = false
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eu.xenit.docker'
Expand All @@ -11,43 +25,20 @@ subprojects {

description = "Solr ${flavor} with Actuators"

sourceSets {
integrationTest {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
srcDirs = ["${project.parent.projectDir}/src/test/java"]
}
}
}

configurations {
actuatorsJar
integrationTestCompile.extendsFrom testCompile
integrationTestRuntime.extendsFrom testRuntime
}


dependencies {
integrationTestCompile group: 'io.rest-assured', name: 'rest-assured', version: '3.0.1'
integrationTestCompile group: 'io.rest-assured', name: 'json-path', version: '3.0.1'
integrationTestCompile group: 'io.rest-assured', name: 'rest-assured-common', version: '3.0.1'
integrationTestCompile group: 'junit', name: 'junit', version: '4.11'
integrationTestRuntime group: 'org.glassfish.jaxb', name: 'jaxb-runtime', version: '2.3.2'


actuatorsJar project(path: ":solr-actuators", configuration: "sharedJar")
}

task integrationTest(type: Test, group: "verification") {
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
useJUnitPlatform()
testClassesDirs = project.parent.sourceSets.test.output.classesDirs
classpath = project.parent.sourceSets.test.runtimeClasspath
outputs.upToDateWhen { false }

doFirst {
dockerCompose.exposeAsSystemProperties(integrationTest)
systemProperty("flavor", flavor)
}
}


Expand All @@ -56,12 +47,9 @@ subprojects {

dependsOn(configurations.actuatorsJar)

if(flavor == "solr6") {
if (flavor == "solr6") {
smartCopy "${project.parent.projectDir}/src/test/resources/solr6/solrconfig_insight.xml", "/opt/alfresco-search-services/solrhome/templates/rerank/conf/solrconfig_insight.xml"
smartCopy configurations.actuatorsJar.singleFile, "/opt/alfresco-search-services/solrhome/lib/"
} else {
smartCopy "${project.parent.projectDir}/src/test/resources/solr4/solrconfig.xml", "/opt/alfresco/solr4/workspace-SpacesStore/conf/solrconfig.xml"
smartCopy configurations.actuatorsJar.singleFile, "/opt/alfresco/solr4/lib/"
}
}

Expand Down
7 changes: 0 additions & 7 deletions integration-tests/solr4/overload.gradle

This file was deleted.

6 changes: 3 additions & 3 deletions integration-tests/solr6/overload.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
solrVersion = '6.6.5'
assVersion = '2.0.0'
solrBaseImage = 'hub.xenit.eu/public/alfresco-solr6:2.0.1'
alfrescoimage ='docker.io/xenit/alfresco-repository-community:6.1.2-ga'
assVersion = '2.0.6'
solrBaseImage = 'private.docker.xenit.eu/alfresco-enterprise/alfresco-solr6:2.0.6'
alfrescoimage ='docker.io/xenit/alfresco-repository-community:7.3.0'
flavor = 'solr6'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,33 @@

import io.restassured.builder.RequestSpecBuilder;
import io.restassured.specification.RequestSpecification;
import org.junit.BeforeClass;
import org.junit.Test;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import static io.restassured.RestAssured.given;
import static java.lang.Thread.sleep;
import static org.hamcrest.core.StringContains.containsString;

public class SolrSmokeTests {
static RequestSpecification spec;
private static final Log log = LogFactory.getLog(SolrSmokeTests.class);

@BeforeClass
@BeforeAll
public static void setup() {
String flavor = System.getProperty("flavor");
String basePathSolr = "solr/alfresco/xenit/actuators/readiness";
if("solr4".equals(flavor))
basePathSolr = "solr4/alfresco/xenit/actuators/readiness";

String solrHost = System.getProperty("solr.host");

int solrPort = 0;
try {
solrPort = Integer.parseInt(System.getProperty("solr.tcp.8080"));
} catch(NumberFormatException e) {
} catch (NumberFormatException e) {
System.out.println("Solr port 8080 is not exposed, probably ssl is enabled");
}

System.out.println("Looking at " + solrHost + ":" + solrPort + "/" + basePathSolr + " where flavor=" + flavor);
System.out.println("Looking at " + solrHost + ":" + solrPort + "/" + basePathSolr + " where flavor=" + flavor);
String baseURISolr = "http://" + solrHost;

spec = new RequestSpecBuilder()
Expand All @@ -40,24 +40,28 @@ public static void setup() {


@Test
public void testActuatorsEndpoint() {
// wait until solr tracks
long sleepTime = 30000;
try {
sleep(sleepTime);
} catch (InterruptedException e) {
e.printStackTrace();
void testActuatorsEndpoint() {
System.out.println("Ready test triggered, will wait maximum 30 seconds");
String status = "";
long timeout = 30000;
long elapsed = 0;
while ("UP".equals(status) && elapsed < timeout) {
status = given()
.spec(spec)
.when()
.get()
.then()
.statusCode(200)
.extract()
.path("ready");
System.out.println("elapsed =" + elapsed);
try {
sleep(1000);
elapsed += 1000;
} catch (InterruptedException e) {
log.error(e);
}
}


given()
.spec(spec)
.when()
.get()
.then()
.statusCode(200)
.body(containsString("UP"))
.toString();

}
}
13 changes: 10 additions & 3 deletions integration-tests/src/test/resources/compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ services:
- 8080
environment:
- INDEX
- SOLR_SSL=none
- SOLR_SSL=secret
- GLOBAL_solr.sharedSecret=mysolrsecret
- GLOBAL_local.transform.service.enabled=false
- JAVA_XMX=2048M

Expand All @@ -25,7 +26,13 @@ services:
restart: unless-stopped
hostname: solr
ports:
- 8080
- 8080:8080
- 8000:8000
- 5000:5000
environment:
- ALFRESCO_SSL=none
- JAVA_XMX=1024M
- DEBUG=true
- JMX_ENABLED=true
- READINESS_MAX_LAG=1300000
- JAVA_XMX=1024M
- JAVA_OPTS_SSL=-Dalfresco.secureComms=secret -Dalfresco.secureComms.secret=mysolrsecret
Loading

0 comments on commit c1c3e91

Please sign in to comment.