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

Remove consumer test related implementations #150

Merged
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- inconsistent messaging in SDCcc logs ("No problems were found" and "Test run was invalid" one after another.)
- incorrect behavior of the configuration option SDCcc.SummarizeMessageEncodingErrors

### Removed

- consumer test related implementations

## [9.0.0] - 2024-02-23

### Added
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,25 @@ all the given filter criteria have to be fulfilled for initiating a connection.
For example the configuration
```
[SDCcc.Consumer]
Enable=true
DeviceEpr="urn:uuid:857bf583-8a51-475f-a77f-d0ca7de69b11"
```
will make only those devices match during discovery that have the EPR "urn:uuid:857bf583-8a51-475f-a77f-d0ca7de69b11",
the configuration
```
[SDCcc.Consumer]
Enable=true
DeviceEpr="urn:uuid:857bf583-8a51-475f-a77f-d0ca7de69b11"
DeviceLocationBed="bed32"
```
only those that have the EPR "urn:uuid:857bf583-8a51-475f-a77f-d0ca7de69b11" and the bed "bed32" in the location query,
the configuration
```
[SDCcc.Consumer]
Enable=true
DeviceLocationBed="bed32"
```
only those that have the bed "bed32" in the location query,
and the configuration
```
[SDCcc.Consumer]
Enable=true
```
will make all devices match during discovery.

Expand Down
4 changes: 0 additions & 4 deletions configuration/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,11 @@ MaxWait=10
MulticastTTL=128

[SDCcc.Consumer]
Enable=true
DeviceEpr="urn:uuid:857bf583-8a51-475f-a77f-d0ca7de69b11"
# DeviceLocationBed="bed32"
# DeviceLocationPointOfCare="poc32"
# etc.

[SDCcc.Provider]
Enable=false

[SDCcc.gRPC]
ServerAddress="localhost:50051"

