Skip to content

Commit

Permalink
fix: transfer process states stuck in RUNNING (#653)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier authored Dec 5, 2023
1 parent b064eb1 commit d733cec
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md).

#### Patch Changes

- Marked `MY_EDC_NAME_KEBAB_CASE` as deprecated in favor of `MY_EDC_PARTICIPANT_ID`.
- Fixed an issue preventing Contract Negotiations between MDS Connectors.
- Fixed an issue preventing transfer processes from being marked as `COMPLETED` in Eclipse EDC `0.2`.
- Improved `:extensions:wrapper:wrapper-common-mappers` for broker: `AssetJsonLdUtils`, made some methods public.
- Added example for using the API Wrapper to offer and consume data.
- Marked `MY_EDC_NAME_KEBAB_CASE` as deprecated in favor of `MY_EDC_PARTICIPANT_ID`.
- Improved development documentation documenting our CHANGELOG.

### Deployment Migration Notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,12 @@ set consumer_agent_id = neg.counterparty_id
from edc_contract_negotiation neg
where neg.agreement_id = edc_contract_agreement.agr_id
and neg.type = 'PROVIDER';

-- Optimizations for Transfer Processes
create index transfer_process_status
on edc_transfer_process (state);

-- Fix transfer processes stuck in running state
update edc_transfer_process
set state = 800
where state = 600;
31 changes: 31 additions & 0 deletions extensions/transfer-process-status-checker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- PROJECT LOGO -->
<br />
<div align="center">
<a href="https://github.com/sovity/edc-extensions">
<img src="https://raw.githubusercontent.com/sovity/edc-ui/main/src/assets/images/sovity_logo.svg" alt="Logo" width="300">
</a>

<h3 align="center">EDC-Connector Extension:<br />Transfer Process Status Checker</h3>

<p align="center">
<a href="https://github.com/sovity/edc-extensions/issues/new?template=bug_report.md">Report Bug</a>
·
<a href="https://github.com/sovity/edc-extensions/issues/new?template=feature_request.md">Request Feature</a>
</p>
</div>

## About this Extension

Bugfix extension for `Eclipse EDC [0.2.1, 0.3)`, marks transfer processes as `COMPLETED`.

## Why does this extension exist?

We cannot directly upgrade to `Eclipse EDC >=0.3` now, but will of course do so soon.

## License

Apache License 2.0 - see [LICENSE](../../LICENSE)

## Contact

sovity GmbH - [email protected]
23 changes: 23 additions & 0 deletions extensions/transfer-process-status-checker/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
val edcVersion: String by project
val edcGroup: String by project

plugins {
`java-library`
`maven-publish`
}

dependencies {
api("${edcGroup}:transfer-spi:${edcVersion}")
testImplementation("${edcGroup}:junit:${edcVersion}")
}

val sovityEdcExtensionGroup: String by project
group = sovityEdcExtensionGroup

publishing {
publications {
create<MavenPublication>(project.name) {
from(components["java"])
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2022 sovity GmbH
*
* 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
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*
*/

package de.sovity.edc.extension.transfer;

import org.eclipse.edc.connector.transfer.spi.status.StatusCheckerRegistry;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;

import java.util.List;

public class TransferProcessStatusCheckerExtension implements ServiceExtension {
private static final String EXTENSION_NAME = "Transfer Process Status Checker";

@Inject
private StatusCheckerRegistry statusCheckerRegistry;

@Override
public String name() {
return EXTENSION_NAME;
}

@Override
public void initialize(ServiceExtensionContext context) {
List.of("HttpProxy", "HttpData").forEach(this::registerStatusChecker);
}

private void registerStatusChecker(String transferType) {
statusCheckerRegistry.register(transferType, (transferProcess, resources) -> true);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.sovity.edc.extension.transfer.TransferProcessStatusCheckerExtension
1 change: 1 addition & 0 deletions launchers/common/base/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dependencies {
// sovity Extensions Package
api(project(":extensions:sovity-edc-extensions-package"))
api(project(":extensions:postgres-flyway"))
api(project(":extensions:transfer-process-status-checker"))

// Control-plane to Data-plane
api("${edcGroup}:transfer-data-plane:${edcVersion}")
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include(":extensions:policy-time-interval")
include(":extensions:postgres-flyway")
include(":extensions:sovity-edc-extensions-package")
include(":extensions:test-backend-controller")
include(":extensions:transfer-process-status-checker")
include(":extensions:wrapper:clients:java-client")
include(":extensions:wrapper:clients:java-client-example")
include(":extensions:wrapper:wrapper")
Expand Down
13 changes: 8 additions & 5 deletions tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
import java.time.OffsetDateTime;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import static de.sovity.edc.client.gen.model.ContractAgreementDirection.CONSUMING;
import static de.sovity.edc.client.gen.model.ContractAgreementDirection.PROVIDING;
import static de.sovity.edc.extension.e2e.connector.DataTransferTestUtil.validateDataTransferred;
import static de.sovity.edc.extension.e2e.connector.config.ConnectorConfigFactory.forTestDatabase;
import static de.sovity.edc.extension.e2e.connector.config.ConnectorRemoteConfigFactory.fromConnectorConfig;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

class UiApiWrapperTest {

Expand Down Expand Up @@ -278,11 +280,12 @@ void provide_consume_assetMapping_policyMapping_agreements() {

validateDataTransferred(dataAddress.getDataSinkSpyUrl(), data);

//Currently the Core Edc which prevent the transfer process to be marked as completed
var completedProvidingTransferProcess = providerClient.uiApi().getContractAgreementPage().getContractAgreements().get(0).getTransferProcesses().get(0);
var completedConsumingTransferProcess = consumerClient.uiApi().getContractAgreementPage().getContractAgreements().get(0).getTransferProcesses().get(0);
assertThat(completedProvidingTransferProcess.getState().getSimplifiedState()).isEqualTo(TransferProcessSimplifiedState.RUNNING);
assertThat(completedConsumingTransferProcess.getState().getSimplifiedState()).isEqualTo(TransferProcessSimplifiedState.RUNNING);
await().atMost(10, TimeUnit.SECONDS).untilAsserted(() -> {
var providing = providerClient.uiApi().getTransferHistoryPage().getTransferEntries().get(0);
var consuming = consumerClient.uiApi().getTransferHistoryPage().getTransferEntries().get(0);
assertThat(providing.getState().getSimplifiedState()).isEqualTo(TransferProcessSimplifiedState.OK);
assertThat(consuming.getState().getSimplifiedState()).isEqualTo(TransferProcessSimplifiedState.OK);
});
}

@Test
Expand Down

0 comments on commit d733cec

Please sign in to comment.