fgerlits commented on code in PR #2059:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2059#discussion_r2580675409
##########
behave_framework/src/minifi_test_framework/containers/container.py:
##########
@@ -254,6 +285,59 @@ def verify_file_contents(self, directory_path: str,
expected_contents: list[str]
return sorted(actual_file_contents) == sorted(expected_contents)
+ def _verify_file_contents_in_stopped_container(self, directory_path: str,
expected_contents: list[str]) -> bool:
+ if not self.container:
+ return False
+
+ with tempfile.TemporaryDirectory() as temp_dir:
+ extracted_dir =
self._extract_directory_from_container(directory_path, temp_dir)
+ if not extracted_dir:
+ return False
+
+ actual_file_contents =
self._read_files_from_directory(extracted_dir)
+ if actual_file_contents is None:
+ return False
+
+ return sorted(actual_file_contents) == sorted(expected_contents)
+
+ def _extract_directory_from_container(self, directory_path: str, temp_dir:
str) -> str | None:
+ try:
+ bits, _ = self.container.get_archive(directory_path)
+ temp_tar_path = os.path.join(temp_dir, "archive.tar")
+
+ with open(temp_tar_path, 'wb') as f:
+ for chunk in bits:
+ f.write(chunk)
+
+ with tarfile.open(temp_tar_path) as tar:
+ tar.extractall(path=temp_dir)
+
+ return os.path.join(temp_dir,
os.path.basename(directory_path.strip('/')))
+ except Exception as e:
+ logging.error(f"Error extracting files from container: {e}")
Review Comment:
Does `e` contain the container's name and `directory_path`? If it doesn't,
then I would add these two to the error message.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]