-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolving conflict and fixing spotbugs and checkstyle
Signed-off-by: Amit-Singh40 <[email protected]>
- Loading branch information
Showing
6 changed files
with
197 additions
and
1 deletion.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...or-collector/src/test/java/io/pravega/sensor/collector/PravegaSensorCollectorAppTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.pravega.sensor.collector; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
class PravegaSensorCollectorAppTest { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(PravegaSensorCollectorAppTest.class); | ||
|
||
@Test | ||
public void testPravegaSensorCollector() { | ||
PravegaSensorCollectorApp app = new PravegaSensorCollectorApp(); | ||
Assertions.assertNotNull(app.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...ensor-collector/src/test/java/io/pravega/sensor/collector/file/MockFileIngestService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.pravega.sensor.collector.file; | ||
|
||
import io.pravega.sensor.collector.DeviceDriverConfig; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class MockFileIngestService extends FileIngestService { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(MockFileIngestService.class); | ||
public MockFileIngestService(DeviceDriverConfig config) { | ||
super(config); | ||
} | ||
|
||
/* | ||
* Mocking the behaviour of create stream | ||
*/ | ||
@Override | ||
protected void createStream(String scopeName, String streamName) { | ||
LOGGER.info("Do nothing for create stream"); | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
pravega-sensor-collector/src/test/java/io/pravega/sensor/collector/util/TestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
*/ | ||
package io.pravega.sensor.collector.util; | ||
|
||
import io.pravega.sensor.collector.DeviceDriverConfig; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
/** | ||
* Class to contain convenient utilities for writing test cases. | ||
*/ | ||
public final class TestUtils { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(TestUtils.class); | ||
private static final String CLASS_KEY = "CLASS"; | ||
protected DeviceDriverConfig config; | ||
|
||
/* | ||
* Utility method that returns a list of DeviceDriverConfig instances from key/value properties. | ||
* It removes the prefix read from properties file. | ||
* */ | ||
public static Map<String, String> configFromProperties(String prefix, String sep, Map<String, String> properties) { | ||
Map<String, String> instanceProperties = new HashMap<>(); | ||
// Find instance names. | ||
final List<String> instanceNames = properties.keySet().stream().flatMap(key -> { | ||
if (key.startsWith(prefix) && key.endsWith(sep + CLASS_KEY)) { | ||
return Stream.of(key.substring(prefix.length(), key.length() - CLASS_KEY.length() - sep.length())); | ||
} | ||
return Stream.empty(); | ||
}).collect(Collectors.toList()); | ||
LOGGER.info("configFromProperties: instanceNames={}", instanceNames); | ||
// Copy properties with prefix to keys without a prefix. | ||
String instanceName = instanceNames.get(0); | ||
|
||
for (Map.Entry<String, String> e : properties.entrySet()) { | ||
final String key = e.getKey(); | ||
final String instancePrefix = prefix + instanceName + sep; | ||
if (key.startsWith(instancePrefix)) { | ||
LOGGER.info("key" + key.substring(instancePrefix.length()) + " value " + e.getValue()); | ||
instanceProperties.put(key.substring(instancePrefix.length()), e.getValue()); | ||
} else if (key.startsWith(prefix)) { | ||
instanceProperties.put(key.substring(prefix.length()), e.getValue()); | ||
} | ||
//LOGGER.info("configFromProperties: instanceProperties={}", instanceProperties); | ||
} | ||
LOGGER.info("configFromProperties: instanceProperties={}", instanceProperties); | ||
return instanceProperties; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
pravega-sensor-collector/src/test/resources/RawFileIngestService.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
# | ||
# Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# This file can be used to manually test RawFileIngestService. | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_CLASS=io.pravega.sensor.collector.file.rawfile.RawFileIngestService | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_PERSISTENT_QUEUE_FILE=/tmp/accel1.db | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_FILE_SPEC=../parquet-file-sample-data/test | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_FILE_EXTENSION=parquet | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_DATABASE_FILE=./test.db | ||
#PRAVEGA_SENSOR_COLLECTOR_RAW1_PRAVEGA_CONTROLLER_URI=tls://pravega-controller.texas-twister.ns.sdp.hop.lab.emc.com:443 | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_PRAVEGA_CONTROLLER_URI=tcp://127.0.0.1:9090 | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_SCOPE=test-psc | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_STREAM=test-psc-stream | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_ROUTING_KEY=$(hostname) | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_DELETE_COMPLETED_FILES=true | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_TRANSACTION_TIMEOUT_MINUTES=1.0 | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_CREATE_SCOPE=true | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_MIN_TIME_IN_MILLIS_TO_UPDATE_FILE=5000 | ||
PRAVEGA_SENSOR_COLLECTOR_RAW1_DELETE_COMPLETED_FILES_INTERVAL_IN_SECONDS=15 |