Skip to content

Commit 2da8c20

Browse files
committed
MINIFICPP-2711 Docker tests, missing logs if container fails to start #2099
1 parent d439b84 commit 2da8c20

File tree

28 files changed

+73
-66
lines changed

28 files changed

+73
-66
lines changed

behave_framework/src/minifi_test_framework/containers/container.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616
#
17+
from __future__ import annotations
18+
from typing import TYPE_CHECKING
19+
1720
import json
1821
import logging
1922
import os
@@ -28,6 +31,9 @@
2831
from minifi_test_framework.containers.file import File
2932
from minifi_test_framework.containers.host_file import HostFile
3033

34+
if TYPE_CHECKING:
35+
from minifi_test_framework.core.minifi_test_context import MinifiTestContext
36+
3137

3238
class Container:
3339
def __init__(self, image_name: str, container_name: str, network: Network, command: str | None = None, entrypoint: str | None = None):
@@ -74,7 +80,7 @@ def _configure_volumes_of_container_dirs(self):
7480
self._write_content_to_file(file_path, None, content)
7581
self.volumes[temp_path] = {"bind": directory.path, "mode": directory.mode}
7682

77-
def deploy(self) -> bool:
83+
def deploy(self, context: MinifiTestContext | None) -> bool:
7884
self._temp_dir = tempfile.TemporaryDirectory()
7985
self._configure_volumes_of_container_files()
8086
self._configure_volumes_of_container_dirs()

behave_framework/src/minifi_test_framework/containers/http_proxy_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ def __init__(self, test_context: MinifiTestContext):
4646

4747
super().__init__("minifi-http-proxy:latest", f"http-proxy-{test_context.scenario_id}", test_context.network)
4848

49-
def deploy(self):
50-
super().deploy()
49+
def deploy(self, context: MinifiTestContext | None) -> bool:
50+
super().deploy(context)
5151
finished_str = "Accepting HTTP Socket connections at"
5252
return wait_for_condition(
5353
condition=lambda: finished_str in self.get_logs(),
5454
timeout_seconds=5,
5555
bail_condition=lambda: self.exited,
56-
context=None
56+
context=context
5757
)
5858

5959
def check_http_proxy_access(self, url):

behave_framework/src/minifi_test_framework/containers/minifi_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def __init__(self, container_name: str, test_context: MinifiTestContext):
5959
self._fill_default_properties()
6060
self._fill_default_log_properties()
6161

62-
def deploy(self) -> bool:
62+
def deploy(self, context: MinifiTestContext | None) -> bool:
6363
flow_config = self.flow_definition.to_yaml()
6464
logging.info(f"Deploying MiNiFi container '{self.container_name}' with flow configuration:\n{flow_config}")
6565
if self.is_fhs:
@@ -77,15 +77,15 @@ def deploy(self) -> bool:
7777
resource_dir = Path(__file__).resolve().parent / "resources" / "minifi-controller"
7878
self.host_files.append(HostFile("/tmp/resources/minifi-controller/config.yml", os.path.join(resource_dir, "config.yml")))
7979

80-
if not super().deploy():
80+
if not super().deploy(context):
8181
return False
8282

8383
finished_str = "MiNiFi started"
8484
return wait_for_condition(
8585
condition=lambda: finished_str in self.get_logs(),
8686
timeout_seconds=15,
8787
bail_condition=lambda: self.exited,
88-
context=None)
88+
context=context)
8989

9090
def set_property(self, key: str, value: str):
9191
self.properties[key] = value

behave_framework/src/minifi_test_framework/containers/nifi_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def __init__(self, test_context: MinifiTestContext, command: Optional[List[str]]
7070

7171
super().__init__("apache/nifi:" + self.NIFI_VERSION, name, test_context.network, entrypoint=command)
7272

73-
def deploy(self):
73+
def deploy(self, context: MinifiTestContext | None) -> bool:
7474
flow_config = self.flow_definition.to_json()
7575
buffer = io.BytesIO()
7676

@@ -80,10 +80,10 @@ def deploy(self):
8080
gzipped_bytes = buffer.getvalue()
8181
self.files.append(File("/tmp/nifi_config/flow.json.gz", gzipped_bytes))
8282

83-
super().deploy()
83+
super().deploy(context)
8484
finished_str = "Started Application in"
8585
return wait_for_condition(
8686
condition=lambda: finished_str in self.get_logs(),
8787
timeout_seconds=300,
8888
bail_condition=lambda: self.exited,
89-
context=None)
89+
context=context)

