Feature 11001: Robot framework linting for E2E tests
[osm/tests.git] / robot-systest / lib / nst_lib.resource
diff --git a/robot-systest/lib/nst_lib.resource b/robot-systest/lib/nst_lib.resource
new file mode 100644 (file)
index 0000000..0bb2e1b
--- /dev/null
@@ -0,0 +1,57 @@
+*** Comments ***
+#   Copyright 2020 Atos
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+
+
+*** Settings ***
+Documentation   Library providing keywords for CRUD operations over Network Slice Templates with OSM client.
+Library   OperatingSystem
+
+
+*** Variables ***
+${SUCCESS_RETURN_CODE}   0
+${NST_DELETE_MAX_WAIT_TIME}   1min
+${NST_DELETE_POL_TIME}   15sec
+
+
+*** Keywords ***
+Get NST List
+    [Documentation]   Get the list of Network Slice Templates (NST) and log it.
+    ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-list
+    Log   ${stdout}
+    Log   ${rc}
+    Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
+
+Create NST
+    [Documentation]   Upload a Network Slice Template (NST) to OSM and return the id.
+    [Arguments]   ${nst}
+    ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-create ${nst}
+    Log   ${stdout}
+    Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
+    RETURN   ${stdout}
+
+Delete NST
+    [Documentation]   Delete a Network Slice Template (NST) from OSM.
+    [Arguments]   ${nst_id}
+    ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-delete ${nst_id}
+    Log   ${stdout}
+    Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
+    Wait Until Keyword Succeeds   ${NST_DELETE_MAX_WAIT_TIME}   ${NST_DELETE_POL_TIME}   Check For NST   ${nst_id}
+
+Check For NST
+    [Documentation]   Check that a Network Slice Template (NST) exists in OSM.
+    [Arguments]   ${nst_id}
+    ${rc}   ${stdout}=   Run And Return Rc And Output   osm netslice-template-list | awk '{print $2}' | grep ${nst_id}
+    Log   ${rc},${stdout}
+    Should Not Be Equal As Strings   ${stdout}   ${nst_id}