Skip to content

Commit 74f9297

Browse files
committed
Review update
1 parent 1e0a51f commit 74f9297

File tree

11 files changed

+72
-58
lines changed

11 files changed

+72
-58
lines changed

behave_framework/src/minifi_test_framework/containers/container.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,26 @@ def deploy(self) -> bool:
100100
def start(self):
101101
if self.container:
102102
self.container.start()
103+
else:
104+
logging.error("Container does not exist. Cannot start.")
103105

104106
def stop(self):
105107
if self.container:
106108
self.container.stop()
109+
else:
110+
logging.error("Container does not exist. Cannot stop.")
107111

108112
def kill(self):
109113
if self.container:
110114
self.container.kill()
115+
else:
116+
logging.error("Container does not exist. Cannot kill.")
111117

112118
def restart(self):
113119
if self.container:
114120
self.container.restart()
121+
else:
122+
logging.error("Container does not exist. Cannot restart.")
115123

116124
def clean_up(self):
117125
if self.container:
@@ -231,10 +239,14 @@ def exited(self) -> bool:
231239
return False
232240

233241
def get_number_of_files(self, directory_path: str) -> int:
234-
if not self.container or not self.not_empty_dir_exists(directory_path):
235-
logging.warning(f"Container not running or directory does not exist: {directory_path}")
242+
if not self.container:
243+
logging.warning("Container not running")
236244
return -1
237245

246+
if not self.not_empty_dir_exists(directory_path):
247+
logging.warning(f"Container directory does not exist: {directory_path}")
248+
return 0
249+
238250
count_command = f"sh -c 'find {directory_path} -maxdepth 1 -type f | wc -l'"
239251
exit_code, output = self.exec_run(count_command)
240252

@@ -314,7 +326,7 @@ def _extract_directory_from_container(self, directory_path: str, temp_dir: str)
314326

315327
return os.path.join(temp_dir, os.path.basename(directory_path.strip('/')))
316328
except Exception as e:
317-
logging.error(f"Error extracting files from container: {e}")
329+
logging.error(f"Error extracting files from directory path '{directory_path}' from container '{self.container_name}': {e}")
318330
return None
319331

320332
def _read_files_from_directory(self, directory_path: str) -> list[str] | None:

behave_framework/src/minifi_test_framework/steps/checking_steps.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from minifi_test_framework.core.minifi_test_context import DEFAULT_MINIFI_CONTAINER_NAME, MinifiTestContext
2828

2929

30-
@then('there is a file with "{content}" content at {path} in less than {duration}')
30+
@then('a file with the content "{content}" is placed on the path "{path}" in less than {duration}')
3131
def step_impl(context: MinifiTestContext, content: str, path: str, duration: str):
3232
new_content = content.replace("\\n", "\n")
3333
timeout_in_seconds = humanfriendly.parse_timespan(duration)
@@ -36,7 +36,7 @@ def step_impl(context: MinifiTestContext, content: str, path: str, duration: str
3636
timeout_seconds=timeout_in_seconds, bail_condition=lambda: context.get_default_minifi_container().exited, context=context)
3737

3838

