-
Notifications
You must be signed in to change notification settings - Fork 99
MINIFICPP-2679 Move HTTP tests to modular docker tests #2077
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
Open
lordgamez
wants to merge
1
commit into
apache:MINIFICPP-2682
Choose a base branch
from
lordgamez:MINIFICPP-2679
base: MINIFICPP-2682
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
89 changes: 89 additions & 0 deletions
89
behave_framework/src/minifi_test_framework/containers/nifi_container.py
This file contains hidden or 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,89 @@ | ||
| # 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 io | ||
| import gzip | ||
| from typing import List, Optional | ||
| from minifi_test_framework.containers.file import File | ||
| from minifi_test_framework.containers.container import Container | ||
| from minifi_test_framework.core.helpers import wait_for_condition | ||
| from minifi_test_framework.core.minifi_test_context import MinifiTestContext | ||
| from minifi_test_framework.minifi.nifi_flow_definition import NifiFlowDefinition | ||
|
|
||
|
|
||
| class NifiContainer(Container): | ||
| NIFI_VERSION = '2.2.0' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we update this to the latest version? Should be 2.7.1 soon |
||
|
|
||
| def __init__(self, test_context: MinifiTestContext, command: Optional[List[str]] = None, use_ssl: bool = False): | ||
| self.flow_definition = NifiFlowDefinition() | ||
| name = f"nifi-{test_context.scenario_id}" | ||
| if use_ssl: | ||
| entry_command = (r"sed -i -e 's/^\(nifi.remote.input.host\)=.*/\1={name}/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.remote.input.secure\)=.*/\1=true/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.sensitive.props.key\)=.*/\1=secret_key_12345/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.web.https.port\)=.*/\1=8443/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.web.https.host\)=.*/\1={name}/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keystore\)=.*/\1=\/tmp\/resources\/keystore.jks/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keystoreType\)=.*/\1=jks/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keystorePasswd\)=.*/\1=passw0rd1!/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keyPasswd\)=.*/#\1=passw0rd1!/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.truststore\)=.*/\1=\/tmp\/resources\/truststore.jks/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.truststoreType\)=.*/\1=jks/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.truststorePasswd\)=.*/\1=passw0rd1!/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.remote.input.socket.port\)=.*/\1=10443/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
|
Comment on lines
+33
to
+45
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be a single |
||
| r"cp /tmp/nifi_config/flow.json.gz /opt/nifi/nifi-current/conf && /opt/nifi/nifi-current/bin/nifi.sh run & " | ||
| r"nifi_pid=$! &&" | ||
| r"tail -F --pid=${{nifi_pid}} /opt/nifi/nifi-current/logs/nifi-app.log").format(name=name) | ||
| else: | ||
| entry_command = (r"sed -i -e 's/^\(nifi.remote.input.host\)=.*/\1={name}/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.sensitive.props.key\)=.*/\1=secret_key_12345/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.remote.input.secure\)=.*/\1=false/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.web.http.port\)=.*/\1=8080/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.web.https.port\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.web.https.host\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.web.http.host\)=.*/\1={name}/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keystore\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keystoreType\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keystorePasswd\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.keyPasswd\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.truststore\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.truststoreType\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.security.truststorePasswd\)=.*/\1=/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"sed -i -e 's/^\(nifi.remote.input.socket.port\)=.*/\1=10000/' /opt/nifi/nifi-current/conf/nifi.properties && " | ||
| r"cp /tmp/nifi_config/flow.json.gz /opt/nifi/nifi-current/conf && /opt/nifi/nifi-current/bin/nifi.sh run & " | ||
| r"nifi_pid=$! &&" | ||
| r"tail -F --pid=${{nifi_pid}} /opt/nifi/nifi-current/logs/nifi-app.log").format(name=name) | ||
| if not command: | ||
| command = ["/bin/sh", "-c", entry_command] | ||
|
|
||
| super().__init__("apache/nifi:" + self.NIFI_VERSION, name, test_context.network, entrypoint=command) | ||
|
|
||
| def deploy(self): | ||
| flow_config = self.flow_definition.to_json() | ||
| buffer = io.BytesIO() | ||
|
|
||
| with gzip.GzipFile(fileobj=buffer, mode='wb') as gz_file: | ||
| gz_file.write(flow_config.encode()) | ||
|
|
||
| gzipped_bytes = buffer.getvalue() | ||
| self.files.append(File("/tmp/nifi_config/flow.json.gz", gzipped_bytes)) | ||
|
|
||
| super().deploy() | ||
| finished_str = "Started Application in" | ||
| return wait_for_condition( | ||
| condition=lambda: finished_str in self.get_logs(), | ||
| timeout_seconds=300, | ||
| bail_condition=lambda: self.exited, | ||
| context=None) | ||
This file contains hidden or 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
63 changes: 63 additions & 0 deletions
63
behave_framework/src/minifi_test_framework/minifi/minifi_flow_definition.py
This file contains hidden or 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,63 @@ | ||
| # | ||
| # 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 yaml | ||
|
|
||
| from .flow_definition import FlowDefinition | ||
|
|
||
|
|
||
| class MinifiFlowDefinition(FlowDefinition): | ||
| def __init__(self, flow_name: str = "MiNiFi Flow"): | ||
| super().__init__(flow_name) | ||
|
|
||
| def to_yaml(self) -> str: | ||
| """Serializes the entire flow definition into the MiNiFi YAML format.""" | ||
|
|
||
| # Create a quick lookup map of processor names to their objects | ||
| # This is crucial for finding the source/destination IDs for connections | ||
| processors_by_name = {p.name: p for p in self.processors} | ||
| funnels_by_name = {f.name: f for f in self.funnels} | ||
|
|
||
| connectables_by_name = {**processors_by_name, **funnels_by_name} | ||
|
|
||
| if len(self.parameter_contexts) > 0: | ||
| parameter_context_name = self.parameter_contexts[0].name | ||
| else: | ||
| parameter_context_name = '' | ||
| # Build the final dictionary structure | ||
| config = {'MiNiFi Config Version': 3, 'Flow Controller': {'name': self.flow_name}, | ||
| 'Parameter Contexts': [p.to_yaml_dict() for p in self.parameter_contexts], | ||
| 'Processors': [p.to_yaml_dict() for p in self.processors], | ||
| 'Funnels': [f.to_yaml_dict() for f in self.funnels], 'Connections': [], | ||
| 'Controller Services': [c.to_yaml_dict() for c in self.controller_services], | ||
| 'Remote Processing Groups': [], 'Parameter Context Name': parameter_context_name} | ||
|
|
||
| # Build the connections list by looking up processor IDs | ||
| for conn in self.connections: | ||
| source_proc = connectables_by_name.get(conn.source_name) | ||
| dest_proc = connectables_by_name.get(conn.target_name) | ||
|
|
||
| if not source_proc or not dest_proc: | ||
| raise ValueError( | ||
| f"Could not find processors for connection from '{conn.source_name}' to '{conn.target_name}'") | ||
|
|
||
| config['Connections'].append( | ||
| {'name': f"{conn.source_name}/{conn.source_relationship}/{conn.target_name}", 'id': conn.id, | ||
| 'source id': source_proc.id, 'source relationship name': conn.source_relationship, | ||
| 'destination id': dest_proc.id}) | ||
|
|
||
| return yaml.dump(config, sort_keys=False, indent=2, width=120) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should do it in one command, and the size filtering can be removed from below. Also I don't think wrapping in
sh -cis necessary, but I've raised comment this in an earlier PR too