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

Support test connector service #56

Merged
merged 6 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [1.2.2] - 2023-03-23

### Added
- Connector test service integration for managed connector connectivity test
- Update email template for connector status

## [1.2.1] - 2023-03-18

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ This service will help service provider to set up DFT/SDE with EDC and EDC as se
### Software Version

```shell
Application version: 1.2.1
Helm release version: 1.2.1
Application version: 1.2.2
Helm release version: 1.2.2
```


Expand Down
4 changes: 2 additions & 2 deletions charts/orchestrator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ sources:
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.2.1
version: 1.2.2


# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.2.1"
appVersion: "1.2.2"
dependencies:
- condition: postgresql.enabled
name: postgresql
Expand Down
2 changes: 1 addition & 1 deletion charts/orchestrator/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# autosetup

![Version: 1.2.1](https://img.shields.io/badge/Version-1.2.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.1](https://img.shields.io/badge/AppVersion-1.2.1-informational?style=flat-square)
![Version: 1.2.2](https://img.shields.io/badge/Version-1.2.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.2.2](https://img.shields.io/badge/AppVersion-1.2.2-informational?style=flat-square)

This service will help service provider to set up DFT/SDE with EDC and EDC as service in service provider environment.

Expand Down
105 changes: 105 additions & 0 deletions index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
apiVersion: v1
entries:
autosetup:
- apiVersion: v2
appVersion: 1.2.2
created: "2023-03-23T11:52:03.751385+05:30"
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.x.x
description: This service will help service provider to set up DFT/SDE with EDC
and EDC as service in service provider environment.
digest: cfe3552cc5cb1a6af6a42f0db1ec3c539cce7dfdfe92f16a03222f3b2c061335
name: autosetup
sources:
- https://github.com/eclipse-tractusx/autosetup-backend
type: application
urls:
- https://catenax-ng.github.io/tx-autosetup-backend/autosetup-1.2.2.tgz
version: 1.2.2
- apiVersion: v2
appVersion: 1.2.1
created: "2023-03-23T11:52:03.747811+05:30"
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.x.x
description: This service will help service provider to set up DFT/SDE with EDC
and EDC as service in service provider environment.
digest: d786a44bcefc16692922febb7e2aa8c8cf1e9c26a90f5f7f9ab96bd7be7ab6d3
name: autosetup
sources:
- https://github.com/eclipse-tractusx/autosetup-backend
type: application
urls:
- https://catenax-ng.github.io/tx-autosetup-backend/autosetup-1.2.1.tgz
version: 1.2.1
- apiVersion: v2
appVersion: 1.2.0
created: "2023-03-23T11:52:03.744139+05:30"
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.x.x
description: This service will help service provider to set up DFT/SDE with EDC
and EDC as service in service provider environment.
digest: 445bb07d54c5122c0a77d167217a7177da0714d302aa394fc6c758a46c8d2fb5
name: autosetup
sources:
- https://github.com/eclipse-tractusx/autosetup-backend
type: application
urls:
- https://catenax-ng.github.io/tx-autosetup-backend/autosetup-1.2.0.tgz
version: 1.2.0
- apiVersion: v2
appVersion: 1.1.5
created: "2023-03-23T11:52:03.739837+05:30"
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.x.x
description: A Helm chart for Kubernetes
digest: 04563b2e84ff94388d09e3645699f47be07fbc985fccc4dbc5997b6c754608bd
name: autosetup
sources:
- https://github.com/eclipse-tractusx/autosetup-backend
type: application
urls:
- https://catenax-ng.github.io/tx-autosetup-backend/autosetup-1.1.5.tgz
version: 1.1.5
- apiVersion: v2
appVersion: 1.1.4
created: "2023-03-23T11:52:03.736098+05:30"
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.x.x
description: A Helm chart for Kubernetes
digest: 31f30dfcab47c6a905522d96508d0c810995504b9cebe76bdf428b735298c7b6
name: autosetup
type: application
urls:
- https://catenax-ng.github.io/tx-autosetup-backend/autosetup-1.1.4.tgz
version: 1.1.4
- apiVersion: v2
appVersion: 0.0.8
created: "2023-03-23T11:52:03.73211+05:30"
dependencies:
- condition: postgresql.enabled
name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 11.x.x
description: A Helm chart for Kubernetes
digest: fc8fbb6b7f5ca9ba828c217ccf260e06ee4fa6ed3633568ce7d74cdf5f0c1051
name: autosetup
type: application
urls:
- https://catenax-ng.github.io/tx-autosetup-backend/autosetup-1.1.3.tgz
version: 1.1.3
generated: "2023-03-23T11:52:03.726464+05:30"
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</parent>
<groupId>org.eclipse.tractusx</groupId>
<artifactId>auto-setup</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<name>auto-setup</name>
<description>auto-setup</description>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public enum AppNameConstant {

DFT_FRONTEND,

DFT_BACKEND


DFT_BACKEND,

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package org.eclipse.tractusx.autosetup.manager;

import java.util.Map;
import java.util.UUID;

import org.eclipse.tractusx.autosetup.constant.TriggerStatusEnum;
import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerDetails;
import org.eclipse.tractusx.autosetup.entity.AutoSetupTriggerEntry;
import org.eclipse.tractusx.autosetup.exception.ServiceException;
import org.eclipse.tractusx.autosetup.model.Customer;
import org.eclipse.tractusx.autosetup.testservice.proxy.ConnectorTestRequest;
import org.eclipse.tractusx.autosetup.testservice.proxy.ConnectorTestServiceProxy;
import org.eclipse.tractusx.autosetup.testservice.proxy.ConnectorTestServiceResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import org.springframework.retry.support.RetrySynchronizationManager;
import org.springframework.stereotype.Service;

import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
@RequiredArgsConstructor
public class TestConnectorServiceManager {

private final AutoSetupTriggerManager autoSetupTriggerManager;

private final ConnectorTestServiceProxy connectorTestServiceProxy;

@Value("${connector.test.service.url}")
private String connectorTestServiceURL;

@Retryable(value = {
ServiceException.class }, maxAttemptsExpression = "${retry.maxAttempts}", backoff = @Backoff(delayExpression = "${retry.backOffDelay}"))
public Map<String, String> verifyConnectorTestingThroughTestService(Customer customerDetails,
Map<String, String> inputData, AutoSetupTriggerEntry triger) {

AutoSetupTriggerDetails autoSetupTriggerDetails = AutoSetupTriggerDetails.builder()
.id(UUID.randomUUID().toString()).step("CONNECTOR_TEST_SERVICE").build();
try {

ConnectorTestRequest connectorTestRequest = ConnectorTestRequest.builder()
.apiKeyHeader(inputData.get("edcApiKey")).apiKeyValue(inputData.get("edcApiKeyValue"))
.connectorHost(inputData.get("controlPlaneEndpoint")).build();

waitingTime();

ConnectorTestServiceResponse testResult = connectorTestServiceProxy
.verifyConnectorTestingThroughTestService(connectorTestRequest);

log.info("Connector status: " + testResult.getMessage());

inputData.put("connectorTestResult", testResult.getMessage());

inputData.put("testServiceURL", connectorTestServiceURL);

autoSetupTriggerDetails.setStatus(TriggerStatusEnum.SUCCESS.name());

} catch (Exception ex) {

log.error("ConnectorTestService failed retry attempt: : {}",
RetrySynchronizationManager.getContext().getRetryCount() + 1);

autoSetupTriggerDetails.setStatus(TriggerStatusEnum.FAILED.name());
autoSetupTriggerDetails.setRemark(ex.getMessage());
throw new ServiceException("ConnectorTestService Oops! We have an exception - " + ex.getMessage());
} finally {
autoSetupTriggerManager.saveTriggerDetails(autoSetupTriggerDetails, triger);
}

return inputData;
}

@SneakyThrows
private void waitingTime() {

try {
log.info("Waiting after connector setup to get pod up to test connector as data provider/consumer");
Thread.sleep(60000);
} catch (InterruptedException e) {

Thread.currentThread().interrupt();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.EDC_CONTROLPLANE;
import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.EDC_DATAPLANE;
import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.TRACTUS_CONNECTOR;
import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.POSTGRES_DB;
import static org.eclipse.tractusx.autosetup.constant.AppNameConstant.TRACTUS_CONNECTOR;

import java.util.Map;

Expand All @@ -35,6 +35,7 @@
import org.eclipse.tractusx.autosetup.manager.EDCControlplaneManager;
import org.eclipse.tractusx.autosetup.manager.EDCDataplaneManager;
import org.eclipse.tractusx.autosetup.manager.PostgresDBManager;
import org.eclipse.tractusx.autosetup.manager.TestConnectorServiceManager;
import org.eclipse.tractusx.autosetup.manager.TractusConnectorManager;
import org.eclipse.tractusx.autosetup.manager.VaultManager;
import org.eclipse.tractusx.autosetup.model.Customer;
Expand All @@ -54,6 +55,7 @@ public class EDCConnectorWorkFlow {
private final EDCDataplaneManager edcDataplaneManager;
private final TractusConnectorManager tractusConnectorManager;
private final ConnectorRegistrationManager connectorRegistrationManager;
private final TestConnectorServiceManager testConnectorServiceManager;

private final AppDeleteManager appDeleteManager;

Expand All @@ -70,6 +72,9 @@ public Map<String, String> getWorkFlow(Customer customerDetails, SelectedTools t
inputConfiguration.putAll(
connectorRegistrationManager.registerConnector(customerDetails, tool, inputConfiguration, triger));

inputConfiguration.putAll(testConnectorServiceManager.verifyConnectorTestingThroughTestService(customerDetails,
inputConfiguration, triger));

return inputConfiguration;
}

Expand All @@ -94,6 +99,9 @@ public Map<String, String> getWorkFlowSeparateCPandDP(Customer customerDetails,
edcDataplaneManager.managePackage(customerDetails, workflowAction, tool, inputConfiguration, triger));
inputConfiguration.putAll(
connectorRegistrationManager.registerConnector(customerDetails, tool, inputConfiguration, triger));

inputConfiguration.putAll(testConnectorServiceManager.verifyConnectorTestingThroughTestService(customerDetails,
inputConfiguration, triger));

return inputConfiguration;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.eclipse.tractusx.autosetup.testservice.proxy;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class ConnectorTestRequest {

private String connectorHost;

private String apiKeyHeader;

private String apiKeyValue;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.eclipse.tractusx.autosetup.testservice.proxy;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(name = "ConnectorTestServiceProxy", url = "${connector.test.service.url}")
public interface ConnectorTestServiceProxy {

@PostMapping("/connector-test")
public ConnectorTestServiceResponse verifyConnectorTestingThroughTestService(@RequestBody ConnectorTestRequest connectorTestRequest);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.eclipse.tractusx.autosetup.testservice.proxy;

import lombok.Data;

@Data
public class ConnectorTestServiceResponse {

private String message;

}
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ vault.url=${vaultUrl}
vault.token=${vaultToken}
vault.timeout=30

#Connector Test service details
connector.test.service.url=${connectorTestServiceUrl}

#Portal interface info
portal.url=${portalurl}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/templates/edc_success_activate.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
<p>EDC ApiKey : <a href="#">${edcApiKey}</a>
<p>EDC ApiKeyValue : <a href="#">${edcApiKeyValue}</a>
<p>Data Plane URL : <a href="#">${dataPlanePublicEndpoint}</a>

<p>Your connector status through connector test service: ${connectorTestResult}, check status again <a href="${testServiceURL}">here</a></p>

<p>Kind Regards<br />Catina-X</p>

</div>
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/templates/success_activate.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<p><strong>Hello ${orgname},</strong></p>
<p>The SDE/DFT tool successfully activated for your use.</p>
<p>Please click <a href="${dftFrontEndUrl}">here</a> to start using it.</p>
<p>Your connector status through connector test service: ${connectorTestResult}, check status again <a href="${testServiceURL}">here</a></p>
<p>Note: You need to use your own organization login credential to login SDE/DFT tool.</p>

<p>Kind Regards<br />Catina-X</p>
Expand Down