From bb53d93990cbf59a3190fd5fba19ad192bef0e67 Mon Sep 17 00:00:00 2001 From: andrej Date: Mon, 9 Jan 2023 13:52:17 +0100 Subject: [PATCH 1/6] integration-tests: make sure the plugin starts per test, not per suite --- .../InterfaceInit.resource | 31 +++++++++++++++ .../robot-ietf-interfaces/__init__.robot | 39 ++----------------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/tests/integration/robot-ietf-interfaces/InterfaceInit.resource b/tests/integration/robot-ietf-interfaces/InterfaceInit.resource index fc29c5e6..773b1180 100644 --- a/tests/integration/robot-ietf-interfaces/InterfaceInit.resource +++ b/tests/integration/robot-ietf-interfaces/InterfaceInit.resource @@ -5,6 +5,7 @@ Library Process *** Variables *** ${Xpath Interfaces} /ietf-interfaces:interfaces +${Running Datastore} running *** Keywords *** Restore Initial Running Datastore @@ -19,3 +20,33 @@ Check If Datastore Is Restored ... ${Xpath Interfaces} ... json Should Be Equal As Strings ${Restored} ${If Init Str} msg="failed to restore inital running datastore" + +Init Running Session + ${Session Running}= Open Datastore Session ${Connection Default} ${Running Datastore} + Set Global Variable ${Session Running} + ${If Init Str}= Get Datastore Data + ... ${Connection Default} + ... ${Session Running} + ... ${Xpath Interfaces} + ... json + Set Global Variable ${If Init Str} + &{If Init JSON}= Convert String To JSON ${If Init Str} + Set Global Variable ${If Init JSON} + +Connect Interfaces + Start Plugin + ${Connection Default}= Open Sysrepo Connection + Set Global Variable ${Connection Default} + Init Running Session + +Cleanup Interfaces + Restore Initial Running Datastore + Cleanup IETF Interfaces + +Start Plugin + ${Plugin}= Start Process %{SYSREPO_INTERFACES_PLUGIN_PATH} + Set Global Variable ${Plugin} + Wait For Process ${Plugin} timeout=0.1s on_timeout=continue + +Cleanup IETF Interfaces + Terminate Process ${Plugin} diff --git a/tests/integration/robot-ietf-interfaces/__init__.robot b/tests/integration/robot-ietf-interfaces/__init__.robot index c53c5611..11155c4c 100644 --- a/tests/integration/robot-ietf-interfaces/__init__.robot +++ b/tests/integration/robot-ietf-interfaces/__init__.robot @@ -4,42 +4,9 @@ Library RPA.JSON Library Process Resource InterfaceInit.resource -Suite Setup Setup IETF Interfaces -Suite Teardown Cleanup IETF Interfaces - -Test Teardown Restore Initial Running Datastore - -*** Variables *** -${Xpath Interfaces} /ietf-interfaces:interfaces -${Running Datastore} running +Suite Teardown Cleanup IETF Interfaces -*** Keywords *** -Setup IETF Interfaces - [Documentation] Create a default connection and running session - Start Plugin - ${Connection Default}= Open Sysrepo Connection - Set Global Variable ${Connection Default} - Init Running Session - -Start Plugin - ${Plugin}= Start Process %{SYSREPO_INTERFACES_PLUGIN_PATH} - Set Suite Variable ${Plugin} - Wait For Process ${Plugin} timeout=2s on_timeout=continue - -Init Running Session - ${Session Running}= Open Datastore Session ${Connection Default} ${Running Datastore} - Set Global Variable ${Session Running} - ${If Init Str}= Get Datastore Data - ... ${Connection Default} - ... ${Session Running} - ... ${Xpath Interfaces} - ... json - Set Global Variable ${If Init Str} - &{If Init JSON}= Convert String To JSON ${If Init Str} - Set Global Variable ${If Init JSON} +Test Setup Connect Interfaces +Test Teardown Cleanup Interfaces -Cleanup IETF Interfaces - # Restore initial data - Terminate Process ${Plugin} - Close All Sysrepo Connections And Sessions From 5b3ace7dcf4f4d2c02face9a1af495d95d0f5b10 Mon Sep 17 00:00:00 2001 From: andrej Date: Mon, 9 Jan 2023 13:54:35 +0100 Subject: [PATCH 2/6] integration-tests: rename plugin stop keyword --- .../integration/robot-ietf-interfaces/InterfaceInit.resource | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/robot-ietf-interfaces/InterfaceInit.resource b/tests/integration/robot-ietf-interfaces/InterfaceInit.resource index 773b1180..9b7a15a1 100644 --- a/tests/integration/robot-ietf-interfaces/InterfaceInit.resource +++ b/tests/integration/robot-ietf-interfaces/InterfaceInit.resource @@ -41,12 +41,12 @@ Connect Interfaces Cleanup Interfaces Restore Initial Running Datastore - Cleanup IETF Interfaces + Stop Plugin Start Plugin ${Plugin}= Start Process %{SYSREPO_INTERFACES_PLUGIN_PATH} Set Global Variable ${Plugin} Wait For Process ${Plugin} timeout=0.1s on_timeout=continue -Cleanup IETF Interfaces +Stop Plugin Terminate Process ${Plugin} From 4a2e33d31df66f69fc607e596fb11f6005d2eea2 Mon Sep 17 00:00:00 2001 From: andrej Date: Mon, 9 Jan 2023 13:58:48 +0100 Subject: [PATCH 3/6] integration-tests: remove old suite cleanup --- tests/integration/robot-ietf-interfaces/__init__.robot | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/integration/robot-ietf-interfaces/__init__.robot b/tests/integration/robot-ietf-interfaces/__init__.robot index 11155c4c..3294cc12 100644 --- a/tests/integration/robot-ietf-interfaces/__init__.robot +++ b/tests/integration/robot-ietf-interfaces/__init__.robot @@ -5,8 +5,6 @@ Library Process Resource InterfaceInit.resource -Suite Teardown Cleanup IETF Interfaces - -Test Setup Connect Interfaces +Test Setup Connect Interfaces Test Teardown Cleanup Interfaces From 87576ebf5d3af47b41c3bf906669afae7e9bf132 Mon Sep 17 00:00:00 2001 From: andrej Date: Wed, 11 Jan 2023 10:10:25 +0100 Subject: [PATCH 4/6] integration-tests: rework routing init to match interfaces --- .../robot-ietf-routing/RoutingInit.resource | 36 ++++++++++++- .../robot-ietf-routing/__init__.robot | 54 +------------------ 2 files changed, 36 insertions(+), 54 deletions(-) diff --git a/tests/integration/robot-ietf-routing/RoutingInit.resource b/tests/integration/robot-ietf-routing/RoutingInit.resource index 50c154d8..6132a4fa 100644 --- a/tests/integration/robot-ietf-routing/RoutingInit.resource +++ b/tests/integration/robot-ietf-routing/RoutingInit.resource @@ -5,10 +5,12 @@ Library Process *** Variables *** ${Xpath Routing} /ietf-routing:routing +${Running Datastore} running +${Plugin Timeout Seconds} 0.5s *** Keywords *** Restore Initial Running Datastore - Edit Datastore Config ${Connection Default} ${Session Running} ${Routing Init Running Str} json + Edit Datastore Config ${Connection Default} ${Session Running} ${Route Init Str} json Check If Datastore Is Restored Check If Datastore Is Restored @@ -18,4 +20,34 @@ Check If Datastore Is Restored ... ${Session Running} ... ${Xpath Routing} ... json - Should Be Equal As Strings ${Restored} ${Routing Init Running Str} msg="failed to restore inital running datastore" + Should Be Equal As Strings ${Restored} ${Route Init Str} msg="failed to restore inital running datastore" + +Init Running Session + ${Session Running}= Open Datastore Session ${Connection Default} ${Running Datastore} + Set Global Variable ${Session Running} + ${Route Init Str}= Get Datastore Data + ... ${Connection Default} + ... ${Session Running} + ... ${Xpath Routing} + ... json + Set Global Variable ${Route Init Str} + &{Route Init JSON}= Convert String To JSON ${Route Init Str} + Set Global Variable ${Route Init JSON} + +Connect Routing + Start Plugin + ${Connection Default}= Open Sysrepo Connection + Set Global Variable ${Connection Default} + Init Running Session + +Cleanup Routing + Restore Initial Running Datastore + Stop Plugin + +Start Plugin + ${Plugin}= Start Process %{SYSREPO_ROUTING_PLUGIN_PATH} + Set Global Variable ${Plugin} + Wait For Process ${Plugin} timeout=${Plugin Timeout Seconds} on_timeout=continue + +Stop Plugin + Terminate Process ${Plugin} diff --git a/tests/integration/robot-ietf-routing/__init__.robot b/tests/integration/robot-ietf-routing/__init__.robot index 7ecccded..b23990d1 100644 --- a/tests/integration/robot-ietf-routing/__init__.robot +++ b/tests/integration/robot-ietf-routing/__init__.robot @@ -4,57 +4,7 @@ Library RPA.JSON Library Process Resource RoutingInit.resource -Suite Setup Setup IETF Routing -Suite Teardown Cleanup IETF Routing -Test Teardown Restore Initial Running Datastore - -*** Variables *** -${Xpath Routing} /ietf-routing:routing -${Operational Datastore} operational -${Running Datastore} running - - -*** Keywords *** -Setup IETF Routing - [Documentation] Create a default connection and running and operational sessions - Start Plugin - ${Connection Default}= Open Sysrepo Connection - Set Global Variable ${Connection Default} - Init Running Session - Init Operational Session - -Start Plugin - ${Plugin}= Start Process %{SYSREPO_ROUTING_PLUGIN_PATH} - Set Suite Variable ${Plugin} - Wait For Process ${Plugin} timeout=2s on_timeout=continue - -Init Running Session - ${Session Running}= Open Datastore Session ${Connection Default} ${Running Datastore} - Set Global Variable ${Session Running} - ${Routing Init Running Str}= Get Datastore Data - ... ${Connection Default} - ... ${Session RUnning} - ... ${Xpath Routing} - ... json - Set Global Variable ${Routing Init Running Str} - &{Routing Init Running JSON}= Convert String To JSON ${Routing Init Running Str} - Set Global Variable ${Routing Init Running JSON} - -Init Operational Session - ${Session Operational}= Open Datastore Session ${Connection Default} ${Operational Datastore} - Set Global Variable ${Session Operational} - ${Routing Init Operational Str}= Get Datastore Data - ... ${Connection Default} - ... ${Session Operational} - ... ${Xpath Routing} - ... json - Set Global Variable ${Routing Init Operational Str} - &{Routing Init Operational JSON}= Convert String To JSON ${Routing Init Operational Str} - Set Global Variable ${Routing Init Operational JSON} - -Cleanup IETF Routing - [Documentation] Restore initial running datastore - Terminate Process ${Plugin} - Close All Sysrepo Connections And Sessions +Test Setup Connect Routing +Test Teardown Cleanup Routing From 77b2a9f1b2e48c33b51c33ed32d4ad63bd1e803b Mon Sep 17 00:00:00 2001 From: andrej Date: Wed, 11 Jan 2023 10:15:46 +0100 Subject: [PATCH 5/6] integration-tests: update readme - refactor --- tests/integration/robot-ietf-interfaces/README.md | 7 +++++-- tests/integration/robot-ietf-routing/README.md | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/integration/robot-ietf-interfaces/README.md b/tests/integration/robot-ietf-interfaces/README.md index 08f54481..7fdb4685 100644 --- a/tests/integration/robot-ietf-interfaces/README.md +++ b/tests/integration/robot-ietf-interfaces/README.md @@ -2,8 +2,11 @@ Robot framework tests via the Sysrepo robot library. ## `__init__.robot` -Initializes a default Sysrepo connection as well as a running datastore session at the start of each test. -At the end of a test, the initial datastore data is restored as well as all connections and sessions being closed. +Starts the plugin, nitializes a default Sysrepo connection as well as a running datastore session at the start of each test. +At the end of a test, the initial datastore data is restored and check for success as well as all connections and sessions being closed. + +## `InterfacesInit.resource` +Contains all the keywords used for test setup/teardown in `__init__.robot` ## `InterfaceTests.robot`, `IpTests.robot` These files contain integration test cases diff --git a/tests/integration/robot-ietf-routing/README.md b/tests/integration/robot-ietf-routing/README.md index ddf46f34..b14720f7 100644 --- a/tests/integration/robot-ietf-routing/README.md +++ b/tests/integration/robot-ietf-routing/README.md @@ -2,8 +2,11 @@ Robot framework tests via the Sysrepo robot library. ## `__init__.robot` -Initializes a default Sysrepo connection as well as running and operational datastore sessions at the start of each test. -At the end of a test, the initial datastore data is restored as well as all connections and sessions being closed. +Starts the plugin, initializes a default Sysrepo connection as well as running and operational datastore sessions at the start of each test. +At the end of a test, the initial datastore data is restored and checked for success as well as all connections and sessions being closed. + +## `RoutingInit.resource` +Contains all the keywords used for test setup/teardown in `__init__.robot` ## `InterfaceTests.robot`, `RoutesTests.robot`, `StaticRoutesTests.robot` These files contain integration test cases From 965b6527973115dbc5f8b6a68e59bbce70607916 Mon Sep 17 00:00:00 2001 From: andrej Date: Wed, 11 Jan 2023 10:59:20 +0100 Subject: [PATCH 6/6] integration-tests: add set plugin startup time env var --- tests/integration/README.md | 2 ++ .../robot-ietf-interfaces/InterfaceInit.resource | 10 ++++++---- .../robot-ietf-routing/RoutingInit.resource | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/integration/README.md b/tests/integration/README.md index 4962fd0a..7447c3e0 100644 --- a/tests/integration/README.md +++ b/tests/integration/README.md @@ -65,6 +65,8 @@ OK ## Robot framework Note the root privileges when invoking the command (datastore permission issues otherwise, item not found): +The plugin wait start time can be modified via the env var `SYSREPO_INTEGRATION_PLUGIN_TIMEOUT_SECONDS`. The default value is `0.5s`. It's set in `robot-ietf-interfaces/InterfacesInit.resource` and `robot-ietf-routing/RoutingInit.resource`. + To test the interfaces plugin (change env var path): ``` # SYSREPO_INTERFACES_PLUGIN_PATH=/path/to/interfaces/plugin/executable robot robot-ietf-interfaces diff --git a/tests/integration/robot-ietf-interfaces/InterfaceInit.resource b/tests/integration/robot-ietf-interfaces/InterfaceInit.resource index 9b7a15a1..2ec91f4c 100644 --- a/tests/integration/robot-ietf-interfaces/InterfaceInit.resource +++ b/tests/integration/robot-ietf-interfaces/InterfaceInit.resource @@ -4,13 +4,15 @@ Library RPA.JSON Library Process *** Variables *** -${Xpath Interfaces} /ietf-interfaces:interfaces -${Running Datastore} running +${Xpath Interfaces} /ietf-interfaces:interfaces +${Running Datastore} running +${Plugin Timeout Seconds Default} 0.5s +${Plugin Timeout Seconds} %{SYSREPO_INTEGRATION_PLUGIN_TIMEOUT_SECONDS=${Plugin Timeout Seconds Default}} *** Keywords *** Restore Initial Running Datastore Edit Datastore Config ${Connection Default} ${Session Running} ${If Init Str} json - Check If Datastore Is Restored + #Check If Datastore Is Restored Check If Datastore Is Restored [Documentation] Make sure the initial datastore is restored @@ -46,7 +48,7 @@ Cleanup Interfaces Start Plugin ${Plugin}= Start Process %{SYSREPO_INTERFACES_PLUGIN_PATH} Set Global Variable ${Plugin} - Wait For Process ${Plugin} timeout=0.1s on_timeout=continue + Wait For Process ${Plugin} timeout=${Plugin Timeout Seconds} on_timeout=continue Stop Plugin Terminate Process ${Plugin} diff --git a/tests/integration/robot-ietf-routing/RoutingInit.resource b/tests/integration/robot-ietf-routing/RoutingInit.resource index 6132a4fa..6678af28 100644 --- a/tests/integration/robot-ietf-routing/RoutingInit.resource +++ b/tests/integration/robot-ietf-routing/RoutingInit.resource @@ -6,7 +6,8 @@ Library Process *** Variables *** ${Xpath Routing} /ietf-routing:routing ${Running Datastore} running -${Plugin Timeout Seconds} 0.5s +${Plugin Timeout Seconds Default} 0.5s +${Plugin Timeout Seconds} %{SYSREPO_INTEGRATION_PLUGIN_TIMEOUT_SECONDS=${Plugin Timeout Seconds Default}} *** Keywords *** Restore Initial Running Datastore