forked from apache/nifi-minifi-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c43307d
commit be3b5b6
Showing
32 changed files
with
1,158 additions
and
300 deletions.
There are no files selected for viewing
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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
docker/test/integration/cluster/containers/KinesisServerContainer.py
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,41 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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 | ||
# | ||
# 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. | ||
|
||
|
||
import logging | ||
from .Container import Container | ||
|
||
|
||
class KinesisServerContainer(Container): | ||
def __init__(self, feature_context, name, vols, network, image_store, command): | ||
super().__init__(feature_context, name, 'kinesis-server', vols, network, image_store, command) | ||
|
||
def get_startup_finished_log_entry(self): | ||
return "Starting Kinesis Plain Mock Service on port 4568" | ||
|
||
def deploy(self): | ||
if not self.set_deployed(): | ||
return | ||
|
||
logging.info('Creating and running kinesis server docker container...') | ||
self.client.containers.run( | ||
self.image_store.get_image(self.get_engine()), | ||
detach=True, | ||
name=self.name, | ||
network=self.network.name, | ||
environment=["INITIALIZE_STREAMS=test_stream:3", | ||
"LOG_LEVEL=DEBUG"], | ||
entrypoint=self.command) | ||
logging.info('Added container \'%s\'', self.name) |
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
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,38 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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 | ||
# | ||
# 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. | ||
|
||
@ENABLE_AWS | ||
Feature: Sending data from MiNiFi-C++ to an AWS Kinesis server | ||
In order to transfer data to interact with AWS Kinesis server | ||
As a user of MiNiFi | ||
I need to have PutKinesisStream processor | ||
|
||
Background: | ||
Given the content of "/tmp/output" is monitored | ||
|
||
Scenario: A MiNiFi instance can send data to AWS Kinesis | ||
Given a GetFile processor with the "Input Directory" property set to "/tmp/input" | ||
And a file with the content "Schnappi, das kleine Krokodil" is present in "/tmp/input" | ||
And a PutKinesisStream processor set up to communicate with the kinesis server | ||
And a PutFile processor with the "Directory" property set to "/tmp/output" | ||
And the "success" relationship of the GetFile processor is connected to the PutKinesisStream | ||
And the "success" relationship of the PutKinesisStream processor is connected to the PutFile | ||
|
||
And a kinesis server is set up in correspondence with the PutKinesisStream | ||
|
||
When both instances start up | ||
|
||
Then a flowfile with the content "Schnappi, das kleine Krokodil" is placed in the monitored directory in less than 60 seconds | ||
And there is a record on the kinesis server with "Schnappi, das kleine Krokodil" |
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
42 changes: 42 additions & 0 deletions
42
docker/test/integration/minifi/processors/PutKinesisStream.py
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,42 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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 | ||
# | ||
# 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. | ||
|
||
|
||
from ..core.Processor import Processor | ||
|
||
|
||
class PutKinesisStream(Processor): | ||
def __init__( | ||
self, | ||
context, | ||
proxy_host='', | ||
proxy_port='', | ||
proxy_username='', | ||
proxy_password=''): | ||
super(PutKinesisStream, self).__init__( | ||
context=context, | ||
clazz='PutKinesisStream', | ||
properties={ | ||
'Amazon Kinesis Stream Name': 'test_stream', | ||
'Access Key': 'test_access_key', | ||
'Secret Key': 'test_secret', | ||
'Endpoint Override URL': f"http://kinesis-server-{context.feature_id}:4568", | ||
'Proxy Host': proxy_host, | ||
'Proxy Port': proxy_port, | ||
'Proxy Username': proxy_username, | ||
'Proxy Password': proxy_password, | ||
'Region': 'us-east-1' | ||
}, | ||
auto_terminate=["success", "failure"]) |
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,8 @@ | ||
FROM node:lts-alpine | ||
WORKDIR /app | ||
RUN npm i kinesis-local | ||
RUN npm i @aws-sdk/client-kinesis @aws-sdk/node-http-handler | ||
COPY server.json ./ | ||
COPY consumer ./consumer | ||
|
||
ENTRYPOINT npx kinesis-local |
64 changes: 64 additions & 0 deletions
64
docker/test/integration/resources/kinesis-mock/consumer/consumer.js
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,64 @@ | ||
import { KinesisClient, DescribeStreamCommand, GetShardIteratorCommand, GetRecordsCommand } from "@aws-sdk/client-kinesis"; | ||
import { NodeHttpHandler } from "@aws-sdk/node-http-handler"; | ||
|
||
const args = process.argv.slice(2); | ||
if (args.length === 0) { | ||
console.error("Usage: node consumer.js <search-string>"); | ||
process.exit(1); | ||
} | ||
|
||
const searchString = args[0]; | ||
const streamName = "test_stream"; | ||
|
||
const kinesis = new KinesisClient({ | ||
endpoint: "http://localhost:4568", | ||
region: "us-east-1", | ||
credentials: { accessKeyId: "fake", secretAccessKey: "fake" }, | ||
requestHandler: new NodeHttpHandler({ http2: false }), | ||
}); | ||
|
||
async function getShardIterator(shardId) { | ||
const command = new GetShardIteratorCommand({ | ||
StreamName: streamName, | ||
ShardId: shardId, | ||
ShardIteratorType: "TRIM_HORIZON", | ||
}); | ||
const response = await kinesis.send(command); | ||
return response.ShardIterator; | ||
} | ||
|
||
async function readShardRecords(shardId) { | ||
let shardIterator = await getShardIterator(shardId); | ||
const getRecordsCommand = new GetRecordsCommand({ ShardIterator: shardIterator }); | ||
const data = await kinesis.send(getRecordsCommand); | ||
|
||
return data.Records.map(r => Buffer.from(r.Data).toString().trim()); | ||
} | ||
|
||
async function readOnce() { | ||
try { | ||
console.log(`Checking stream '${streamName}' for: "${searchString}"`); | ||
|
||
const describeCommand = new DescribeStreamCommand({ StreamName: streamName }); | ||
const { StreamDescription } = await kinesis.send(describeCommand); | ||
|
||
for (let shard of StreamDescription.Shards) { | ||
console.log(`Reading from shard: ${shard.ShardId}`); | ||
|
||
const records = await readShardRecords(shard.ShardId); | ||
|
||
if (records.includes(searchString)) { | ||
console.log(`Found "${searchString}" in records.`); | ||
process.exit(0); | ||
} | ||
} | ||
|
||
console.log(`"${searchString}" not found in any shard.`); | ||
process.exit(-1); | ||
} catch (error) { | ||
console.error("Error reading stream:", error); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
readOnce(); |
3 changes: 3 additions & 0 deletions
3
docker/test/integration/resources/kinesis-mock/consumer/package.json
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,3 @@ | ||
{ | ||
"type": "module" | ||
} |
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,6 @@ | ||
{ | ||
"server": { | ||
"key": "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkw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