Commit 5924d5b3 authored by Ivan Tyagov's avatar Ivan Tyagov

Implement first test.

parent 57aca877
......@@ -12,4 +12,4 @@ md5sum = cbaa8e36097f36caf1a377fa71341a09
[test_beremiz.py]
filename = test_beremiz.py
md5sum =184920492fc7e1a812e659d91a95a121
md5sum =4e3263e01dc00e867ed70144219a3551
......@@ -6,7 +6,6 @@ import unittest
from opcua import Client
import slapos.client
class EndToEndTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
......@@ -125,5 +124,36 @@ class BeremizTest(EndToEndTestCase):
cls.waitUntilGreen(instance_name)
connection_dict = cls.getInstanceInfos(instance_name).connection_dict
def test_fail(self):
self.assertEqual(0, 1)
def test_plc_increment_run(self):
NUMBER_OF_CHECKS = 100
TIMEOUT = 2
OPC_UA_ADDRESS = "opc.tcp://0.0.0.0:4840/"
OPC_UA_IDENTIFIER = "ns=1;s=i2c0.relay0"
# connect to a session at OPC-UA server
client = Client(OPC_UA_ADDRESS)
# for now this is the only test thus we start it without a wrapper
test_count = 1
test_failures = 0
expected_failures = 0
try:
client.connect()
root = client.get_root_node()
children_list = root.get_children()
var = client.get_node(OPC_UA_IDENTIFIER)
for i in range (0, NUMBER_OF_CHECKS):
i2c0_relay0_before = var.get_value()
print("\ni2c0_relay0 (before) = ", i2c0_relay0_before)
print("Sleep for %s seconds ..." %TIMEOUT)
time.sleep(TIMEOUT)
i2c0_relay0_after = var.get_value()
print("i2c0_relay0 (after) = ", i2c0_relay0_after)
# for the wait timeout runtime should have increased the value
if (i2c0_relay0_after <= i2c0_relay0_before):
# counter should have been increased, mark failure
test_failures += 1
finally:
client.disconnect()
# no failures
self.asserEqual(test_failures, 0)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment