diff --git a/clients/export-client/export-api-spec.yaml b/clients/export-client/export-api-spec.yaml
index ea417e3885..e90520fd87 100644
--- a/clients/export-client/export-api-spec.yaml
+++ b/clients/export-client/export-api-spec.yaml
@@ -39,11 +39,7 @@ paths:
requestBody:
required: true
content:
- application/json:
- schema:
- type: string
- format: binary
- application/csv:
+ application/octet-stream:
schema:
type: string
format: binary
diff --git a/src/main/java/org/candlepin/subscriptions/capacity/CapacityIngressConfiguration.java b/src/main/java/org/candlepin/subscriptions/capacity/CapacityIngressConfiguration.java
index 03c9807a36..a057a6c3c5 100644
--- a/src/main/java/org/candlepin/subscriptions/capacity/CapacityIngressConfiguration.java
+++ b/src/main/java/org/candlepin/subscriptions/capacity/CapacityIngressConfiguration.java
@@ -21,7 +21,6 @@
package org.candlepin.subscriptions.capacity;
import org.candlepin.subscriptions.db.RhsmSubscriptionsDataSourceConfiguration;
-import org.candlepin.subscriptions.export.ExportConfiguration;
import org.candlepin.subscriptions.resteasy.ResteasyConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigurationExcludeFilter;
import org.springframework.boot.context.TypeExcludeFilter;
@@ -43,14 +42,11 @@
@Import({
ResteasyConfiguration.class,
RhsmSubscriptionsDataSourceConfiguration.class,
- ExportConfiguration.class
})
@ComponentScan(
basePackages = {
"org.candlepin.subscriptions.capacity",
"org.candlepin.subscriptions.product",
- "org.candlepin.subscriptions.export",
- "org.candlepin.subscriptions.subscription.export",
},
// Prevent TestConfiguration annotated classes from being picked up by ComponentScan
excludeFilters = {
diff --git a/src/main/resources/application-capacity-ingress.yaml b/src/main/resources/application-capacity-ingress.yaml
index 3525e8893e..39139b3497 100644
--- a/src/main/resources/application-capacity-ingress.yaml
+++ b/src/main/resources/application-capacity-ingress.yaml
@@ -1,15 +1,2 @@
-SUBSCRIPTION_EXPORT_TOPIC: ${clowder.kafka.topics."platform.export.requests".name:platform.export.requests}
-
-
rhsm-subscriptions:
- export-service:
- url: ${clowder.privateEndpoints.export-service-service.url:http://localhost:10000}
- truststore: ${clowder.privateEndpoints.export-service-service.trust-store-path}
- truststore-password: ${clowder.privateEndpoints.export-service-service.trust-store-password}
- truststore-type: ${clowder.privateEndpoints.export-service-service.trust-store-type}
- psk: ${SWATCH_EXPORT_PSK:placeholder}
subscription-sync-enabled: ${SUBSCRIPTION_SYNC_ENABLED:true}
- export:
- tasks:
- topic: ${SUBSCRIPTION_EXPORT_TOPIC}
- kafka-group-id: swatch-subscription-export
diff --git a/src/test/java/org/candlepin/subscriptions/export/BaseDataExporterServiceTest.java b/src/test/java/org/candlepin/subscriptions/export/BaseDataExporterServiceTest.java
index 7f43a49479..aab4c606a0 100644
--- a/src/test/java/org/candlepin/subscriptions/export/BaseDataExporterServiceTest.java
+++ b/src/test/java/org/candlepin/subscriptions/export/BaseDataExporterServiceTest.java
@@ -51,7 +51,7 @@
import org.candlepin.subscriptions.db.model.Offering;
import org.candlepin.subscriptions.db.model.ServiceLevel;
import org.candlepin.subscriptions.db.model.Usage;
-import org.candlepin.subscriptions.json.SubscriptionsExportJson;
+import org.candlepin.subscriptions.json.InstancesExportJson;
import org.candlepin.subscriptions.rbac.RbacApiException;
import org.candlepin.subscriptions.rbac.RbacService;
import org.candlepin.subscriptions.task.TaskQueueProperties;
@@ -193,7 +193,7 @@ protected void verifyNoRequestsWereSentToExportServiceWithUploadData() {
protected void verifyRequestWasSentToExportServiceWithNoDataFound() {
verifyRequestWasSentToExportServiceWithUploadData(
- request, toJson(new SubscriptionsExportJson().withData(new ArrayList<>())));
+ request, toJson(new InstancesExportJson().withData(new ArrayList<>())));
}
protected void updateOffering() {
diff --git a/src/test/java/org/candlepin/subscriptions/subscription/export/PerformanceSubscriptionDataExporterServiceIT.java b/src/test/java/org/candlepin/subscriptions/subscription/export/PerformanceSubscriptionDataExporterServiceIT.java
deleted file mode 100644
index 0570a239ab..0000000000
--- a/src/test/java/org/candlepin/subscriptions/subscription/export/PerformanceSubscriptionDataExporterServiceIT.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * Red Hat trademarks are not licensed under GPLv3. No permission is
- * granted to use or replicate Red Hat trademarks that are incorporated
- * in this software or its documentation.
- */
-package org.candlepin.subscriptions.subscription.export;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-import com.redhat.cloud.event.apps.exportservice.v1.Format;
-import com.redhat.swatch.configuration.util.MetricIdUtils;
-import java.time.Duration;
-import java.util.Map;
-import java.util.UUID;
-import org.candlepin.clock.ApplicationClock;
-import org.candlepin.subscriptions.db.model.BillingProvider;
-import org.candlepin.subscriptions.db.model.Subscription;
-import org.candlepin.subscriptions.db.model.SubscriptionMeasurementKey;
-import org.candlepin.subscriptions.export.BaseDataExporterServiceTest;
-import org.candlepin.subscriptions.test.ExtendWithSwatchDatabase;
-import org.hibernate.SessionFactory;
-import org.hibernate.StatelessSession;
-import org.hibernate.Transaction;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.ActiveProfiles;
-import org.testcontainers.shaded.org.awaitility.Awaitility;
-
-@Disabled
-@SpringBootTest(useMainMethod = SpringBootTest.UseMainMethod.ALWAYS)
-@ActiveProfiles(value = {"kafka-queue", "test-inventory", "capacity-ingress"})
-class PerformanceSubscriptionDataExporterServiceIT extends BaseDataExporterServiceTest
- implements ExtendWithSwatchDatabase {
-
- @Autowired SessionFactory sessionFactory;
- @Autowired ApplicationClock clock;
-
- @Override
- protected String resourceType() {
- return "subscriptions";
- }
-
- @BeforeEach
- @Override
- public void setup() {
- super.setup();
-
- StatelessSession session = sessionFactory.openStatelessSession();
- Transaction tx = session.beginTransaction();
- // According to https://github.com/RedHatInsights/rhsm-subscriptions/pull/3145,
- // the file size limit is reached when having 500k subscriptions, where
- // the following exception "RESTEASY005081: File limit of 50MB has been reached." is thrown.
- // To avoid this exception and un-limit the file size the client can handle,
- // we need to set the system property "dev.resteasy.entity.file.threshold" to "-1".
- // This setting is being done in org.candlepin.subscriptions.BootApplication.
- for (int num = 0; num < 500_000; num++) {
- session.insert(givenSubscriptionWithMeasurement());
- }
-
- tx.commit();
- session.close();
- }
-
- @Test
- void testLargeDataDealingWithRestEasyClientFileLimit() {
- givenExportRequestWithPermissions(Format.JSON);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- }
-
- private Subscription givenSubscriptionWithMeasurement() {
- Subscription subscription = new Subscription();
- subscription.setSubscriptionId(UUID.randomUUID().toString());
- subscription.setStartDate(clock.now());
- subscription.setOffering(offering);
- subscription.setOrgId(ORG_ID);
- subscription.setBillingProvider(BillingProvider.AWS);
- offering.getProductTags().clear();
- offering.getProductTags().add(RHEL_FOR_X86);
- updateOffering();
- subscription.setBillingAccountId("123");
- subscription.setSubscriptionMeasurements(
- Map.of(
- new SubscriptionMeasurementKey(MetricIdUtils.getCores().toString(), "HYPERVISOR"),
- 5.0));
- return subscription;
- }
-
- @Override
- protected void verifyRequestWasSentToExportService() {
- Awaitility.await()
- .atMost(Duration.ofMinutes(3))
- .untilAsserted(
- () -> {
- var calls =
- EXPORT_SERVICE_WIRE_MOCK_SERVER.findAll(
- postRequestedFor(
- urlEqualTo(
- String.format(
- "/app/export/v1/%s/subscriptions/%s/upload",
- request.getData().getResourceRequest().getExportRequestUUID(),
- request.getData().getResourceRequest().getUUID()))));
- assertEquals(1, calls.size());
- assertTrue(calls.get(0).getBody().length > 50_000_000);
- });
- }
-}
diff --git a/src/test/java/org/candlepin/subscriptions/subscription/export/SubscriptionDataExporterServiceTest.java b/src/test/java/org/candlepin/subscriptions/subscription/export/SubscriptionDataExporterServiceTest.java
deleted file mode 100644
index 1beca9981a..0000000000
--- a/src/test/java/org/candlepin/subscriptions/subscription/export/SubscriptionDataExporterServiceTest.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright Red Hat, Inc.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- *
- * Red Hat trademarks are not licensed under GPLv3. No permission is
- * granted to use or replicate Red Hat trademarks that are incorporated
- * in this software or its documentation.
- */
-package org.candlepin.subscriptions.subscription.export;
-
-import static com.redhat.swatch.export.ExportRequestHandler.MISSING_PERMISSIONS;
-import static org.candlepin.subscriptions.db.SubscriptionCapacityViewRepository.orgIdEquals;
-import static org.candlepin.subscriptions.subscription.export.SubscriptionDataExporterService.PRODUCT_ID;
-
-import com.redhat.cloud.event.apps.exportservice.v1.Format;
-import com.redhat.swatch.configuration.util.MetricIdUtils;
-import java.time.OffsetDateTime;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import org.candlepin.clock.ApplicationClock;
-import org.candlepin.subscriptions.db.SubscriptionCapacityViewRepository;
-import org.candlepin.subscriptions.db.SubscriptionRepository;
-import org.candlepin.subscriptions.db.model.BillingProvider;
-import org.candlepin.subscriptions.db.model.Subscription;
-import org.candlepin.subscriptions.db.model.SubscriptionCapacityView;
-import org.candlepin.subscriptions.db.model.SubscriptionMeasurementKey;
-import org.candlepin.subscriptions.export.BaseDataExporterServiceTest;
-import org.candlepin.subscriptions.json.SubscriptionsExportCsvItem;
-import org.candlepin.subscriptions.json.SubscriptionsExportJson;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.CsvSource;
-import org.junit.jupiter.params.provider.EnumSource;
-import org.junit.jupiter.params.provider.ValueSource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ActiveProfiles;
-
-@ActiveProfiles(value = {"kafka-queue", "test-inventory", "capacity-ingress"})
-class SubscriptionDataExporterServiceTest extends BaseDataExporterServiceTest {
-
- @Autowired SubscriptionRepository subscriptionRepository;
- @Autowired SubscriptionCapacityViewRepository subscriptionCapacityViewRepository;
- @Autowired ApplicationClock clock;
- @Autowired SubscriptionCsvDataMapperService csvDataMapperService;
- @Autowired SubscriptionJsonDataMapperService jsonDataMapperService;
-
- @AfterEach
- public void tearDown() {
- subscriptionRepository.deleteAll();
- }
-
- @Override
- protected String resourceType() {
- return "subscriptions";
- }
-
- @Test
- void testRequestWithoutPermissions() {
- givenExportRequestWithoutPermissions();
- whenReceiveExportRequest();
- verifyRequestWasSentToExportServiceWithError(request, MISSING_PERMISSIONS);
- }
-
- @Test
- void testRequestWithPermissions() {
- givenExportRequestWithPermissions(Format.JSON);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- }
-
- @Test
- void testRequestShouldBeUploadedWithSubscriptionsAsJson() {
- givenSubscriptionWithMeasurement(RHEL_FOR_X86);
- givenExportRequestWithPermissions(Format.JSON);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- }
-
- @Test
- void testRequestShouldBeUploadedWithSubscriptionsUsingPrometheusEnabledProductAsJson() {
- givenSubscriptionWithMeasurement(ROSA);
- givenExportRequestWithPermissions(Format.JSON);
- givenFilterInExportRequest(PRODUCT_ID, ROSA);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- }
-
- @Test
- void testRequestShouldBeUploadedWithSubscriptionsAsCsv() {
- givenSubscriptionWithMeasurement(RHEL_FOR_X86);
- givenExportRequestWithPermissions(Format.CSV);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- }
-
- @ParameterizedTest
- @EnumSource(value = Format.class)
- void testGivenDuplicateSubscriptionsThenItReturnsOnlyOneRecordAndCapacityIsSum(Format format) {
- givenSubscriptionWithMeasurement(RHEL_FOR_X86);
- givenSameSubscriptionWithOtherMeasurement();
- givenExportRequestWithPermissions(format);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- }
-
- @ParameterizedTest
- @CsvSource(
- value = {
- PRODUCT_ID + "," + RHEL_FOR_X86,
- "usage,production",
- "category,hypervisor",
- "sla,premium",
- "metric_id,Cores",
- "billing_provider,aws",
- "billing_account_id,123"
- })
- void testFiltersFoundData(String filterName, String exists) {
- givenSubscriptionWithMeasurement(RHEL_FOR_X86);
- givenExportRequestWithPermissions(Format.JSON);
- givenFilterInExportRequest(filterName, exists);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- verifyNoRequestsWereSentToExportServiceWithError();
- }
-
- @ParameterizedTest
- @CsvSource(
- value = {
- PRODUCT_ID + "," + ROSA,
- "usage,disaster recovery",
- "category,cloud",
- "sla,standard",
- "metric_id,Sockets",
- "billing_provider,azure",
- "billing_account_id,345"
- })
- void testFiltersDoesNotFoundDataAndReportIsEmpty(String filterName, String doesNotExist) {
- givenSubscriptionWithMeasurement(RHEL_FOR_X86);
- givenExportRequestWithPermissions(Format.JSON);
- givenFilterInExportRequest(filterName, doesNotExist);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportServiceWithNoDataFound();
- verifyNoRequestsWereSentToExportServiceWithError();
- }
-
- @ParameterizedTest
- @ValueSource(strings = {PRODUCT_ID, "usage", "category", "sla", "metric_id", "billing_provider"})
- void testFiltersAreInvalid(String filterName) {
- givenSubscriptionWithMeasurement(RHEL_FOR_X86);
- givenExportRequestWithPermissions(Format.JSON);
- givenFilterInExportRequest(filterName, "wrong!");
- whenReceiveExportRequest();
- verifyNoRequestsWereSentToExportServiceWithUploadData();
- verifyRequestWasSentToExportServiceWithError(request);
- }
-
- @Test
- void testRequestShouldFilterByOrgId() {
- givenSubscriptionWithMeasurementForAnotherOrgId(RHEL_FOR_X86);
- givenSubscriptionWithMeasurement(RHEL_FOR_X86);
- givenExportRequestWithPermissions(Format.JSON);
- whenReceiveExportRequest();
- verifyRequestWasSentToExportService();
- }
-
- @Override
- protected void verifyRequestWasSentToExportService() {
- boolean isCsvFormat = request.getData().getResourceRequest().getFormat() == Format.CSV;
- List