Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Th2-5226] added integration test #123

Merged
merged 45 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
03123a6
[TH2-5226] moved kotlin files to the src/kotlin dir
Nikita-Smirnov-Exactpro Aug 7, 2024
a19d4b5
[TH2-5226] Added RabbitMQGcTask
Nikita-Smirnov-Exactpro Aug 8, 2024
04e15b9
[TH2-5226] Updated libraries
Nikita-Smirnov-Exactpro Aug 8, 2024
a565d2d
[TH2-5226] Implemented RabbitMQGcTask.deleteRedundantExchanges
Nikita-Smirnov-Exactpro Aug 8, 2024
17879e0
[TH2-5226] added configure logging method
Nikita-Smirnov-Exactpro Aug 8, 2024
1add5b3
[TH2-5226] Refactored
Nikita-Smirnov-Exactpro Aug 8, 2024
98b1655
[TH2-5226] added wrapper closure into build script
Nikita-Smirnov-Exactpro Aug 9, 2024
d34bbb3
[TH2-5226] moved kotlin files to the src/kotlin dir
Nikita-Smirnov-Exactpro Aug 7, 2024
9391349
[TH2-5226] Added `rabbitMQManagement.cleanUpOnStart` option
Nikita-Smirnov-Exactpro Aug 13, 2024
bd6c67b
[TH2-5226] Corrected GitHub workflow
Nikita-Smirnov-Exactpro Aug 13, 2024
3e4130c
Merge remote-tracking branch 'origin/TH2-5226-hotfix-2' into TH2-5226
Nikita-Smirnov-Exactpro Aug 14, 2024
0b04c17
[TH2-5226] registered exception handler for informers
Nikita-Smirnov-Exactpro Aug 15, 2024
c4041b9
[TH2-5226] added deleteRabbitMQRubbish method
Nikita-Smirnov-Exactpro Aug 16, 2024
a6d9014
[TH2-5226] set true for clearOnStart by default
Nikita-Smirnov-Exactpro Aug 16, 2024
ada9bf0
[TH2-5226] refactored
Nikita-Smirnov-Exactpro Aug 16, 2024
34816d5
Merge remote-tracking branch 'origin/master' into TH2-5226
Nikita-Smirnov-Exactpro Aug 16, 2024
1bc6904
[TH2-5226] corrected after review
Nikita-Smirnov-Exactpro Aug 19, 2024
2e47d42
[TH2-5226] refactored after review
Nikita-Smirnov-Exactpro Aug 19, 2024
123585d
Update src/main/kotlin/com/exactpro/th2/infraoperator/util/RabbitMQUt…
Nikita-Smirnov-Exactpro Aug 19, 2024
b359882
[TH2-5226] Updated kotlin logging to 5.1.4
Nikita-Smirnov-Exactpro Aug 23, 2024
879d17b
[TH2-5226] Added IntegrationTest
Nikita-Smirnov-Exactpro Aug 23, 2024
152af53
[TH2-5226] Added topic exchange test at the start of integration test
Nikita-Smirnov-Exactpro Aug 23, 2024
0fec9a0
[TH2-5226] Added create namespace test
Nikita-Smirnov-Exactpro Aug 23, 2024
a57b19a
[TH2-5226] Delete namespace after test
Nikita-Smirnov-Exactpro Aug 26, 2024
c7cf794
[TH2-5226] Added namespace configmaps into integration test
Nikita-Smirnov-Exactpro Aug 26, 2024
c3bb543
[TH2-5226] Refactored
Nikita-Smirnov-Exactpro Aug 26, 2024
5dff0ee
[TH2-5226] Prepared base IntegrationTest
Nikita-Smirnov-Exactpro Sep 10, 2024
8119b34
[TH2-5226] Updated test
Nikita-Smirnov-Exactpro Sep 12, 2024
9986b5e
[TH2-5226] added integration-tests.yml
Nikita-Smirnov-Exactpro Sep 12, 2024
3410e21
[TH2-5226] added dictionary test
Nikita-Smirnov-Exactpro Sep 12, 2024
a8d0ef3
[TH2-5226] added 'disable component (min configuration)' test
Nikita-Smirnov-Exactpro Sep 13, 2024
33a9a29
Merge remote-tracking branch 'origin/master' into TH2-5226-integratio…
Nikita-Smirnov-Exactpro Sep 13, 2024
39704a4
[TH2-5226] added 'enable component (min configuration)' test
Nikita-Smirnov-Exactpro Sep 13, 2024
ff3beb6
[TH2-5226] refactored
Nikita-Smirnov-Exactpro Sep 13, 2024
c1c9dca
[TH2-5226] corrected after review
Nikita-Smirnov-Exactpro Sep 13, 2024
bb4731c
[TH2-5226] refactored
Nikita-Smirnov-Exactpro Sep 13, 2024
87c6370
[TH2-5226] corrected after review
Nikita-Smirnov-Exactpro Sep 16, 2024
0a45dff
[TH2-5226] corrected after review
Nikita-Smirnov-Exactpro Sep 16, 2024
f2f35d6
[TH2-5226] corrected after review
Nikita-Smirnov-Exactpro Sep 16, 2024
5dc5513
[TH2-5226] added mq link test
Nikita-Smirnov-Exactpro Sep 16, 2024
0187cd0
[TH2-5226] added grpc link test
Nikita-Smirnov-Exactpro Sep 16, 2024
20ef110
[TH2-5226] corrected after review
Nikita-Smirnov-Exactpro Sep 16, 2024
1555413
[TH2-5226] added DeleteRubbishOnStartTest
Nikita-Smirnov-Exactpro Sep 16, 2024
b409e5b
[TH2-5226] Removed singletons (#124)
Nikita-Smirnov-Exactpro Sep 19, 2024
a77dd93
[TH2-5226] Enabled style check
Nikita-Smirnov-Exactpro Sep 20, 2024
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
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 LDP"

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
177 changes: 74 additions & 103 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,141 +1,112 @@
/*
* 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 'checkstyle'
id "io.gitlab.arturbosch.detekt" version "${detekt_version}"
id "org.jetbrains.kotlin.jvm" version "${kotlin_version}"
id "org.owasp.dependencycheck" version "${owaspVersion}"
id 'application'
// id 'checkstyle'
// alias(libs.plugins.detekt)
alias(libs.plugins.kotlin)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: why have you removed those plugins? We should keep the style checkers

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will revert these checks at the end but now they are bothering me

alias(libs.plugins.th2.component)
alias(libs.plugins.download)
}

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

repositories {
mavenCentral()
kotlin {
jvmToolchain(11)
}

checkstyle {
toolVersion = "10.12.0"
repositories {
mavenCentral()
}

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

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"
}
}
//detekt {
// buildUponDefaultConfig = true
// autoCorrect = true
// 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}"
testImplementation(platform(libs.testcontainers.bom))
testImplementation 'org.testcontainers:rabbitmq'
testImplementation 'org.testcontainers:k3s'

testImplementation "org.junit.jupiter:junit-jupiter-api:${jupiter_version}"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${jupiter_version}"

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()
useJUnitPlatform {
excludeTags("integration-test")
}
}

compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
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()
}

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

dependencyCheck {
skipConfigurations += "checkstyle"
}
Loading
Loading