Skip to content

Commit

Permalink
Merge pull request #1070 from eclipse-tractusx/feat/bpdm-system-teste…
Browse files Browse the repository at this point in the history
…r-wip

feat(bpdm-system-test): golden record tester module.
  • Loading branch information
SujitMBRDI authored Dec 9, 2024
2 parents 2b1f2c9 + 5a1ffdf commit edf3fd6
Show file tree
Hide file tree
Showing 18 changed files with 950 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C

- BPDM Pool: Post endpoint to fetch the BPNL/S/A based on the requested identifiers.([#1052](https://github.com/eclipse-tractusx/bpdm/issues/1052))
- BPDM Gate & Orchestrator: Enhance the error handling mechanism for the orchestrator and gate components by extending the list of available error codes.([#1003](https://github.com/eclipse-tractusx/bpdm/pull/1003#pullrequestreview-2477395867))
- BPDM System Test: Tester module which performs automated end-to-end tests on an existing golden record process.([#1070](https://github.com/eclipse-tractusx/bpdm/pull/1070))

### Changed

Expand Down
18 changes: 18 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ maven/mavencentral/commons-codec/commons-codec/1.17.1, Apache-2.0 AND (Apache-2.
maven/mavencentral/commons-collections/commons-collections/3.2.2, Apache-2.0, approved, #15185
maven/mavencentral/commons-io/commons-io/2.17.0, Apache-2.0, approved, #16198
maven/mavencentral/commons-logging/commons-logging/1.2, Apache-2.0, approved, CQ10162
maven/mavencentral/io.cucumber/ci-environment/10.0.1, MIT, approved, #15218
maven/mavencentral/io.cucumber/cucumber-core/7.18.1, MIT AND (Apache-2.0 AND MIT), approved, #15146
maven/mavencentral/io.cucumber/cucumber-expressions/17.1.0, MIT, approved, #14271
maven/mavencentral/io.cucumber/cucumber-gherkin-messages/7.18.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-gherkin/7.18.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-java/7.18.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-junit/7.18.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-plugin/7.18.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/cucumber-spring/7.18.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/datatable/7.18.1, Apache-2.0, approved, #15145
maven/mavencentral/io.cucumber/docstring/7.18.1, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/gherkin/28.0.0, MIT, approved, #14276
maven/mavencentral/io.cucumber/html-formatter/21.4.1, MIT, restricted, clearlydefined
maven/mavencentral/io.cucumber/junit-xml-formatter/0.5.0, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/messages/24.1.0, MIT, approved, #14274
maven/mavencentral/io.cucumber/query/12.2.0, MIT, approved, clearlydefined
maven/mavencentral/io.cucumber/tag-expressions/6.1.0, MIT AND (BSD-3-Clause AND MIT) AND BSD-3-Clause, approved, #14277
maven/mavencentral/io.cucumber/testng-xml-formatter/0.2.0, MIT, approved, clearlydefined
maven/mavencentral/io.github.microutils/kotlin-logging-jvm/3.0.5, Apache-2.0, approved, clearlydefined
maven/mavencentral/io.micrometer/micrometer-commons/1.14.1, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #17272
maven/mavencentral/io.micrometer/micrometer-core/1.14.1, Apache-2.0 AND (Apache-2.0 AND MIT), approved, #17271
Expand Down
17 changes: 17 additions & 0 deletions bpdm-system-tester/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# System Tester

This application performs automated end-to-end tests on an existing golden record process.
For this it needs access to a BPDM Gate application in order to share business partner data and compare the resulting golden records with the expected result.

In order to use this application you first need to [install the BPDM applications](../INSTALL.md).
For a local execution you can follow the following steps:

1. Create a JAR file of the bpdm system tester (Execute from project root)
```bash
mvn -B -U clean package -pl bpdm-system-tester -am -DskipTests
```
2. Install and run the BPDM applications locally without authentication
3. Run the JAR file so the tests will be executed:
```bash
java -jar bpdm-system-tester/target/bpdm-system-tester.jar
```
103 changes: 103 additions & 0 deletions bpdm-system-tester/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>bpdm-parent</artifactId>
<version>${revision}</version>
</parent>

<artifactId>bpdm-system-tester</artifactId>
<name>Business Partner Data Management System Tester</name>
<description>Application to perform system tests for the BPDM system and golden record process</description>
<packaging>jar</packaging>

<properties>
<cucumber.version>7.18.1</cucumber.version>
</properties>

<dependencies>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-coroutines-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bpdm-pool-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bpdm-gate-api</artifactId>
</dependency>
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bpdm-common-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<!-- in kotlin, use mockk instead of mockito -->
<exclusion>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<!-- Name jar without version to make it easier to reference it during CICD -->
<finalName>bpdm-system-tester</finalName>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package org.eclipse.tractusx.bpdm.test.system

import io.cucumber.junit.Cucumber
import org.junit.runner.RunWith
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
import org.springframework.boot.context.properties.ConfigurationPropertiesScan

@RunWith(Cucumber::class)
class CucumberTestRunConfiguration

@SpringBootApplication(exclude=[DataSourceAutoConfiguration::class])
@ConfigurationPropertiesScan
class SpringApplicationConfiguration

fun main(args: Array<String>) {
//use parallel execution default if not overwritten
//can't use cucumber.properties for this as the properties parser currently does not support it
//see https://github.com/cucumber/cucumber-jvm/issues/2833
val cucumberArgs = if(!args.contains("--threads")) args.plus(listOf("--threads", "16")) else args
io.cucumber.core.cli.Main.main(*cucumberArgs)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package org.eclipse.tractusx.bpdm.test.system.config

import org.eclipse.tractusx.bpdm.common.util.BpdmClientProperties
import org.eclipse.tractusx.bpdm.common.util.BpdmWebClientProvider
import org.eclipse.tractusx.bpdm.common.util.ClientConfigurationProperties
import org.eclipse.tractusx.bpdm.gate.api.client.GateClient
import org.eclipse.tractusx.bpdm.gate.api.client.GateClientImpl
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@ConfigurationProperties(prefix = PoolClientConfigurationProperties.PREFIX)
data class GateClientConfigProperties(
override val baseUrl: String = "http://localhost:8081",
val searchChangelogPageSize: Int = 100,
override val securityEnabled: Boolean = false,
override val registration: OAuth2ClientProperties.Registration,
override val provider: OAuth2ClientProperties.Provider
) : BpdmClientProperties {
companion object {
const val PREFIX = "${ClientConfigurationProperties.PREFIX}.gate"
}

override fun getId() = PREFIX
}

@Configuration
class GateClientConfig{

@Bean
fun gateClient(webClientProvider: BpdmWebClientProvider, properties: GateClientConfigProperties): GateClient {
return GateClientImpl { webClientProvider.builder(properties).build() }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package org.eclipse.tractusx.bpdm.test.system.config

import org.eclipse.tractusx.bpdm.common.util.BpdmClientProperties
import org.eclipse.tractusx.bpdm.common.util.BpdmWebClientProvider
import org.eclipse.tractusx.bpdm.common.util.ClientConfigurationProperties
import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient
import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl
import org.springframework.boot.autoconfigure.security.oauth2.client.OAuth2ClientProperties
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration


@ConfigurationProperties(prefix = PoolClientConfigurationProperties.PREFIX)
data class PoolClientConfigurationProperties(
override val baseUrl: String = "http://localhost:8080",
val searchChangelogPageSize: Int = 100,
override val securityEnabled: Boolean = false,
override val registration: OAuth2ClientProperties.Registration,
override val provider: OAuth2ClientProperties.Provider
) : BpdmClientProperties {
companion object {
const val PREFIX = "${ClientConfigurationProperties.PREFIX}.pool"
}

override fun getId() = PREFIX
}

@Configuration
class PoolClientConfiguration{

@Bean
fun poolClient(webClientProvider: BpdmWebClientProvider, properties: PoolClientConfigurationProperties): PoolApiClient{
return PoolClientImpl { webClientProvider.builder(properties).build() }
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*******************************************************************************
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
******************************************************************************/

package org.eclipse.tractusx.bpdm.test.system.config

import org.eclipse.tractusx.bpdm.gate.api.client.GateClient
import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient
import org.eclipse.tractusx.bpdm.test.system.utils.GateInputFactory
import org.eclipse.tractusx.bpdm.test.system.utils.GateOutputFactory
import org.eclipse.tractusx.bpdm.test.system.utils.StepUtils
import org.eclipse.tractusx.bpdm.test.system.utils.TestMetadata
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import java.time.Instant

@Configuration
class TestDataConfiguration {

@Bean
fun testMetadata(poolClient: PoolApiClient): TestMetadata {
val testMetadata = TestMetadata(
identifierTypes = listOf("EU_VAT_ID_DE", "DUNS_ID"),
legalForms = listOf("SCE1", "SGST"),
adminAreas = listOf("DE-BW", "DE-BY")
)

return testMetadata
}

@Bean
fun gateTestDataFactory(testMetadata: TestMetadata, testRunData: TestRunData): GateInputFactory {
return GateInputFactory(testMetadata, testRunData)
}

@Bean
fun gateOutputFactory(gateInputDataFactory: GateInputFactory): GateOutputFactory {
return GateOutputFactory(gateInputDataFactory)
}

@Bean
fun testRunData(): TestRunData {
return TestRunData(Instant.now())
}

@Bean
fun stepUtils(testRunData: TestRunData, gateClient: GateClient): StepUtils{
return StepUtils(gateClient)
}
}
Loading

0 comments on commit edf3fd6

Please sign in to comment.