Expand Down
78 changes: 33 additions & 45 deletions sdccc/src/main/java/com/draeger/medical/sdccc/TestSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public class TestSuite {
* Used by the main injector to create a TestSuite instance.
* It is also useful for extending the TestSuite class.
*
* @param injector a reference to the injector injecting here
* @param testRunObserver observer for invalidating test runs
* @param sdcTestDirectories directories to search for test cases
* @param testRunDir directory to run the tests in and store artifacts
* @param injector a reference to the injector injecting here
* @param testRunObserver observer for invalidating test runs
* @param sdcTestDirectories directories to search for test cases
* @param testRunDir directory to run the tests in and store artifacts
* @param testExecutionLogging whether logging of test case starts etc. shall be done
* @param messageGenerator utility for generating messages to send
* @param testRunInformation utility where information of the test run is stored
* @param client client to use for direct tests
* @param messageGenerator utility for generating messages to send
* @param testRunInformation utility where information of the test run is stored
* @param client client to use for direct tests
*/
@Inject
public TestSuite(
Expand Down Expand Up @@ -165,13 +165,16 @@ public long runTestSuite() {
final SummaryGeneratingListener directSummary = new SummaryGeneratingListener();
directTestLauncher.registerTestExecutionListeners(directSummary);

final Boolean isConsumerEnabled = setupDeviceAndProvider();

long totalTestFailures = 0L;
/*
* Starting TestSuite Client and connect, check for an archive service of the DUT
*/
startClient();

/*
* Phase 1, generate messages
*/
phase1(isConsumerEnabled);
phase1();

/*
* Phase 2, execute direct tests
Expand All @@ -186,7 +189,7 @@ public long runTestSuite() {
/*
* Phase 4, invariant tests
*/
// stop client and provider now
// stop client now
totalTestFailures =
phase4(totalTestFailures, outWriter, invariantTestLauncher, invariantTestPlan, invariantSummary);

Expand Down Expand Up @@ -228,7 +231,6 @@ private long phase4(
} catch (final TimeoutException e) {
testRunObserver.invalidateTestRun("Could not stop the test client", e);
}
// TODO: Stop provider (https://github.com/Draegerwerk/SDCcc/issues/1)

// flush all data so invariant tests run on most current data
injector.getInstance(MessageStorage.class).flush();
Expand Down Expand Up @@ -273,10 +275,8 @@ private long phase2(
return totalTestFailures + directSummary.getSummary().getTotalFailureCount();
}

private void phase1(final Boolean isConsumerEnabled) {
if (isConsumerEnabled) {
performBasicMessagingCheck();
}
private void phase1() {
performBasicMessagingCheck();

try {
Thread.sleep(TIME_BETWEEN_PHASES);
Expand Down Expand Up @@ -365,34 +365,22 @@ private void performBasicMessagingCheck() {
LOG.info("SDC Basic Messaging Check completed" + statusline + ".");
}

private Boolean setupDeviceAndProvider() {
final var isConsumerEnabled =
injector.getInstance(Key.get(Boolean.class, Names.named(TestSuiteConfig.CONSUMER_ENABLE)));
final var isProviderEnabled =
injector.getInstance(Key.get(Boolean.class, Names.named(TestSuiteConfig.PROVIDER_ENABLE)));

if (isConsumerEnabled) {
LOG.info("Starting TestSuite Client");
try {
client.startService(MAX_WAIT);
client.connect();
} catch (final InterceptorException | TransportException | IOException | TimeoutException e) {
LOG.error("Could not connect to target device {}", client.getTargetEpr());
testRunObserver.invalidateTestRun("Could not connect to target device", e);
throw new RuntimeException(e);
}

// check the DUT for an archive service, currently needed for MDPWS:R0006
this.testRunInformation.setArchiveServicePresent(
client.getHostingServiceProxy().getHostedServices().values().stream()
.anyMatch(service ->
service.getType().getTypes().contains(WsdlConstants.PORT_TYPE_ARCHIVE_QNAME)));
}
if (isProviderEnabled) {
LOG.info("Starting TestSuite Provider");
// TODO: Start provider (https://github.com/Draegerwerk/SDCcc/issues/1)
private void startClient() {
LOG.info("Starting TestSuite Client");
try {
client.startService(MAX_WAIT);
client.connect();
} catch (final InterceptorException | TransportException | IOException | TimeoutException e) {
LOG.error("Could not connect to target device {}", client.getTargetEpr());
testRunObserver.invalidateTestRun("Could not connect to target device", e);
throw new RuntimeException(e);
}
return isConsumerEnabled;

// check the DUT for an archive service, currently needed for MDPWS:R0006
this.testRunInformation.setArchiveServicePresent(
client.getHostingServiceProxy().getHostedServices().values().stream()
.anyMatch(service ->
service.getType().getTypes().contains(WsdlConstants.PORT_TYPE_ARCHIVE_QNAME)));
}

/**
Expand Down Expand Up @@ -665,9 +653,9 @@ public static CommandLineOptions initialize(final String[] args) {
* Run the test suite with the given already parsed command line arguments and the
* specified enabled test config constants.
*
* @param cmdLine parsed command line arguments
* @param cmdLine parsed command line arguments
* @param enabledTestConfigClass class containing test identifier constants
* @param sdcTestDirectories directories to search for test cases
* @param sdcTestDirectories directories to search for test cases
*/
public static void runWithArgs(
final CommandLineOptions cmdLine,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ protected void defaultConfigure() {
configureTestSuite();
configureTLS();
configureNetwork();
configureProvider();
configureGRpc();
configureTestParameter();
configureInternalSettings();
Expand Down Expand Up @@ -79,10 +78,6 @@ void configureNetwork() {
bind(TestSuiteConfig.NETWORK_MULTICAST_TTL, long.class, 128L);
}

void configureProvider() {
bind(TestSuiteConfig.PROVIDER_ENABLE, Boolean.class, false);
}

void configureGRpc() {
bind(TestSuiteConfig.GRPC_SERVER_ADDRESS, String.class, "localhost:50051");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class TestSuiteConfig {
/*
* General configuration
*/
private static final String SDCCC = "SDCcc.";
public static final String SDCCC = "SDCcc.";
public static final String CI_MODE = SDCCC + "CIMode";
public static final String GRAPHICAL_POPUPS = SDCCC + "GraphicalPopups";
public static final String TEST_EXECUTION_LOGGING = SDCCC + "TestExecutionLogging";
Expand Down Expand Up @@ -49,7 +49,6 @@ public final class TestSuiteConfig {
* Consumer configuration
*/
private static final String CONSUMER = "Consumer.";
public static final String CONSUMER_ENABLE = SDCCC + CONSUMER + Constants.ENABLE_SETTING_POSTFIX;
public static final String CONSUMER_DEVICE_EPR = SDCCC + CONSUMER + Constants.DEVICE_EPR_POSTFIX;
public static final String CONSUMER_DEVICE_LOCATION_FACILITY = SDCCC + CONSUMER + "DeviceLocationFacility";
public static final String CONSUMER_DEVICE_LOCATION_BUILDING = SDCCC + CONSUMER + "DeviceLocationBuilding";
Expand All @@ -58,13 +57,6 @@ public final class TestSuiteConfig {
public static final String CONSUMER_DEVICE_LOCATION_ROOM = SDCCC + CONSUMER + "DeviceLocationRoom";
public static final String CONSUMER_DEVICE_LOCATION_BED = SDCCC + CONSUMER + "DeviceLocationBed";

/*
* Provider configuration
*/
private static final String PROVIDER = "Provider.";
public static final String PROVIDER_ENABLE = SDCCC + PROVIDER + Constants.ENABLE_SETTING_POSTFIX;
public static final String PROVIDER_DEVICE_EPR = SDCCC + PROVIDER + Constants.DEVICE_EPR_POSTFIX;

/*
* GRPC configuration
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
import com.draeger.medical.sdccc.manipulation.precondition.PreconditionRegistry;
import com.draeger.medical.sdccc.messages.HibernateConfig;
import com.draeger.medical.sdccc.sdcri.testclient.TestClient;
import com.draeger.medical.sdccc.sdcri.testprovider.TestProvider;
import com.draeger.medical.sdccc.sdcri.testprovider.TestProviderImpl;
import com.draeger.medical.sdccc.sdcri.testprovider.guice.ProviderFactory;
import com.draeger.medical.sdccc.tests.InjectorTestBase;
import com.draeger.medical.sdccc.util.HibernateConfigInMemoryImpl;
import com.draeger.medical.sdccc.util.TestRunObserver;
Expand All @@ -43,6 +40,10 @@
import com.google.inject.assistedinject.FactoryModuleBuilder;
import com.google.inject.util.Modules;
import it.com.draeger.medical.sdccc.test_util.SslMetadata;
import it.com.draeger.medical.sdccc.test_util.testprovider.TestProvider;
import it.com.draeger.medical.sdccc.test_util.testprovider.TestProviderConfig;
import it.com.draeger.medical.sdccc.test_util.testprovider.TestProviderImpl;
import it.com.draeger.medical.sdccc.test_util.testprovider.guice.ProviderFactory;
import it.com.draeger.medical.sdccc.testsuite_it_mock_tests.Identifiers;
import it.com.draeger.medical.sdccc.testsuite_it_mock_tests.WasRunObserver;
import java.io.File;
Expand Down Expand Up @@ -585,7 +586,6 @@ protected void defaultConfigure() {
bind(CryptoSettings.class).toInstance(cryptoSettings);

bind(TestSuiteConfig.CI_MODE, Boolean.class, true);
bind(TestSuiteConfig.CONSUMER_ENABLE, Boolean.class, true);
bind(TestSuiteConfig.CONSUMER_DEVICE_EPR, String.class, DUT_EPR);
bind(TestSuiteConfig.CONSUMER_DEVICE_LOCATION_FACILITY, String.class, this.locationConfig.facility);
bind(TestSuiteConfig.CONSUMER_DEVICE_LOCATION_BUILDING, String.class, this.locationConfig.building);
Expand All @@ -594,8 +594,7 @@ protected void defaultConfigure() {
bind(TestSuiteConfig.CONSUMER_DEVICE_LOCATION_ROOM, String.class, this.locationConfig.room);
bind(TestSuiteConfig.CONSUMER_DEVICE_LOCATION_BED, String.class, this.locationConfig.bed);

bind(TestSuiteConfig.PROVIDER_ENABLE, Boolean.class, true);
bind(TestSuiteConfig.PROVIDER_DEVICE_EPR, String.class, DUT_EPR);
bind(TestProviderConfig.PROVIDER_DEVICE_EPR, String.class, DUT_EPR);

bind(TestSuiteConfig.NETWORK_INTERFACE_ADDRESS, String.class, "127.0.0.1");
bind(DpwsConfig.MULTICAST_TTL, Integer.class, 128);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*/

package com.draeger.medical.sdccc.sdcri.testprovider;
package it.com.draeger.medical.sdccc.test_util.testprovider;

import com.google.inject.Injector;
import java.time.Duration;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This Source Code Form is subject to the terms of the MIT License.
* Copyright (c) 2023, 2024 Draegerwerk AG & Co. KGaA.
*
* SPDX-License-Identifier: MIT
*/

package it.com.draeger.medical.sdccc.test_util.testprovider;

import com.draeger.medical.sdccc.configuration.DefaultTestSuiteConfig;
import com.draeger.medical.sdccc.configuration.TestSuiteConfig;
import com.draeger.medical.sdccc.util.Constants;

/**
* Configuration of the SDCcc package.
*
* @see DefaultTestSuiteConfig
*/
public final class TestProviderConfig {

/*
* Provider configuration
*/
private static final String PROVIDER = "Provider.";
public static final String PROVIDER_DEVICE_EPR = TestSuiteConfig.SDCCC + PROVIDER + Constants.DEVICE_EPR_POSTFIX;

private TestProviderConfig() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*/

package com.draeger.medical.sdccc.sdcri.testprovider;
package it.com.draeger.medical.sdccc.test_util.testprovider;

import com.google.inject.Inject;
import org.somda.sdc.dpws.DpwsUtil;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*/

package com.draeger.medical.sdccc.sdcri.testprovider;
package it.com.draeger.medical.sdccc.test_util.testprovider;

import com.draeger.medical.sdccc.configuration.TestSuiteConfig;
import com.google.common.util.concurrent.AbstractIdleService;
Expand Down Expand Up @@ -39,7 +39,7 @@
import org.somda.sdc.glue.provider.sco.OperationInvocationReceiver;

/**
* SDCri provider used to test SDC consumers.
* SDCri provider used integration tests.
*/
public class TestProviderImpl extends AbstractIdleService implements TestProvider {
private static final Logger LOG = LogManager.getLogger();
Expand All @@ -54,7 +54,7 @@ public class TestProviderImpl extends AbstractIdleService implements TestProvide
@Inject
TestProviderImpl(
@Assisted final InputStream mdibAsStream,
@Named(TestSuiteConfig.PROVIDER_DEVICE_EPR) final String providerEpr,
@Named(TestProviderConfig.PROVIDER_DEVICE_EPR) final String providerEpr,
@Named(TestSuiteConfig.NETWORK_INTERFACE_ADDRESS) final String adapterAddress,
final TestProviderUtil testProviderUtil) {
this.injector = testProviderUtil.getInjector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* SPDX-License-Identifier: MIT
*/

package com.draeger.medical.sdccc.sdcri.testprovider;
package it.com.draeger.medical.sdccc.test_util.testprovider;

import com.draeger.medical.sdccc.configuration.TestSuiteConfig;
import com.draeger.medical.sdccc.messages.MessageStorage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* SPDX-License-Identifier: MIT
*/

package com.draeger.medical.sdccc.sdcri.testprovider.guice;
package it.com.draeger.medical.sdccc.test_util.testprovider.guice;

import com.draeger.medical.sdccc.sdcri.testprovider.TestProviderImpl;
import com.google.inject.assistedinject.Assisted;
import it.com.draeger.medical.sdccc.test_util.testprovider.TestProviderImpl;
import java.io.InputStream;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
* SDCcc test provider guice factory.
*/
@ParametersAreNonnullByDefault
package com.draeger.medical.sdccc.sdcri.testprovider.guice;
package it.com.draeger.medical.sdccc.test_util.testprovider.guice;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
* SDCcc test provider.
*/
@ParametersAreNonnullByDefault
package com.draeger.medical.sdccc.sdcri.testprovider;
package it.com.draeger.medical.sdccc.test_util.testprovider;

import javax.annotation.ParametersAreNonnullByDefault;
Loading