behave_framework/src/minifi_test_framework/steps/core_steps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@
3636
@when("all instances start up")
3737
def step_impl(context: MinifiTestContext):
3838
for container in context.containers.values():
39-
assert container.deploy() or container.log_app_output()
39+
assert container.deploy(context)
4040
logging.debug("All instances started up")
4141

4242

4343
@when("the MiNiFi instance starts up")
4444
def step_impl(context: MinifiTestContext):
45-
assert context.get_or_create_default_minifi_container().deploy()
45+
assert context.get_or_create_default_minifi_container().deploy(context)
4646
logging.debug("MiNiFi instance started up")
4747

4848

extensions/aws/tests/features/steps/kinesis_server_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ def __init__(self, test_context: MinifiTestContext):
3434
self.environment.append("INITIALIZE_STREAMS=test_stream:3")
3535
self.environment.append("LOG_LEVEL=DEBUG")
3636

37-
def deploy(self):
38-
super().deploy()
37+
def deploy(self, context: MinifiTestContext | None) -> bool:
38+
super().deploy(context)
3939
finished_str = "Starting Kinesis Plain Mock Service on port 4568"
4040
return wait_for_condition(
4141
condition=lambda: finished_str in self.get_logs(),
4242
timeout_seconds=300,
4343
bail_condition=lambda: self.exited,
44-
context=None)
44+
context=context)
4545

4646
@retry_check()
4747
def check_kinesis_server_record_data(self, record_data):

extensions/aws/tests/features/steps/s3_server_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ def __init__(self, test_context: MinifiTestContext):
2626
super().__init__("adobe/s3mock:3.12.0", f"s3-server-{test_context.scenario_id}", test_context.network)
2727
self.environment.append("initialBuckets=test_bucket")
2828

29-
def deploy(self):
30-
super().deploy()
29+
def deploy(self, context: MinifiTestContext | None) -> bool:
30+
super().deploy(context)
3131
finished_str = "Started S3MockApplication"
3232
return wait_for_condition(
3333
condition=lambda: finished_str in self.get_logs(),
3434
timeout_seconds=15,
3535
bail_condition=lambda: self.exited,
36-
context=None)
36+
context=context)
3737

3838
def check_s3_server_object_data(self, test_data):
3939
(code, output) = self.exec_run(["find", "/s3mockroot/test_bucket", "-mindepth", "1", "-maxdepth", "1", "-type", "d"])

extensions/azure/tests/features/steps/azure_server_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ def __init__(self, test_context: MinifiTestContext):
3333
self.azure_connection_string = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;" \
3434
f"BlobEndpoint=http://{azure_storage_hostname}:10000/devstoreaccount1;QueueEndpoint=http://{azure_storage_hostname}:10001/devstoreaccount1;"
3535

36-
def deploy(self):
37-
super().deploy()
36+
def deploy(self, context: MinifiTestContext | None) -> bool:
37+
super().deploy(context)
3838
finished_str = "Azurite Queue service is successfully listening at"
3939
return wait_for_condition(condition=lambda: finished_str in self.get_logs(),
4040
timeout_seconds=15,
4141
bail_condition=lambda: self.exited,
42-
context=None)
42+
context=context)
4343

4444
def check_azure_storage_server_data(self, test_data):
4545
(code, output) = self.exec_run(["find", "/data/__blobstorage__", "-type", "f"])

extensions/azure/tests/features/steps/steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def step_impl(context: MinifiTestContext, processor_name: str):
4343
@step("an Azure storage server is set up")
4444
def step_impl(context):
4545
context.containers["azure-storage-server"] = AzureServerContainer(context)
46-
assert context.containers["azure-storage-server"].deploy()
46+
assert context.containers["azure-storage-server"].deploy(context)
4747

4848

4949
@then('the object on the Azure storage server is "{object_data}"')

extensions/couchbase/tests/features/steps/couchbase_server_container.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ def __init__(self, test_context: MinifiTestContext):
3737
couchbase_key_content = crypto.dump_privatekey(type=crypto.FILETYPE_PEM, pkey=couchbase_key)
3838
self.files.append(File("/opt/couchbase/var/lib/couchbase/inbox/pkey.key", couchbase_key_content, permissions=0o666))
3939

40-
def deploy(self):
41-
super().deploy()
40+
def deploy(self, context: MinifiTestContext | None) -> bool:
41+
super().deploy(context)
4242
finished_str = "logs available in"
4343
assert wait_for_condition(
4444
condition=lambda: finished_str in self.get_logs(),
4545
timeout_seconds=15,
4646
bail_condition=lambda: self.exited,
47-
context=None)
47+
context=context)
4848
return self.run_post_startup_commands()
4949

5050
def run_post_startup_commands(self):

0 commit comments

Comments
 (0)