Skip to content
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

[WIP] Fixed flaky blackbox tests #1473

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
LOG = logging.getLogger("TEST")


@unittest.skip('Flaky test')
class ModbusAttributesUpdatesTest(BaseTest):
CONFIG_PATH = path.join(path.dirname(path.dirname(path.dirname(path.abspath(__file__)))),
"data" + path.sep + "modbus" + path.sep)
Expand Down
38 changes: 18 additions & 20 deletions tests/blackbox/connectors/opcua/test_opcua_attributes_updates.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from time import sleep
from unittest import skip

from tests.blackbox.connectors.opcua.test_base_opcua import BaseOpcuaTest
from tests.test_utils.gateway_device_util import GatewayDeviceUtil


@skip('Flaky test')
class OpcuaAsyncioAttributesUpdatesTest(BaseOpcuaTest):
def test_attr_update(self):
self.update_device_and_connector_shared_attributes(
Expand All @@ -20,24 +18,24 @@ def test_attr_update(self):
self.assertEqual(str(value), actual_values[_type][0]['value'],
f'Value is not equal for the next telemetry key: {_type}')

# def test_attr_update_after_gateway_restart(self):
# GatewayDeviceUtil.restart_gateway()
#
# self.update_device_and_connector_shared_attributes(
# 'configs/attrs_update_configs/attrs_update_node.json',
# 'test_values/attrs_update/attrs_update_restart_node_values.json')
# sleep(self.GENERAL_TIMEOUT)
# expected_values = self.load_configuration(
# self.CONFIG_PATH + 'test_values/attrs_update/attrs_update_restart_node_values.json')
# actual_values = self.client.get_latest_timeseries(self.device.id,
# ','.join([key for (key, _) in expected_values.items()]))
# for (_type, value) in expected_values.items():
# self.assertEqual(str(value), actual_values[_type][0]['value'],
# f'Value is not equal for the next telemetry key: {_type}')
#
# # reset node values to default
# self.reset_node_default_values()
# sleep(self.GENERAL_TIMEOUT)
def test_attr_update_after_gateway_restart(self):
GatewayDeviceUtil.restart_gateway()

self.update_device_and_connector_shared_attributes(
'configs/attrs_update_configs/attrs_update_node.json',
'test_values/attrs_update/attrs_update_restart_node_values.json')
sleep(self.GENERAL_TIMEOUT)
expected_values = self.load_configuration(
self.CONFIG_PATH + 'test_values/attrs_update/attrs_update_restart_node_values.json')
actual_values = self.client.get_latest_timeseries(self.device.id,
','.join([key for (key, _) in expected_values.items()]))
for (_type, value) in expected_values.items():
self.assertEqual(str(value), actual_values[_type][0]['value'],
f'Value is not equal for the next telemetry key: {_type}')

# reset node values to default
self.reset_node_default_values()
sleep(self.GENERAL_TIMEOUT)

def test_attr_update_after_connection_lost(self):
GatewayDeviceUtil.update_credentials({"credentialsType": "ACCESS_TOKEN",
Expand Down
2 changes: 0 additions & 2 deletions tests/blackbox/connectors/opcua/test_opcua_rpc.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from time import sleep
from unittest import skip

from tests.blackbox.connectors.opcua.test_base_opcua import BaseOpcuaTest
from tests.test_utils.gateway_device_util import GatewayDeviceUtil


@skip('Flaky test')
class OpcuaAsyncioRPCTest(BaseOpcuaTest):
def test_rpc_set(self):
"""
Expand Down
31 changes: 15 additions & 16 deletions tests/blackbox/connectors/opcua/test_opcua_uplink_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from tests.test_utils.gateway_device_util import GatewayDeviceUtil


@skip('Flaky test')
class OpcuaAsyncioUplinkMessagesTest(BaseOpcuaTest):
def test_gateway_connection(self):
self.assertEqual(self.client.get_attributes_by_scope(self.gateway.id, 'SERVER_SCOPE', 'active')[0]['value'],
Expand Down Expand Up @@ -44,21 +43,21 @@ def test_reading_from_variable_in_the_variable(self):
self.assertEqual(value, actual_values[_type][0]['value'],
f'Value is not equal for the next telemetry key: {_type}')

# def test_gateway_restarted(self):
# sleep(8)
# GatewayDeviceUtil.restart_gateway()
# restarted_time = time() * 1000
# config = self.load_configuration(
# self.CONFIG_PATH + 'configs/uplink_configs/different_node_finding_methods_config_path.json')
# GatewayDeviceUtil.update_connector_config(
# self.CONNECTOR_NAME,
# self.CONFIG_PATH + 'configs/uplink_configs/different_node_finding_methods_config_path.json')
# sleep(self.GENERAL_TIMEOUT)
# telemetry_keys = [key['key'] for node in config['Opcua']['configurationJson']['server']['mapping'] for
# key in node['timeseries']]
# actual_values = self.client.get_latest_timeseries(self.device.id, ','.join(telemetry_keys))
# for actual_value in actual_values.values():
# self.assertGreater(actual_value[0]['ts'], restarted_time)
def test_gateway_restarted(self):
sleep(8)
GatewayDeviceUtil.restart_gateway()
restarted_time = time() * 1000
config = self.load_configuration(
self.CONFIG_PATH + 'configs/uplink_configs/different_node_finding_methods_config_path.json')
GatewayDeviceUtil.update_connector_config(
self.CONNECTOR_NAME,
self.CONFIG_PATH + 'configs/uplink_configs/different_node_finding_methods_config_path.json')
sleep(self.GENERAL_TIMEOUT)
telemetry_keys = [key['key'] for node in config['Opcua']['configurationJson']['server']['mapping'] for
key in node['timeseries']]
actual_values = self.client.get_latest_timeseries(self.device.id, ','.join(telemetry_keys))
for actual_value in actual_values.values():
self.assertGreater(actual_value[0]['ts'], restarted_time)

def test_sending_attrs_and_telemetries_after_connection_lost(self):
GatewayDeviceUtil.update_credentials({"credentialsType": "ACCESS_TOKEN",
Expand Down
Loading