Skip to content

Commit

Permalink
feat: enable federated catalog cache SQL variant (#1432)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood authored Jul 22, 2024
1 parent 07cdb51 commit 91cb441
Show file tree
Hide file tree
Showing 11 changed files with 263 additions and 13 deletions.
13 changes: 13 additions & 0 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,22 @@ maven/mavencentral/org.eclipse.edc/asset-api/0.8.0, Apache-2.0, approved, techno
maven/mavencentral/org.eclipse.edc/asset-index-sql/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/asset-spi/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/asset-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/asset-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/auth-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/auth-tokenbased/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/autodoc-processor/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot-spi/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/boot/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/callback-event-dispatcher/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/callback-http-dispatcher/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/callback-static-endpoint/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/catalog-api/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/catalog-spi/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/catalog-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/catalog-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/catalog-util-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/configuration-filesystem/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/connector-core/0.8.0, Apache-2.0, approved, technology.edc
Expand All @@ -386,8 +389,10 @@ maven/mavencentral/org.eclipse.edc/control-plane-transfer/0.8.0, Apache-2.0, app
maven/mavencentral/org.eclipse.edc/control-plane-transform/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/core-spi/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/core-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/core-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/crawler-core/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/crawler-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/crawler-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/credential-query-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/crypto-common-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/data-address-http-data-spi/0.8.0, Apache-2.0, approved, technology.edc
Expand Down Expand Up @@ -436,8 +441,10 @@ maven/mavencentral/org.eclipse.edc/edr-store-core/0.8.0, Apache-2.0, approved, t
maven/mavencentral/org.eclipse.edc/edr-store-receiver/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/edr-store-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/federated-catalog-api/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/federated-catalog-cache-sql/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/federated-catalog-core/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/federated-catalog-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/federated-catalog-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/http-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/http-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/http/0.8.0, Apache-2.0, approved, technology.edc
Expand Down Expand Up @@ -498,6 +505,7 @@ maven/mavencentral/org.eclipse.edc/policy-engine-spi/0.8.0, Apache-2.0, approved
maven/mavencentral/org.eclipse.edc/policy-evaluator-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-model/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-model/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-model/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-monitor-core/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-monitor-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/policy-monitor-store-sql/0.8.0, Apache-2.0, approved, technology.edc
Expand All @@ -506,17 +514,21 @@ maven/mavencentral/org.eclipse.edc/presentation-api/0.8.0, Apache-2.0, approved,
maven/mavencentral/org.eclipse.edc/query-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/runtime-metamodel/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/secrets-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/sql-core/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/sql-core/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/sql-lease/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/sql-pool-apache-commons/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/state-machine-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/store-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/token-core/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/token-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transaction-datasource-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transaction-datasource-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transaction-local/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transaction-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transaction-spi/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transfer-data-plane-signaling/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transfer-data-plane-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/transfer-process-api/0.8.0, Apache-2.0, approved, technology.edc
Expand All @@ -528,6 +540,7 @@ maven/mavencentral/org.eclipse.edc/transform-lib/0.8.0, Apache-2.0, approved, te
maven/mavencentral/org.eclipse.edc/transform-spi/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/util-lib/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/util-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/util-lib/0.8.1-20240719-SNAPSHOT, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/validator-data-address-http-data/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/validator-lib/0.8.0, Apache-2.0, approved, technology.edc
maven/mavencentral/org.eclipse.edc/validator-spi/0.7.2-SNAPSHOT, Apache-2.0, approved, technology.edc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ spec:
- name: "EDC_DATASOURCE_EDR_URL"
value: {{ tpl .Values.postgresql.jdbcUrl . | quote }}

# see extension https://github.com/eclipse-edc/FederatedCatalog/tree/main/extensions/store/sql/federated-catalog-cache-sql
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_NAME"
value: "federatedcatalog"
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_USER"
value: {{ .Values.postgresql.auth.username | required ".Values.postgresql.auth.username is required" | quote }}
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_PASSWORD"
value: {{ .Values.postgresql.auth.password | required ".Values.postgresql.auth.password is required" | quote }}
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_URL"
value: {{ tpl .Values.postgresql.jdbcUrl . | quote }}

#############################
## IATP / STS / DIM CONFIG ##
#############################
Expand Down
10 changes: 10 additions & 0 deletions charts/tractusx-connector/templates/deployment-controlplane.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ spec:
- name: "EDC_DATASOURCE_EDR_URL"
value: {{ tpl .Values.postgresql.jdbcUrl . | quote }}

# see extension https://github.com/eclipse-edc/FederatedCatalog/tree/main/extensions/store/sql/federated-catalog-cache-sql
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_NAME"
value: "federatedcatalog"
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_USER"
value: {{ .Values.postgresql.auth.username | required ".Values.postgresql.auth.username is required" | quote }}
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_PASSWORD"
value: {{ .Values.postgresql.auth.password | required ".Values.postgresql.auth.password is required" | quote }}
- name: "EDC_DATASOURCE_FEDERATEDCATALOG_URL"
value: {{ tpl .Values.postgresql.jdbcUrl . | quote }}

#############################
## IATP / STS / DIM CONFIG ##
#############################
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* 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.edc.postgresql.migration;

public class FederatedCatalogCacheMigrationExtension extends AbstractPostgresqlMigrationExtension {
private static final String NAME_SUBSYSTEM = "federatedcatalog";

@Override
protected String getSubsystemName() {
return NAME_SUBSYSTEM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ org.eclipse.tractusx.edc.postgresql.migration.PolicyPostgresqlMigrationExtension
org.eclipse.tractusx.edc.postgresql.migration.PolicyMonitorPostgresqlMigrationExtension
org.eclipse.tractusx.edc.postgresql.migration.TransferProcessPostgresqlMigrationExtension
org.eclipse.tractusx.edc.postgresql.migration.BusinessGroupPostgresMigrationExtension
org.eclipse.tractusx.edc.postgresql.migration.EdrIndexPostgresqlMigrationExtension
org.eclipse.tractusx.edc.postgresql.migration.EdrIndexPostgresqlMigrationExtension
org.eclipse.tractusx.edc.postgresql.migration.FederatedCatalogCacheMigrationExtension
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--
-- Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
--
-- 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:
-- Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
--

--
-- table: edc_federated_catalog
--

CREATE TABLE IF NOT EXISTS edc_federated_catalog
(
id VARCHAR PRIMARY KEY NOT NULL,
catalog JSON,
marked BOOLEAN DEFAULT FALSE
);


1 change: 1 addition & 0 deletions edc-tests/edc-controlplane/catalog-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
testImplementation(libs.edc.junit)
testImplementation(libs.restAssured)
testImplementation(libs.awaitility)
testImplementation(libs.edc.fc.spi.crawler)
testRuntimeOnly(libs.edc.transaction.local)

testCompileOnly(project(":edc-tests:runtime:runtime-memory"))
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
/********************************************************************************
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* 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.edc.tests.catalog;

import org.eclipse.edc.crawler.spi.TargetNode;
import org.eclipse.edc.crawler.spi.TargetNodeDirectory;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.annotations.PostgresqlIntegrationTest;
import org.eclipse.edc.junit.extensions.RuntimeExtension;
import org.eclipse.tractusx.edc.tests.participant.TransferParticipant;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import java.util.List;
import java.util.stream.Collectors;

import static io.restassured.http.ContentType.JSON;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.controlplane.test.system.utils.PolicyFixtures.noConstraintPolicy;
import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.CONSUMER_BPN;
import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.CONSUMER_NAME;
import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.PROVIDER_BPN;
import static org.eclipse.tractusx.edc.tests.TestRuntimeConfiguration.PROVIDER_NAME;
import static org.eclipse.tractusx.edc.tests.participant.TractusxParticipantBase.ASYNC_POLL_INTERVAL;
import static org.eclipse.tractusx.edc.tests.participant.TractusxParticipantBase.ASYNC_TIMEOUT;
import static org.eclipse.tractusx.edc.tests.runtimes.Runtimes.memoryRuntime;
import static org.eclipse.tractusx.edc.tests.runtimes.Runtimes.pgRuntime;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;

public class FederatedCatalogTest {

protected static final TransferParticipant CONSUMER = TransferParticipant.Builder.newInstance()
.name(CONSUMER_NAME)
.id(CONSUMER_BPN)
.build();


protected static final TransferParticipant PROVIDER = TransferParticipant.Builder.newInstance()
.name(PROVIDER_NAME)
.id(PROVIDER_BPN)
.build();

abstract static class Tests {

@Test
@DisplayName("Consumer gets cached catalog with provider entry")
void requestCatalog_fulfillsPolicy_shouldReturnOffer() {

// arrange
PROVIDER.createAsset("test-asset");
var ap = PROVIDER.createPolicyDefinition(noConstraintPolicy());
var cp = PROVIDER.createPolicyDefinition(noConstraintPolicy());
PROVIDER.createContractDefinition("test-asset", "test-def", ap, cp);


await().pollInterval(ASYNC_POLL_INTERVAL)
.atMost(ASYNC_TIMEOUT)
.untilAsserted(() -> {
// act
CONSUMER.getFederatedCatalog()
.log().ifError()
.statusCode(200)
.contentType(JSON)
.body("size()", is(1))
.body("[0].'http://www.w3.org/ns/dcat#dataset'.'@id'", equalTo("test-asset"));
});
}
}

static class TestTargetNodeDirectory implements TargetNodeDirectory {

private final List<TransferParticipant> participants;

TestTargetNodeDirectory(List<TransferParticipant> participants) {
this.participants = participants;
}

@Override
public List<TargetNode> getAll() {
return participants.stream()
.map(p -> new TargetNode(p.getDid(), p.getBpn(), p.getProtocolEndpoint().getUrl().toString(), List.of("dataspace-protocol-http")))
.collect(Collectors.toList());
}

@Override
public void insert(TargetNode node) {

}
}

@Nested
@EndToEndTest
class InMemory extends Tests {

@RegisterExtension
protected static final RuntimeExtension CONSUMER_RUNTIME = memoryRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());

@RegisterExtension
protected static final RuntimeExtension PROVIDER_RUNTIME = memoryRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());


static {
CONSUMER_RUNTIME.registerServiceMock(TargetNodeDirectory.class, new TestTargetNodeDirectory(List.of(PROVIDER)));
}
}

@Nested
@PostgresqlIntegrationTest
class Postgres extends Tests {

@RegisterExtension
protected static final RuntimeExtension CONSUMER_RUNTIME = pgRuntime(CONSUMER.getName(), CONSUMER.getBpn(), CONSUMER.getConfiguration());

@RegisterExtension
protected static final RuntimeExtension PROVIDER_RUNTIME = pgRuntime(PROVIDER.getName(), PROVIDER.getBpn(), PROVIDER.getConfiguration());

static {
CONSUMER_RUNTIME.registerServiceMock(TargetNodeDirectory.class, new TestTargetNodeDirectory(List.of(PROVIDER)));
}
}

}
Loading

0 comments on commit 91cb441

Please sign in to comment.