Skip to content

Commit

Permalink
XENOPS-1128 add check for content store fetching file to health check (
Browse files Browse the repository at this point in the history
…#22)

* XENOPS-1128 add check for content stora fetching file to health check

* XENOPS-1128 add check for content stora fetching file to health check

* XENOPS-1128 add check for content stora fetching file to health check

* XENOPS-1128 add more testing for details

* XENOPS-1128 change the way to access the noderef for content store to a constant
  • Loading branch information
hechmi-dammak-xenit authored Dec 21, 2023
1 parent d04057e commit 899c2e1
Show file tree
Hide file tree
Showing 52 changed files with 583 additions and 463 deletions.
61 changes: 31 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
workflow_dispatch:
env:
GRADLE_OPTS: "-Dorg.gradle.project.org.alfresco.artifacts.username=${{ secrets.ALFRESCO_NEXUS_USERNAME }} -Dorg.gradle.project.org.alfresco.artifacts.password=${{ secrets.ALFRESCO_NEXUS_PASSWORD }}"
GRADLE_OPTS: >-
-Dorg.gradle.project.org.alfresco.maven.nexus.username=${{ secrets.ALFRESCO_NEXUS_USERNAME }}
-Dorg.gradle.project.org.alfresco.maven.nexus.password=${{ secrets.ALFRESCO_NEXUS_PASSWORD }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
flavour: [ "community", "enterprise" ]
version: [ "61", "62", "70", "71", "72", "73" ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Set up JDK 11
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3
with:
fetch-depth: 0
- uses: actions/setup-java@v1
distribution: 'temurin'
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: Integration Test
uses: gradle/gradle-build-action@v2
with:
java-version: 11
- name: Login to CloudSmith docker registry
env:
DOCKER_USER: ${{ secrets.CLOUDSMITH_USER }}
DOCKER_PASSWORD: ${{ secrets.CLOUDSMITH_APIKEY }}
run: echo "$DOCKER_PASSWORD" | docker login docker.xenit.eu --username "$DOCKER_USER" --password-stdin
- name: Integration test
run: ./gradlew :integration-tests:alfresco-${{ matrix.flavour }}-${{ matrix.version }}:integrationTest --parallel
- name: 'Upload Artifact'
cache-read-only: false
arguments: :integration-tests:alfresco-${{ matrix.flavour }}-${{ matrix.version }}:integrationTest --parallel
- name: 'Upload Test Reports'
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: test-result-${{ matrix.flavour }}-${{ matrix.version }}
path: /home/runner/work/**/build/reports
retention-days: 2
path: /home/runner/**/build/reports
retention-days: 14
publish:
needs: [ test ]
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/tags/') }}
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v1
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Set up JDK 11
uses: actions/setup-java@cd89f46ac9d01407894225f350157564c9c7cee2 # v3
with:
java-version: 11
distribution: 'temurin'
java-version: '11'
- name: Add TAG_VERSION env property
run: echo "TAG_VERSION=`echo ${GITHUB_REF#refs/tags/}`" >> $GITHUB_ENV
- name: Publish
env:
ORG_GRADLE_PROJECT_publish_username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_publish_password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
SIGNING_PRIVATE_KEY: ${{ secrets.MAVEN_CENTRAL_GPG_KEY }}
SIGNING_PASSWORD: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }}
ORG_GRADLE_PROJECT_sonatype_username: ${{ secrets.SONATYPE_S01_USERNAME }}
ORG_GRADLE_PROJECT_sonatype_password: ${{ secrets.SONATYPE_S01_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.MAVEN_CENTRAL_GPG_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_CENTRAL_GPG_PASSWORD }}
run: ./gradlew publish --info


47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,59 @@ Health endpoint, unauthenticated, to be used as docker and load balancer health

The webscript is available at:

```
alfresco/s/xenit/actuators/health
alfresco/s/xenit/actuators/health/details
```

with both having request parameter disabled with values :

* `SystemInfoService`
* `AlfrescoInfoService`
* `ContentInfoService`
* `LicenseInfoService`
* `StatusInfoService`

example:

* `alfresco/s/xenit/actuators/health?disabled=SystemInfoService,LicenseInfoService`
* `alfresco/s/xenit/actuators/health/details?disabled=SystemInfoService`

## Usage

Status code is to be used for the health check.

The output of the check is:
The output of the health check is:

```
{"status":"UP"}
```

or

```
{"status":"DOWN"}
{"status":"DOWN" , "message":"error message"}
```

Currently the check looks at:

* system
* os
* java
* cpu
* os
* java
* cpu
* alfresco
* id
* version
* edition
* license
* warManifest
* modules
* status
* id
* version
* edition
* license
* warManifest
* modules
* status
* content store

# Development

Expand All @@ -46,5 +67,7 @@ See [TODO.md](TODO.md)
## How to run integration tests

```
./gradlew integrationTest
```
54 changes: 6 additions & 48 deletions alfresco-actuators/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ plugins {
id 'java'
id 'maven-publish'
id 'eu.xenit.amp'
id 'org.hidetake.swagger.generator' version '2.19.2'
id "com.github.johnrengelman.shadow" version "7.1.2"
}

description = "Xenit webscripts to retrieve health of the application"

// compile against alfresco 5.2
ext {
alfrescoVersion = '5.2.7'
alfrescoVersion = '6.1.1.11'
servletApiVersion = '2.5'
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -25,57 +21,19 @@ java {
}

dependencies {
alfrescoProvided("org.alfresco:alfresco-repository:$alfrescoVersion")
alfrescoProvided("org.alfresco:alfresco-enterprise-repository:$alfrescoVersion")
alfrescoProvided("javax.servlet:servlet-api:$servletApiVersion")
alfrescoProvided platform("org.alfresco:acs-packaging:${alfrescoVersion}")
alfrescoProvided("org.alfresco:alfresco-repository")
alfrescoProvided("org.alfresco:alfresco-enterprise-repository")

// Add dependency for Swagger Codegen CLI
swaggerCodegen 'io.swagger:swagger-codegen-cli:2.2.3'
alfrescoProvided("javax.servlet:servlet-api:$servletApiVersion")

compileOnly 'io.swagger:swagger-annotations:1.5.6'
compileOnly 'javax.validation:validation-api:1.1.0.Final'
compileOnly 'com.fasterxml.jackson.core:jackson-annotations:2.9.0'
}

swaggerSources {

model {
inputFile = file("src/main/resources/swagger.yaml")
code {
language = 'spring'
additionalProperties = [
"modelPackage" : "eu.xenit.actuators.model.gen",
"serializableModel": "true"
]
// Only generate model:
components = ['models']
}
}

}

processResources {
filesMatching("**/module.properties") {
expand project.properties
}
}

sourceSets {
main {
java {
srcDirs = ["src/main/java", "$generateSwaggerCodeModel.outputDir/src/main/java"]
}
resources {
srcDirs = ['src/main/resources']
}
amp {
module("src/main/resources/alfresco/module/alfresco-actuators/module.properties")
}
}
}

apply from: "${rootProject.projectDir}/swaggerCodeGen.gradle"

compileJava.dependsOn generateSwaggerCodeModel

publishing {
publications {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<bean id="eu.xenit.actuators.bootstrap" class="org.alfresco.repo.admin.patch.impl.GenericBootstrapPatch"
parent="basePatch">
<property name="id">
<value>eu.xenit.alfresco-actuators.alfresco-actuators.filesLoader</value>
</property>
<property name="description" value="File used to verify the health of content store of alfresco"/>
<property name="fixesFromSchema">
<value>0</value>
</property>
<property name="fixesToSchema">
<value>${version.schema}</value>
</property>
<property name="targetSchema">
<value>99999</value>
</property>
<property name="importerBootstrap" ref="spacesBootstrap"/>
<property name="bootstrapView">
<props>
<prop key="uuidBinding">UPDATE_EXISTING</prop>
<prop key="path">/${spaces.company_home.childname}/${spaces.dictionary.childname}</prop>
<prop key="location">alfresco/module/alfresco-actuators/bootstrap/AlfrescoActuatorsACP.acp</prop>
</props>
</property>
</bean>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
<bean id="AlfrescoInfoService"
class="eu.xenit.actuators.services.AlfrescoInfoService">
</bean>

<bean id="ContentInfoService"
class="eu.xenit.actuators.services.ContentInfoService">
</bean>
<bean id="LicenseInfoService"
class="eu.xenit.actuators.services.LicenseInfoService">
class="eu.xenit.actuators.services.LicenseInfoService">
</bean>

<bean id="StatusInfoService"
class="eu.xenit.actuators.services.StatusInfoService">
class="eu.xenit.actuators.services.StatusInfoService">
</bean>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<bean id="webscript.eu.xenit.actuators.webscripts.health.get"
class="eu.xenit.actuators.webscripts.classical.HealthWebScript"
parent="webscript" />
parent="webscript"/>

<bean id="webscript.eu.xenit.actuators.webscripts.healthdetails.get"
class="eu.xenit.actuators.webscripts.classical.HealthdetailsWebScript"
parent="webscript" />
class="eu.xenit.actuators.webscripts.classical.HealthDetailsWebScript"
parent="webscript"/>
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
<import resource="classpath:alfresco/module/alfresco-actuators/context/*-context.xml"/>
<import resource="classpath:alfresco/module/alfresco-actuators/bootstrap/bootstrap.xml"/>
</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
${json}
25 changes: 0 additions & 25 deletions alfresco-actuators/src/main/java/eu/xenit/actuators/Health.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
package eu.xenit.actuators;

public interface HealthIndicator {
Health isHealthy();
import eu.xenit.actuators.model.gen.HealthInfo;
import eu.xenit.actuators.model.gen.StatusEnum;


public abstract class HealthIndicator {
public HealthInfo isHealthy() {
HealthInfo health = new HealthInfo();
health.setName(this.getClass().getSimpleName());
try {
health.setDetails(getHealthDetails());
health.setStatus(StatusEnum.UP);
} catch (Exception exception) {
health.setStatus(StatusEnum.DOWN);
health.setError(exception.getMessage());
}
return health;
}

protected abstract Object getHealthDetails() throws Exception;
}
Loading

0 comments on commit 899c2e1

Please sign in to comment.