39-
@then('there is a single file with "{content}" content in the "{directory}" directory in less than {duration}')
39+
@then('a single file with the content "{content}" is placed in the "{directory}" directory in less than {duration}')
4040
def step_impl(context: MinifiTestContext, content: str, directory: str, duration: str):
4141
new_content = content.replace("\\n", "\n")
4242
timeout_in_seconds = humanfriendly.parse_timespan(duration)
@@ -101,26 +101,27 @@ def step_impl(context: MinifiTestContext, url: str):
101101
@then('no files are placed in the "{directory}" directory in {duration} of running time')
102102
def step_impl(context, directory, duration):
103103
duration_seconds = humanfriendly.parse_timespan(duration)
104-
assert check_condition_after_wait(condition=lambda: context.get_default_minifi_container().get_number_of_files(directory) < 1,
104+
assert check_condition_after_wait(condition=lambda: context.get_default_minifi_container().get_number_of_files(directory) == 0,
105105
context=context, wait_time=duration_seconds)
106106

107107

108-
@then('there are {num_str} files in the "{directory}" directory in less than {duration}')
109-
@then('there is {num_str} file in the "{directory}" directory in less than {duration}')
110-
def step_impl(context: MinifiTestContext, num_str: str, directory: str, duration: str):
108+
@then('{num:d} files are placed in the "{directory}" directory in less than {duration}')
109+
@then('{num:d} file is placed in the "{directory}" directory in less than {duration}')
110+
def step_impl(context: MinifiTestContext, num: int, directory: str, duration: str):
111111
duration_seconds = humanfriendly.parse_timespan(duration)
112-
if int(num_str) == 0:
112+
if num == 0:
113113
context.execute_steps(f'then no files are placed in the "{directory}" directory in {duration} of running time')
114114
return
115-
assert wait_for_condition(condition=lambda: context.get_default_minifi_container().get_number_of_files(directory) == int(num_str),
115+
assert wait_for_condition(condition=lambda: context.get_default_minifi_container().get_number_of_files(directory) == num,
116116
timeout_seconds=duration_seconds, bail_condition=lambda: context.get_default_minifi_container().exited,
117117
context=context)
118118

119119

120-
@then('there are at least {num_str} files is in the "{directory}" directory in less than {duration}')
121-
def step_impl(context: MinifiTestContext, num_str: str, directory: str, duration: str):
120+
@then('at least {num:d} files are placed in the "{directory}" directory in less than {duration}')
121+
@then('at least {num:d} file is placed in the "{directory}" directory in less than {duration}')
122+
def step_impl(context: MinifiTestContext, num: int, directory: str, duration: str):
122123
duration_seconds = humanfriendly.parse_timespan(duration)
123-
assert wait_for_condition(condition=lambda: context.get_default_minifi_container().get_number_of_files(directory) >= int(num_str),
124+
assert wait_for_condition(condition=lambda: context.get_default_minifi_container().get_number_of_files(directory) >= num,
124125
timeout_seconds=duration_seconds, bail_condition=lambda: context.get_default_minifi_container().exited,
125126
context=context)
126127

@@ -133,7 +134,7 @@ def step_impl(context: MinifiTestContext, directory: str, regex_str: str, durati
133134
timeout_seconds=duration_seconds, bail_condition=lambda: context.get_default_minifi_container().exited, context=context)
134135

135136

136-
@then('the contents of {directory} in less than {timeout} are: "{content_one}" and "{content_two}"')
137+
@then('files with contents "{content_one}" and "{content_two}" are placed in the "{directory}" directory in less than {timeout}')
137138
def step_impl(context: MinifiTestContext, directory: str, timeout: str, content_one: str, content_two: str):
138139
timeout_seconds = humanfriendly.parse_timespan(timeout)
139140
c1 = content_one.replace("\\n", "\n")
@@ -144,7 +145,7 @@ def step_impl(context: MinifiTestContext, directory: str, timeout: str, content_
144145
context=context)
145146

146147

147-
@then('the contents of {directory} in less than {timeout} are: "{contents}"')
148+
@then('files with contents "{contents}" are placed in the "{directory}" directory in less than {timeout}')
148149
def step_impl(context: MinifiTestContext, directory: str, timeout: str, contents: str):
149150
timeout_seconds = humanfriendly.parse_timespan(timeout)
150151
new_contents = contents.replace("\\n", "\n")
@@ -173,7 +174,7 @@ def step_impl(context: MinifiTestContext, max_increase: str, duration: str):
173174
assert final_memory_usage - initial_memory_usage <= max_increase_in_bytes
174175

175176

176-
@then('after a wait of {duration}, at least {lower_bound:d} and at most {upper_bound:d} flowfiles are produced and placed in the "{directory}" directory')
177+
@then('after a wait of {duration}, at least {lower_bound:d} and at most {upper_bound:d} files are produced and placed in the "{directory}" directory')
177178
def step_impl(context, lower_bound, upper_bound, duration, directory):
178179
duration_seconds = humanfriendly.parse_timespan(duration)
179180
assert check_condition_after_wait(condition=lambda: context.get_default_minifi_container().get_number_of_files(directory) >= lower_bound

extensions/aws/tests/features/s3.feature

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
3333

3434
When both instances start up
3535

36-
Then there is a single file with "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" content in the "/tmp/output" directory in less than 20 seconds
36+
Then a single file with the content "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" is placed in the "/tmp/output" directory in less than 20 seconds
3737
And the object on the s3 server is "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{"
3838
And the object content type on the s3 server is "application/octet-stream" and the object metadata matches use metadata
3939
And the Minifi logs contain the following message: "in a single upload" in less than 10 seconds
@@ -58,7 +58,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
5858
And the http proxy server is set up
5959
When all instances start up
6060

61-
Then there is a single file with "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" content in the "/tmp/output" directory in less than 20 seconds
61+
Then a single file with the content "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" is placed in the "/tmp/output" directory in less than 20 seconds
6262
And the object on the s3 server is "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{"
6363
And the object content type on the s3 server is "application/octet-stream" and the object metadata matches use metadata
6464
And no errors were generated on the http-proxy regarding "http://s3-server-s3-1:9090/test_bucket/test_object_key"
@@ -81,7 +81,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
8181

8282
When both instances start up
8383

84-
Then there is a single file with "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" content in the "/tmp/output" directory in less than 20 seconds
84+
Then a single file with the content "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" is placed in the "/tmp/output" directory in less than 20 seconds
8585
And the object bucket on the s3 server is empty in less than 10 seconds
8686

8787
Scenario: Deletion of a non-existent s3 object succeeds
@@ -96,7 +96,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
9696

9797
When both instances start up
9898

99-
Then there is a single file with "test" content in the "/tmp/output" directory in less than 20 seconds
99+
Then a single file with the content "test" is placed in the "/tmp/output" directory in less than 20 seconds
100100
And the object bucket on the s3 server is empty in less than 10 seconds
101101

102102
Scenario: Deletion of a s3 object through a proxy-server succeeds
@@ -124,7 +124,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
124124

125125
When all instances start up
126126

127-
Then there is a single file with "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" content in the "/tmp/output" directory in less than 20 seconds
127+
Then a single file with the content "LH_O#L|FD<FASD{FO#@$#$%^ \"#\"$L%:\"@#$L\":test_data#$#%#$%?{\"F{" is placed in the "/tmp/output" directory in less than 20 seconds
128128
And the object bucket on the s3 server is empty in less than 10 seconds
129129
And no errors were generated on the http-proxy regarding "http://s3-server-s3-4:9090/test_bucket/test_object_key"
130130

@@ -149,7 +149,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
149149

150150
When all instances start up
151151

152-
Then there is a single file with "test" content in the "/tmp/output" directory in less than 20 seconds
152+
Then a single file with the content "test" is placed in the "/tmp/output" directory in less than 20 seconds
153153

154154
Scenario: A MiNiFi instance can download s3 bucket objects via a http-proxy
155155
Given a GetFile processor with the "Input Directory" property set to "/tmp/input"
@@ -176,7 +176,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
176176

177177
When all instances start up
178178

179-
Then there is a single file with "test" content in the "/tmp/output" directory in less than 20 seconds
179+
Then a single file with the content "test" is placed in the "/tmp/output" directory in less than 20 seconds
180180
And no errors were generated on the http-proxy regarding "http://s3-server-s3-6:9090/test_bucket/test_object_key"
181181

182182
Scenario: A MiNiFi instance can list an S3 bucket directly
@@ -197,7 +197,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
197197

198198
When all instances start up
199199

200-
Then there are 2 files in the "/tmp/output" directory in less than 20 seconds
200+
Then 2 files are placed in the "/tmp/output" directory in less than 20 seconds
201201

202202
Scenario: A MiNiFi instance can list an S3 bucket objects via a http-proxy
203203
Given a GetFile processor with the "Input Directory" property set to "/tmp/input"
@@ -220,7 +220,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
220220

221221
When all instances start up
222222

223-
Then there is 1 file in the "/tmp/output" directory in less than 20 seconds
223+
Then 1 file is placed in the "/tmp/output" directory in less than 20 seconds
224224
And no errors were generated on the http-proxy regarding "http://s3-server-s3-8:9090/test_bucket"
225225

226226
Scenario: A MiNiFi instance transfers data in multiple parts to s3
@@ -236,7 +236,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
236236

237237
When all instances start up
238238

239-
Then there is 1 file in the "/tmp/output" directory in less than 20 seconds
239+
Then 1 file is placed in the "/tmp/output" directory in less than 20 seconds
240240
And the object on the s3 server is present and matches the original hash
241241
And the Minifi logs contain the following message: "passes the multipart threshold, uploading it in multiple parts" in less than 10 seconds
242242

@@ -260,7 +260,7 @@ Feature: Sending data from MiNiFi-C++ to an AWS server
260260
And the http proxy server is set up
261261
When all instances start up
262262

263-
Then there is 1 file in the "/tmp/output" directory in less than 20 seconds
263+
Then 1 file is placed in the "/tmp/output" directory in less than 20 seconds
264264
And the object on the s3 server is present and matches the original hash
265265
And the Minifi logs contain the following message: "passes the multipart threshold, uploading it in multiple parts" in less than 10 seconds
266266
And no errors were generated on the http-proxy regarding "http://s3-server-s3-10:9090/test_bucket/test_object_key"

extensions/azure/tests/features/azure_storage.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Feature: Sending data from MiNiFi-C++ to an Azure storage server
3232
And an Azure storage server is set up
3333
When the MiNiFi instance starts up
3434

35-
Then there is a single file with "#test_data$123$#" content in the "/tmp/output" directory in less than 20 seconds
35+
Then a single file with the content "#test_data$123$#" is placed in the "/tmp/output" directory in less than 20 seconds
3636
And the object on the Azure storage server is "#test_data$123$#"
3737

3838
Scenario: A MiNiFi instance can delete blob from Azure blob storage
@@ -90,7 +90,7 @@ Feature: Sending data from MiNiFi-C++ to an Azure storage server
9090
When the MiNiFi instance starts up
9191
And test blob "test" with the content "#test_data_123$#" is created on Azure blob storage
9292

93-
Then there is a single file with "data_" content in the "/tmp/output" directory in less than 20 seconds
93+
Then a single file with the content "data_" is placed in the "/tmp/output" directory in less than 20 seconds
9494

9595
Scenario: A MiNiFi instance can list a container on Azure blob storage
9696
Given a ListAzureBlobStorage processor set up to communicate with an Azure blob storage

0 commit comments

Comments
 (0)