Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/system/python/api/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def test_statistics_history_with_params(self, fledge_url, request_params, keys):
assert 1 == len(jdoc['statistics'])
assert Counter(keys) == Counter(jdoc['statistics'][0].keys())

def test_statistics_history_with_service_enabled(self, start_south_coap, fledge_url, wait_time):
def test_statistics_history_with_service_enabled(self, start_south_coap, update_stat_collection, fledge_url, wait_time):
# Allow CoAP listener to start
time.sleep(wait_time)

Expand Down
19 changes: 19 additions & 0 deletions tests/system/python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,25 @@ def clone_make_install():

return _add_fledge_north


@pytest.fixture
def update_stat_collection(fledge_url, wait_time):
"""Update the Statistics Collection of all south service to per asset & service"""

# Wait for the south service and advanced category to be created
time.sleep(wait_time)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra delay from here. This fixture should call when service is up

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can call once added in disable mode as well; and advance category is available? So not necessarily when up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sleep is used to wait for the creation of the advanced category. Since this fixture is called immediately after the South service is created, the sleep is added here to prevent failures caused by delays in the creation of the advanced category, even in disabled mode.

service_response_list = list()
response = utils.get_request(fledge_url, "/fledge/south")

for service in response["services"]:
put_url = "/fledge/category/{}Advanced".format(service["name"])
payload = {"statistics": "per asset & service"}
res = utils.put_request(fledge_url, quote(put_url), payload)
service_response_list.append(res)

return service_response_list


