use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method test_SchedulerStartTaskCallback_StartRecordingJob.
@Test
public void test_SchedulerStartTaskCallback_StartRecordingJob(@TempDir Path tempDir) throws IOException, InterruptedException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).captureStartTime("").liveStreamingStartTime("").videoRecordFolderPath(tempDir).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
Thread.sleep(3000);
edgeConnectorForKVSConfiguration.setRecordingRequestsCount(2);
edgeConnectorForKVSService.schedulerStartTaskCallback(Constants.JobType.LOCAL_VIDEO_CAPTURE, MOCK_KINESIS_VIDEO_STREAM_NAME);
Thread.sleep(1000);
// verify
assertNotNull(edgeConnectorForKVSConfiguration.videoUploader);
assertNotNull(edgeConnectorForKVSConfiguration.inputStream);
assertEquals(3, edgeConnectorForKVSConfiguration.getRecordingRequestsCount());
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class EdgeConnectorForKVSServiceTest method testInitVideoRecorders.
@Test
public void testInitVideoRecorders(@TempDir Path tempDir) throws IOException, InterruptedException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = new ArrayList();
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(MOCK_KINESIS_VIDEO_STREAM_NAME).liveStreamingStartTime(LIVE_STREAMING_START_TIME).liveStreamingDurationInMinutes(LIVE_STREAMING_DURATION_IN_MINUTES).captureStartTime(START_TIME_ALWAYS).videoRecordFolderPath(tempDir).build();
edgeConnectorForKVSConfigurationList.add(edgeConnectorForKVSConfiguration);
// Mock for initConfiguration
when(siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(any())).thenReturn(edgeConnectorForKVSConfigurationList);
// Mock for initSecretsManager
when(secretsClient.getSecretValue(any())).thenReturn(gson.toJson(secretMap));
// then
edgeConnectorForKVSService.setUpSharedEdgeConnectorForKVSService();
edgeConnectorForKVSService.setUpCameraLevelEdgeConnectorForKVSService(edgeConnectorForKVSConfiguration);
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class JobSchedulerTest method stop_singleCamera_stopsScheduler.
@Test
public void stop_singleCamera_stopsScheduler() throws SchedulerException {
// mock
EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = EdgeConnectorForKVSConfiguration.builder().kinesisVideoStreamName(STREAM_NAME).build();
JobDetail recorderJobDetail = newJob(StartJob.class).withIdentity(STREAM_NAME, Constants.JobType.LOCAL_VIDEO_CAPTURE.name() + "_START").build();
JobDetail uploaderJobDetail = newJob(StartJob.class).withIdentity(STREAM_NAME, Constants.JobType.LIVE_VIDEO_STREAMING.name() + "_START").build();
JobKey recorderJobKey = recorderJobDetail.getKey();
JobKey uploaderJobKey = uploaderJobDetail.getKey();
// when
when(schedulerFactory.getScheduler()).thenReturn(scheduler);
when(scheduler.checkExists(recorderJobKey)).thenReturn(true);
when(scheduler.checkExists(uploaderJobKey)).thenReturn(true);
when(scheduler.deleteJob(recorderJobKey)).thenReturn(true);
when(scheduler.deleteJob(uploaderJobKey)).thenReturn(true);
// then
jobScheduler.stop(edgeConnectorForKVSConfiguration);
// verify
verify(scheduler, times(1)).checkExists(recorderJobKey);
verify(scheduler, times(1)).checkExists(uploaderJobKey);
verify(scheduler, times(1)).deleteJob(recorderJobKey);
verify(scheduler, times(1)).deleteJob(uploaderJobKey);
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class SiteWiseManagerTest method testInitEdgeConnectorForKVSServiceConfiguration.
@Test
public void testInitEdgeConnectorForKVSServiceConfiguration() {
// when
when(siteWiseClient.isAssetInheritedFromAssetModel(anyString(), anyString())).thenReturn(true);
when(siteWiseClient.describeAsset(anyString())).thenReturn(describeAssetResponse);
when(siteWiseClient.listAssociatedAssets(anyString())).thenReturn(cameraSiteWiseAssetIdList);
when(siteWiseClient.getAssetPropertyValue(anyString(), eq(generateSiteWisePropertyId(SITE_WISE_CAMERA_MODEL_KINESIS_VIDEO_STREAM_NAME)))).thenReturn(GetAssetPropertyValueResponse.builder().propertyValue(AssetPropertyValue.builder().value(Variant.builder().stringValue(generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_KINESIS_VIDEO_STREAM_NAME)).build()).build()).build());
when(siteWiseClient.getAssetPropertyValue(anyString(), eq(generateSiteWisePropertyId(SITE_WISE_CAMERA_MODEL_RTSP_STREAM_URL)))).thenReturn(GetAssetPropertyValueResponse.builder().propertyValue(AssetPropertyValue.builder().value(Variant.builder().stringValue(generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_RTSP_STREAM_URL)).build()).build()).build());
when(siteWiseClient.getAssetPropertyValue(anyString(), eq(generateSiteWisePropertyId(SITE_WISE_CAMERA_MODEL_LIVE_STREAMING_START_TIME)))).thenReturn(GetAssetPropertyValueResponse.builder().propertyValue(AssetPropertyValue.builder().value(Variant.builder().stringValue(generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_LIVE_STREAMING_START_TIME)).build()).build()).build());
when(siteWiseClient.getAssetPropertyValue(anyString(), eq(generateSiteWisePropertyId(SITE_WISE_CAMERA_MODEL_LIVE_STREAMING_DURATION_IN_MINUTES)))).thenReturn(GetAssetPropertyValueResponse.builder().propertyValue(AssetPropertyValue.builder().value(Variant.builder().integerValue(liveStreamingDurationInMinutes).build()).build()).build());
when(siteWiseClient.getAssetPropertyValue(anyString(), eq(generateSiteWisePropertyId(SITE_WISE_CAMERA_MODEL_LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES)))).thenReturn(GetAssetPropertyValueResponse.builder().propertyValue(AssetPropertyValue.builder().value(Variant.builder().integerValue(localDataRetentionPeriodInMinutes).build()).build()).build());
when(siteWiseClient.getAssetPropertyValue(anyString(), eq(generateSiteWisePropertyId(SITE_WISE_CAMERA_MODEL_CAPTURE_START_TIME)))).thenReturn(GetAssetPropertyValueResponse.builder().propertyValue(AssetPropertyValue.builder().value(Variant.builder().stringValue(generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_CAPTURE_START_TIME)).build()).build()).build());
when(siteWiseClient.getAssetPropertyValue(anyString(), eq(generateSiteWisePropertyId(SITE_WISE_CAMERA_MODEL_CAPTURE_DURATION_IN_MINUTES)))).thenReturn(GetAssetPropertyValueResponse.builder().propertyValue(AssetPropertyValue.builder().value(Variant.builder().integerValue(captureDurationInMinutes).build()).build()).build());
// then
List<EdgeConnectorForKVSConfiguration> result = siteWiseManager.initEdgeConnectorForKVSServiceConfiguration(MOCK_HUB_DEVICE_SITE_WISE_ASSET_ID);
// verify
EdgeConnectorForKVSConfiguration configuration = result.get(0);
assertEquals(configuration.getKinesisVideoStreamName(), generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_KINESIS_VIDEO_STREAM_NAME));
assertEquals(configuration.getRtspStreamURL(), generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_RTSP_STREAM_URL));
assertEquals(configuration.getLiveStreamingStartTime(), generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_LIVE_STREAMING_START_TIME));
assertEquals(configuration.getLiveStreamingDurationInMinutes(), liveStreamingDurationInMinutes);
assertEquals(configuration.getLocalDataRetentionPeriodInMinutes(), localDataRetentionPeriodInMinutes);
assertEquals(configuration.getCaptureStartTime(), generateSiteWisePropertyValue(SITE_WISE_CAMERA_MODEL_CAPTURE_START_TIME));
assertEquals(configuration.getCaptureDurationInMinutes(), captureDurationInMinutes);
assertEquals(configuration.getVideoUploadedTimeRangePropertyId(), generateSiteWisePropertyId(SITE_WISE_VIDEO_UPLOADED_TIME_RANGE_MEASUREMENT_NAME));
assertEquals(configuration.getVideoRecordedTimeRangePropertyId(), generateSiteWisePropertyId(SITE_WISE_VIDEO_RECORDED_TIME_RANGE_MEASUREMENT_NAME));
assertEquals(configuration.getCachedVideoAgeOutOnEdgePropertyId(), generateSiteWisePropertyId(SITE_WISE_CACHED_VIDEO_AGE_OUT_ON_EDGE_MEASUREMENT_NAME));
}
use of com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.
the class DiskManagerTest method testWatchService_File_Creation_Case.
@Test
public void testWatchService_File_Creation_Case(@TempDir Path tempDir) throws InterruptedException, IOException {
// when
List<EdgeConnectorForKVSConfiguration> edgeConnectorForKVSConfigurationList = Collections.singletonList(EdgeConnectorForKVSConfiguration.builder().videoRecordFolderPath(tempDir).localDataRetentionPeriodInMinutes(LOCAL_DATA_RETENTION_PERIOD_IN_MINUTES).build());
List<WatchEvent<?>> events = new ArrayList<>();
testWatchEventCallBack = new TestWatchEventCallBack(events);
diskManager = new DiskManager(edgeConnectorForKVSConfigurationList, diskManagerUtil, watchServiceExecutor, fileCleanerService, testWatchEventCallBack);
// then
diskManager.setupDiskManagerThread();
Thread.sleep(3000);
filePath = tempDir.resolve(FILE_NAME);
Files.write(filePath, Collections.singletonList(MOCK_VALUE));
// verify
synchronized (events) {
int i = 0;
while (events.size() < 1 && i < testRepeatTimes) {
events.wait(3000);
i++;
}
assertEquals(1, events.size());
}
}
Aggregations