Skip to content

Commit

Permalink
[Th2-5226] added integration test (#123)
Browse files Browse the repository at this point in the history
* Implemented RabbitMQGcTask.deleteRedundantExchanges
* Updated libraries

Co-authored-by: Oleg Smirnov <[email protected]>
  • Loading branch information
Nikita-Smirnov-Exactpro and OptimumCode authored Sep 30, 2024
1 parent 0daac82 commit 1a2b25e
Show file tree
Hide file tree
Showing 73 changed files with 4,162 additions and 1,078 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
name: Build and publish Docker images to github registry
name: Build and publish dev release Docker image to Github Container Registry ghcr.io

on:
push:
branches:
- master
- version-*
paths:
- gradle.properties
on: workflow_dispatch

jobs:
build:
uses: th2-net/.github/.github/workflows/compound-java.yml@main
with:
build-target: 'Docker'
runsOn: ubuntu-latest
gradleVersion: '7'
devRelease: true
createTag: true
docker-username: ${{ github.actor }}
# FIXME: strict scanner was disabled for 4.6.4 hotfix publishing and must be removed after that
strict-scanner: false
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Build and publish release Docker image to Github Container Registry ghcr.io

on: workflow_dispatch

jobs:
build:
uses: th2-net/.github/.github/workflows/compound-java.yml@main
with:
build-target: 'Docker'
devRelease: false
createTag: true
docker-username: ${{ github.actor }}
secrets:
docker-password: ${{ secrets.GITHUB_TOKEN }}
nvd-api-key: ${{ secrets.NVD_APIKEY }}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: Dev build and publish Docker images to github registry
name: Build and publish Docker image to Github Container Registry ghcr.io

on:
push:
branches-ignore:
- master
- version-*
- dev-version-*
- dependabot*
- dependabot**
paths-ignore:
- README.md

Expand All @@ -15,8 +14,6 @@ jobs:
uses: th2-net/.github/.github/workflows/compound-java-dev.yml@main
with:
build-target: 'Docker'
runsOn: ubuntu-latest
gradleVersion: '7'
docker-username: ${{ github.actor }}
# FIXME: strict scanner was disabled for 4.6.4 hotfix publishing and must be removed after that
strict-scanner: false
Expand Down
30 changes: 15 additions & 15 deletions .github/workflows/ci-unwelcome-words.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ on:

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.sha }}
- name: Checkout tool
uses: actions/checkout@v2
with:
repository: exactpro-th2/ci-github-action
ref: master
token: ${{ secrets.PAT_CI_ACTION }}
path: ci-github-action
- name: Run CI action
uses: ./ci-github-action
with:
ref: ${{ github.sha }}
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
- name: Checkout tool
uses: actions/checkout@v4
with:
repository: exactpro-th2/ci-github-action
ref: master
token: ${{ secrets.PAT_CI_ACTION }}
path: ci-github-action
- name: Run CI action
uses: ./ci-github-action
with:
ref: ${{ github.sha }}
26 changes: 26 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Run integration tests for infra-operator"

on:
push:
branches:
- '*'

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 'zulu' '11'
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Setup Gradle
uses: gradle/gradle-build-action@v2
- name: Build with Gradle
run: ./gradlew --info clean integrationTest
- uses: actions/upload-artifact@v3
if: failure()
with:
name: integration-test-results
path: build/reports/tests/integrationTest/
16 changes: 6 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
FROM gradle:7.6-jdk11 AS build
FROM gradle:8.7-jdk11 AS build
ARG app_version=0.0.0
COPY ./ .
RUN gradle build -Prelease_version=${app_version}
RUN gradle --no-daemon clean build dockerPrepare -Prelease_version=${release_version}