@pytest.fixture
def add_service():
def _add_service(fledge_url, service, service_branch, retries, installation_type = "make", service_name = "svc@123",
Expand Down
2 changes: 1 addition & 1 deletion tests/system/python/e2e/test_e2e_coap_PI.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def start_south_north(reset_and_start_fledge, add_south, start_north_pi_server_c


class TestE2E_CoAP_PI:
def test_end_to_end(self, start_south_north, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db,
def test_end_to_end(self, start_south_north, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db,
wait_time, retries, skip_verify_north_interface, asset_name=ASSET_NAME):
""" Test that data is inserted in Fledge and sent to PI
start_south_north: Fixture that starts Fledge with south and north instance
Expand Down
7 changes: 4 additions & 3 deletions tests/system/python/e2e/test_e2e_csv_PI.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def start_south_north(reset_and_start_fledge, add_south, start_north_pi_server_c
_data_str[_head] = tmp_list

south_plugin = "playback"
add_south(south_plugin, south_branch, fledge_url, config=south_config)
add_south(south_plugin, south_branch, fledge_url, config=south_config, start_service=False)
start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token)

yield start_south_north
Expand All @@ -131,8 +131,8 @@ def _verify_egress(read_data_from_pi, pi_host, pi_admin, pi_passwd, pi_db, wait_


class TestE2E_CSV_PI:
def test_e2e_csv_pi(self, start_south_north, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db,
wait_time, retries, skip_verify_north_interface, asset_name="end_to_end_csv"):
def test_e2e_csv_pi(self, start_south_north, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db,
enable_schedule, wait_time, retries, skip_verify_north_interface, asset_name="end_to_end_csv"):
""" Test that data is inserted in Fledge and sent to PI
start_south_north: Fixture that starts Fledge with south and north instance
read_data_from_pi: Fixture to read data from PI
Expand All @@ -143,6 +143,7 @@ def test_e2e_csv_pi(self, start_south_north, read_data_from_pi, fledge_url, pi_h
data received from PI is same as data sent"""

conn = http.client.HTTPConnection(fledge_url)
enable_schedule(fledge_url, "play")
# Time to wait until north schedule runs
time.sleep(wait_time * math.ceil(15/wait_time) + 15)

Expand Down
12 changes: 6 additions & 6 deletions tests/system/python/e2e/test_e2e_csv_multi_filter_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule,
filter_cfg_meta = {"enable": "true"}
add_filter("metadata", filter_branch, "fmeta", filter_cfg_meta, fledge_url, SVC_NAME)

# Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add
# enable service when all filters all applied
enable_schedule(fledge_url, SVC_NAME)

start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token)

yield self.start_south_north
Expand All @@ -140,8 +136,8 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule,

remove_data_file(csv_file_path)

def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin,
pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface):
def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin,
enable_schedule, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface):
""" Test that data is inserted in Fledge using playback south plugin &
Delta, RMS, Rate, Scale, Asset & Metadata filters, and sent to PI
start_south_north: Fixture that starts Fledge with south service, add filter and north instance
Expand All @@ -151,6 +147,10 @@ def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_
on endpoint GET /fledge/asset/<asset_name> with applied data processing filter value
data received from PI is same as data sent"""

# Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add
# enable service when all filters all applied
enable_schedule(fledge_url, SVC_NAME)

# Time to wait until north schedule runs
time.sleep(wait_time * math.ceil(15/wait_time) + 15)
conn = http.client.HTTPConnection(fledge_url)
Expand Down
2 changes: 1 addition & 1 deletion tests/system/python/e2e/test_e2e_expr_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule,
remove_directories("/tmp/fledge-south-{}".format(SOUTH_PLUGIN.lower()))
remove_directories("/tmp/fledge-filter-{}".format(filter_plugin))

def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin,
def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin,
pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface):
""" Test that data is inserted in Fledge using expression south plugin & metadata filter, and sent to PI
start_south_north: Fixture that starts Fledge with south service, add filter and north instance
Expand Down
12 changes: 6 additions & 6 deletions tests/system/python/e2e/test_e2e_filter_fft_threshold.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule,
filter_cfg_fft = {"asset": ASSET, "lowPass": "10", "highPass": "30", "enable": "true"}
add_filter("fft", filter_branch, "FFT Filter", filter_cfg_fft, fledge_url, SVC_NAME)

# Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add
# enable service when all filters all applied
enable_schedule(fledge_url, SVC_NAME)

start_north_pi_server_c(fledge_url, pi_host, pi_port, pi_token, taskname=NORTH_TASK_NAME,
start_task=False)

Expand All @@ -128,8 +124,8 @@ def start_south_north(self, reset_and_start_fledge, add_south, enable_schedule,

remove_data_file(csv_dest)

def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin,
pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface):
def test_end_to_end(self, start_south_north, update_stat_collection, disable_schedule, fledge_url, read_data_from_pi, pi_host, pi_admin,
enable_schedule, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface):
""" Test that data is inserted in Fledge using playback south plugin &
FFT filter, and sent to PI after passing through threshold filter
start_south_north: Fixture that starts Fledge with south service, add filter and north instance
Expand All @@ -139,6 +135,10 @@ def test_end_to_end(self, start_south_north, disable_schedule, fledge_url, read_
on endpoint GET /fledge/asset/<asset_name> with applied data processing filter value
data received from PI is same as data sent"""

# Since playback plugin reads all csv data at once, we cant keep it in enable mode before filter add
# enable service when all filters all applied
enable_schedule(fledge_url, SVC_NAME)

# Time to wait until north schedule runs
time.sleep(wait_time * math.ceil(15/wait_time) + 15)
conn = http.client.HTTPConnection(fledge_url)
Expand Down
4 changes: 2 additions & 2 deletions tests/system/python/e2e/test_e2e_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _configure_and_start_north_kafka(self, north_branch, fledge_url, host, port,
"schedule_type": 3,
"schedule_day": 0,
"schedule_time": 0,
"schedule_repeat": 0,
"schedule_repeat": 5,

@ashish-jabble ashish-jabble Oct 12, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that task never runs/execute before as its type is INTERVAL?
For nightly system tests, Are we running with skip_verify_north_interface?

"schedule_enabled": "true",
"config": {"topic": {"value": topic},
"brokers": {"value": "{}:{}".format(host, port)}}
Expand Down Expand Up @@ -118,7 +118,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, remove_data_file,
remove_directories("/tmp/fledge-south-{}".format(SOUTH_PLUGIN_NAME))
remove_directories("/tmp/fledge-north-{}".format(NORTH_PLUGIN_NAME.lower()))

def test_end_to_end(self, start_south_north, fledge_url, wait_time, kafka_host, kafka_rest_port, kafka_topic,
def test_end_to_end(self, start_south_north, update_stat_collection, fledge_url, wait_time, kafka_host, kafka_rest_port, kafka_topic,
skip_verify_north_interface):
""" Test that data is inserted in Fledge and sent to Kafka
start_south_north: Fixture that starts Fledge with south and north instance
Expand Down
2 changes: 1 addition & 1 deletion tests/system/python/e2e/test_e2e_modbus_c_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, remove_directorie

remove_directories("/tmp/fledge-south-{}".format(SOUTH_PLUGIN.lower()))

def test_end_to_end(self, start_south_north, enable_schedule, disable_schedule, fledge_url, read_data_from_pi,
def test_end_to_end(self, start_south_north, update_stat_collection, enable_schedule, disable_schedule, fledge_url, read_data_from_pi,
pi_host, pi_admin, pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface,
modbus_host, modbus_port):
""" Test that data is inserted in Fledge using modbus-c south plugin and sent to PI
Expand Down
2 changes: 1 addition & 1 deletion tests/system/python/e2e/test_e2e_pi_scaleset.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def start_south_north_with_filter(self, reset_and_start_fledge, add_south, south
remove_directories("/tmp/fledge-south-{}".format(ASSET_NAME.lower()))
remove_directories("/tmp/fledge-filter-{}".format(FILTER_PLUGIN))

def test_end_to_end(self, start_south_north_with_filter, read_data_from_pi, fledge_url, pi_host, pi_admin,
def test_end_to_end(self, start_south_north_with_filter, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin,
pi_passwd, pi_db, wait_time, retries, skip_verify_north_interface):

subprocess.run(["cd $FLEDGE_ROOT/extras/python; python3 -m fogbench -t ../../data/template.json -p http; cd -"]
Expand Down
2 changes: 1 addition & 1 deletion tests/system/python/e2e/test_e2e_vary_asset_http_pi.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def start_south_north(self, reset_and_start_fledge, add_south, start_north_pi_se
# Cleanup code that runs after the caller test is over
remove_directories("/tmp/fledge-south-{}".format(south_plugin))

def test_end_to_end(self, start_south_north, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db,
def test_end_to_end(self, start_south_north, update_stat_collection, read_data_from_pi, fledge_url, pi_host, pi_admin, pi_passwd, pi_db,
wait_time, retries, skip_verify_north_interface):
""" Test that data is inserted in Fledge and sent to PI
start_south_north: Fixture that starts Fledge with south and north instance
Expand Down
2 changes: 1 addition & 1 deletion tests/system/python/packages/test_eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def verify_eds_egress_asset_tracking(fledge_url):


class TestEDS:
def test_eds(self, check_eds_installed, reset_eds, remove_and_add_pkgs, reset_fledge, start_south_north, fledge_url,
def test_eds(self, check_eds_installed, reset_eds, remove_and_add_pkgs, reset_fledge, start_south_north, update_stat_collection, fledge_url,
wait_time):
time.sleep(wait_time * 4)

Expand Down
Loading