RUN mkdir /home/app
RUN cp ./build/libs/*.jar /home/app/application.jar

FROM eclipse-temurin:11-alpine
COPY --from=build /home/app /home/app

WORKDIR /home/app/
ENTRYPOINT ["java", "-Dlog4j2.configurationFile=file:/var/th2/config/log4j2.properties", "-jar", "/home/app/application.jar"]
FROM adoptopenjdk/openjdk11:alpine
WORKDIR /home
COPY --from=build /home/gradle/build/docker .
ENTRYPOINT ["/home/service/bin/service", "/var/th2/config/log4j2.properties"]
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ rabbitMQManagement:
persistence: true
# determines if the RabbitMQ resources are persistent or not

cleanUpOnStart: false
# if option is true, operator removes all queues and exchanges from RabbitMQ on start

schemaPermissions:
# this section describes what permissions schema RabbitMQ user will have on its own resources
# see RabbitMQ documentation to find out how permissions are described
Expand Down Expand Up @@ -147,6 +144,20 @@ openshift:

## Release notes

### 4.7.0
+ Improved clean rubbish from RabbitMQ on start to delete only redundant resources.
The `cleanUpOnStart` option has been removed, the clean rubbish function is enabled.
+ Migrated to th2 plugin `0.1.2`

+ Updated:
+ bom: `4.6.1`
+ kubernetes-client: `6.13.1`
+ force okhttp: `4.12.0`
+ force logging-interceptor: `4.12.0`
+ http-client: `5.2.0`
+ java-uuid-generator: `5.1.0`
+ kotlin-logging: `5.1.4`

### 4.6.5

+ Fix issue when changing `desabled` flag to `true` does not remove the resource from k8s
Expand Down
166 changes: 71 additions & 95 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,141 +1,117 @@
/*
* Copyright 2020-2021 Exactpro (Exactpro Systems Limited)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

plugins {
id 'java'
id 'application'
id 'checkstyle'
id "io.gitlab.arturbosch.detekt" version "${detekt_version}"
id "org.jetbrains.kotlin.jvm" version "${kotlin_version}"
id "org.owasp.dependencycheck" version "${owaspVersion}"
alias(libs.plugins.detekt)
alias(libs.plugins.kotlin)
alias(libs.plugins.th2.component)
alias(libs.plugins.download)
}

group = 'com.exactpro.th2'
version = release_version

kotlin {
jvmToolchain(11)
}

repositories {
mavenCentral()
}

checkstyle {
toolVersion = "10.12.0"
toolVersion = "10.12.4"
}

detekt {
buildUponDefaultConfig = true
autoCorrect = true
config = files("$rootDir/config/detekt/detekt.yml")
}

ext {
uuid_generator_version = '4.2.0'
okhttp_version = '4.10.0'
fabric8_version = '6.6.2'
rabbit_amqp_version = '5.16.0'
rabbit_http_version = '5.0.0'
kotlin_logging_version = '3.0.0' // 3.0.0 the las version supported 1.6.21
jetbrains_annotations_version = '24.0.1'
mockito_version = '3.11.2'
jupiter_version = '5.9.2'
guava_version = '32.0.1-jre'
snakeyaml_version = '2.0'
}

configurations.configureEach() {
resolutionStrategy {
force "com.google.guava:guava:$guava_version"
force "org.yaml:snakeyaml:$snakeyaml_version"
}
config.setFrom("$rootDir/config/detekt/detekt.yml")
}

dependencies {
api platform('com.exactpro.th2:bom:4.3.0')
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml"
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-kotlin'
implementation "com.fasterxml.uuid:java-uuid-generator:${uuid_generator_version}"

implementation "com.squareup.okhttp3:okhttp:${okhttp_version}"
implementation "com.fasterxml.jackson.module:jackson-module-kotlin"
implementation libs.java.uuid.generator

implementation "org.apache.commons:commons-text"

implementation "io.fabric8:kubernetes-client:${fabric8_version}"
implementation "com.rabbitmq:amqp-client:${rabbit_amqp_version}"
implementation "com.rabbitmq:http-client:${rabbit_http_version}"
implementation libs.kubernetes.client
implementation(libs.okhttp) {
because "okhttp:3.12.12 has vulnerabilities"
}
implementation(libs.logging.interceptor) {
because "logging-interceptor:3.12.12 has vulnerabilities"
}

implementation "org.slf4j:slf4j-api"
implementation "org.apache.logging.log4j:log4j-slf4j2-impl"
implementation "org.apache.logging.log4j:log4j-core"
implementation group: 'io.github.microutils', name: 'kotlin-logging', version: kotlin_logging_version
implementation "com.rabbitmq:amqp-client"
implementation libs.http.client

implementation "org.jetbrains:annotations:${jetbrains_annotations_version}"
implementation 'org.apache.logging.log4j:log4j-slf4j2-impl'
implementation 'org.apache.logging.log4j:log4j-core'
implementation libs.kotlin.logging
implementation "org.jetbrains:annotations"

implementation "io.prometheus:simpleclient"
implementation "io.prometheus:simpleclient_httpserver"
implementation "io.prometheus:simpleclient_hotspot"

testImplementation group: 'org.mockito', name: 'mockito-core', version: "${mockito_version}"
implementation "com.google.guava:guava"

testImplementation "org.junit.jupiter:junit-jupiter-api:${jupiter_version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jupiter_version}"
testImplementation(platform(libs.testcontainers.bom))
testImplementation 'org.testcontainers:rabbitmq'
testImplementation 'org.testcontainers:k3s'

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${detekt_version}")
}

dependencyCheck {
formats=['SARIF', 'JSON', 'HTML']
failBuildOnCVSS=5
testImplementation libs.mockito.core
testImplementation libs.mockito.kotlin
testImplementation libs.junit.jupiter
testImplementation libs.junit.jupiter.params
testImplementation "org.jetbrains.kotlin:kotlin-test-junit5"
testImplementation libs.bcpkix.jdk18on
testImplementation libs.awaitility
testImplementation libs.strikt.core

analyzers {
assemblyEnabled = false
nugetconfEnabled = false
nodeEnabled = false
}
detektPlugins libs.detekt.formatting
}

jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
manifest {
attributes(
'Created-By': "${System.getProperty('java.version')} (${System.getProperty('java.vendor')})",
'Specification-Title': '',
'Specification-Vendor': 'Exactpro Systems LLC',
'Main-Class': 'com.exactpro.th2.infraoperator.Th2CrdController',
'Implementation-Title': project.archivesBaseName,
'Implementation-Vendor': 'Exactpro Systems LLC',
'Implementation-Vendor-Id': 'com.exactpro',
'Implementation-Version': project.version
)
}

from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
wrapper {
version '8.7'
distributionType Wrapper.DistributionType.BIN
}

test {
useJUnitPlatform()
tasks.register("downloadCRDs", Download) {
group = "verification"
src([
'https://raw.githubusercontent.com/th2-net/th2-infra/master/chart/crds/th2-box-crd.yaml',
'https://raw.githubusercontent.com/th2-net/th2-infra/master/chart/crds/th2-core-box-crd.yaml',
'https://raw.githubusercontent.com/th2-net/th2-infra/master/chart/crds/th2-dictionary-crd.yaml',
'https://raw.githubusercontent.com/th2-net/th2-infra/master/chart/crds/th2-estore-crd.yaml',
'https://raw.githubusercontent.com/th2-net/th2-infra/master/chart/crds/th2-job-crd.yaml',
'https://raw.githubusercontent.com/th2-net/th2-infra/master/chart/crds/th2-mstore-crd.yaml',
])
dest layout.buildDirectory.dir('resources/test/crds').get()
}

compileKotlin {
kotlinOptions {
jvmTarget = "11"
checkstyleTest.dependsOn("downloadCRDs")

test {
dependsOn("downloadCRDs")
useJUnitPlatform {
excludeTags("integration-test")
}
}

compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
tasks.register("integrationTest", Test) {
group = "verification"
dependsOn("downloadCRDs")
useJUnitPlatform {
includeTags("integration-test")
}
testLogging {
showStandardStreams = true
}
}

dependencyCheck {
skipConfigurations += "checkstyle"
}
Loading

0 comments on commit 1a2b25e

Please sign in to comment.