Add system test for the northbound API in NEMO project. 57/32557/27
authorZhang Yali <zhangyali369@huawei.com>
Thu, 14 Jan 2016 10:51:18 +0000 (18:51 +0800)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 28 Jan 2016 00:59:04 +0000 (00:59 +0000)
The main test includes:
- Add predefined role of users, which inludes tenant and admin
- Add predefined node type and connection type
- register a user whose role is tenant (create a vn space)
- In this vn space, issue an intent, that is, create two nodes and one connection
between them.

TODO list:
- Use customized switch to consruct a physical topology
- Test the intent result on the physical network, such as, ping

Change-Id: I185447428fe6c5e78176a210687e6f1f48008cb3
Signed-off-by: Zhang Yali <zhangyali369@huawei.com>
csit/suites/nemo/engine/NEMO_ENGINE.robot
csit/variables/Variables.py
csit/variables/nemo/intent-node-host.json [new file with mode: 0644]
csit/variables/nemo/predefine/connection.json [new file with mode: 0644]
csit/variables/nemo/predefine/node.json [new file with mode: 0644]
csit/variables/nemo/predefine/role.json [new file with mode: 0644]
csit/variables/nemo/register-user.json [new file with mode: 0644]
csit/variables/nemo/structure-intent.json [new file with mode: 0644]

index b95bfa47fef90005ed25a427091b1495167e2712..366b2f509abaa88debac19d60ff3d929a699b354 100644 (file)
@@ -3,17 +3,60 @@ Documentation     Test suite for nemo engine functionality
 Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
 Suite Teardown    Delete All Sessions
 Library           RequestsLibrary
+Library           OperatingSystem
 Library           ../../../libraries/Common.py
 Variables         ../../../variables/Variables.py
 Resource          ../../../libraries/Utils.robot
 
 *** Variables ***
-${REST_CONTEXT}    /restconf/modules
+${REGISTER_TENANT_FILE}     ${CURDIR}/../../../variables/nemo/register-user.json
+${STRUCTURE_HOST_FILE}      ${CURDIR}/../../../variables/nemo/intent-node-host.json
+${STRUCTURE_INTENT_FILE}      ${CURDIR}/../../../variables/nemo/structure-intent.json
+${PREDEFINE_ROLE_FILE}        ${CURDIR}/../../../variables/nemo/predefine/role.json
+${PREDEFINE_NODE_FILE}        ${CURDIR}/../../../variables/nemo/predefine/node.json
+${PREDEFINE_CONNECTION_FILE}        ${CURDIR}/../../../variables/nemo/predefine/connection.json
 
 *** Test Cases ***
-Get Controller Modules
-    [Documentation]    Get the controller modules via Restconf
-    ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}
+Add Pre-define Role
+    [Documentation]    Add Pre-define Role
+    [Tags]    Put
+    ${body}    OperatingSystem.Get File   ${PREDEFINE_ROLE_FILE}
+    ${resp}    RequestsLibrary.Put    session    ${PREDEFINE_ROLE_URI}     data=${body}    headers=${HEADERS_YANG_JSON}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Add Pre-define Node
+    [Documentation]    Add Pre-define Node
+    [Tags]    Put
+    ${body}    OperatingSystem.Get File   ${PREDEFINE_NODE_FILE}
+    ${resp}    RequestsLibrary.Put    session    ${PREDEFINE_NODE_URI}     data=${body}    headers=${HEADERS_YANG_JSON}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Add Pre-define Connection
+    [Documentation]    Add Pre-define Connection
+    [Tags]    Put
+    ${body}    OperatingSystem.Get File    ${PREDEFINE_CONNECTION_FILE}
+    ${resp}    RequestsLibrary.Put    session    ${PREDEFINE_CONNECTION_URI}    data=${body}    headers=${HEADERS_YANG_JSON}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Register Tenant
+    [Documentation]    Register Tenant
+    [Tags]    Post
+    ${body}    OperatingSystem.Get File   ${REGISTER_TENANT_FILE}
+    ${resp}    RequestsLibrary.Post    session    ${REGISTER_TENANT_URI}    data=${body}    headers=${HEADERS_YANG_JSON}
     Log    ${resp.content}
     Should Be Equal As Strings    ${resp.status_code}    200
-    Should Contain    ${resp.content}    ietf-restconf
+
+Add Host Intent
+    [Documentation]   Add Host Intent
+    [Tags]    Post
+    ${body}    OperatingSystem.Get File    ${STRUCTURE_HOST_FILE}
+    ${resp}    RequestsLibrary.Post Request    session    ${STRUCTURE_INTENT_URI}    data=${body}    headers=${HEADERS_YANG_JSON}
+    Log    ${resp.content}
+    Should Be Equal As Strings    ${resp.status_code}    200
+
+Add Structure Intent
+    [Documentation]   Add Structure Intent
+    [Tags]    Post
+    ${body}    OperatingSystem.Get File    ${STRUCTURE_INTENT_FILE}
+    ${resp}    RequestsLibrary.Post Request    session    ${STRUCTURE_INTENT_URI}    data=${body}    headers=${HEADERS_YANG_JSON}
+    Should Be Equal As Strings    ${resp.status_code}    200
index 4b01a97a791a0ab556790db05612bc78ad623286..8c1840bfa44ea3aa369b081a7a04d463d9fa938b 100644 (file)
@@ -116,6 +116,14 @@ CONFIG_API = '/restconf/config'
 OPERATIONAL_API = '/restconf/operational'
 MODULES_API = '/restconf/modules'
 
+# NEMO Variables
+PREDEFINE_ROLE_URI = '/restconf/config/nemo-user:user-roles'
+PREDEFINE_NODE_URI = '/restconf/config/nemo-object:node-definitions'
+PREDEFINE_CONNECTION_URI = '/restconf/config/nemo-object:connection-definitions'
+REGISTER_TENANT_URI = '/restconf/operations/nemo-intent:register-user'
+STRUCTURE_INTENT_URI = '/restconf/operations/nemo-intent:structure-style-nemo-update'
+GET_INTENTS_URI = '/retconf/config/intent:intents'
+
 # TOKEN
 AUTH_TOKEN_API = '/oauth2/token'
 REVOKE_TOKEN_API = '/oauth2/revoke'
@@ -178,9 +186,6 @@ CONTROLLER_STOP_TIMEOUT = 120  # Max number of seconds test will wait for a cont
 TOPOLOGY_URL = 'network-topology:network-topology/topology'
 SEND_ACCEPT_XML_HEADERS = {'Content-Type': 'application/xml', 'Accept': 'application/xml'}
 
-# Test deadlines global control
-ENABLE_GLOBAL_TEST_DEADLINES = True
-
 # Deprecated old variables, to be removed once all tests that need them are
 # updated to use the new names.
 CONTROLLER = ODL_SYSTEM_IP
diff --git a/csit/variables/nemo/intent-node-host.json b/csit/variables/nemo/intent-node-host.json
new file mode 100644 (file)
index 0000000..cce7bbb
--- /dev/null
@@ -0,0 +1,29 @@
+{
+    "input":{
+            "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
+            "objects":{
+            "node":[
+                    {
+                        "node-name": "server1",
+                        "node-type": "host",
+                        "node-id":"7b796915-adf4-4356-b5ca-de005ac410c1"
+                    },
+                    {
+                        "node-name": "server2",
+                        "node-type": "host",
+                        "node-id":"22282cca-9a13-4d0c-a67e-a933ebb0b0ae"
+                    },
+                    {
+                        "node-name": "vm1",
+                        "node-type": "host",
+                        "node-id":"1eaf9a67-a171-42a8-9282-71cf702f61dd"
+                    },
+                    {
+                        "node-name": "vm2",
+                        "node-type": "host",
+                        "node-id":"6c787caa-156a-49ed-8546-547bdccf283c"
+                    }
+            ]
+        }
+   }
+}
diff --git a/csit/variables/nemo/predefine/connection.json b/csit/variables/nemo/predefine/connection.json
new file mode 100644 (file)
index 0000000..6e7bce6
--- /dev/null
@@ -0,0 +1,42 @@
+{
+     "connection-definitions": {
+          "connection-definition":[
+                    {
+                         "connection-type": "p2p",
+                         "property-definition": [
+                                   {
+                                        "property-name": "bandwidth",
+                                        "property-value-type": "int"
+                                   }
+                              ]
+                    },
+                    {
+                         "connection-type": "p2mp",
+                         "property-definition": [
+                                   {
+                                        "property-name": "bandwidth",
+                                        "property-value-type": "int"
+                                   }
+                              ]
+                    },
+                    {
+                         "connection-type": "mesh",
+                         "property-definition": [
+                                   {
+                                        "property-name": "bandwidth",
+                                        "property-value-type": "int"
+                                   }
+                              ]
+                    },
+                    {
+                         "connection-type": "chain",
+                         "property-definition": [
+                                   {
+                                        "property-name": "bandwidth",
+                                        "property-value-type": "int"
+                                   }
+                              ]
+                    }
+               ]
+          }
+}
diff --git a/csit/variables/nemo/predefine/node.json b/csit/variables/nemo/predefine/node.json
new file mode 100644 (file)
index 0000000..cd6681b
--- /dev/null
@@ -0,0 +1,125 @@
+{
+          "node-definitions": {
+                    "node-definition": [
+                              {
+                                   "node-type": "host",
+                                   "property-definition": [
+                                             {
+                                                  "property-name": "name",
+                                                  "property-value-type": "string"
+                                             },
+                                             {
+                                                  "property-name": "location",
+                                                  "property-value-type": "string"
+                                             },
+                                             {
+                                                  "property-name": "mac-address",
+                                                  "property-value-type": "string"
+                                             },
+                                             {
+                                                  "property-name": "ip-address",
+                                                  "property-value-type": "string"
+                                             }
+                                        ]
+                              },
+                              {
+                                   "node-type": "l2-group",
+                                   "property-definition": [
+                                             {
+                                                  "property-name": "ip-prefix",
+                                                  "property-value-type": "string"
+                                             },
+                                             {
+                                                  "property-name": "gateway-ip",
+                                                  "property-value-type": "string"
+                                             },
+                                             {
+                                                  "property-name": "location",
+                                                  "property-value-type": "string"
+                                             }
+                                        ]
+                              },
+                              {
+                                   "node-type": "l3-group",
+                                   "property-definition": [
+                                             {
+                                                  "property-name": "ip-prefix",
+                                                  "property-value-type": "string"
+                                             }
+                                        ]
+                              },
+                              {
+                                   "node-type": "ext-group",
+                                   "property-definition": [
+                                             {
+                                                  "property-name": "location",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             },
+                                             {
+                                                  "property-name": "ac-info-network",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             },
+                                             {
+                                                  "property-name": "ac-info-protocol",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                              },
+                                             {
+                                                  "property-name": "ip-prefix",
+                                                  "property-value-type": "string"
+                                              }
+                                        ]
+                              },
+                              {
+                                   "node-type": "chain-group"
+                              },
+                              {
+                                   "node-type": "fw",
+                                   "property-definition": [
+                                             {
+                                                  "property-name": "location",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             },
+                                             {
+                                                  "property-name": "operating-mode",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             }
+                                        ]
+                              },
+                              {
+                                   "node-type": "lb",
+                                   "property-definition": [
+                                             {
+                                                  "property-name": "location",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             },
+                                             {
+                                                  "property-name": "operating-mode",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             }
+                                        ]
+                              },
+                              {
+                                   "node-type": "cache",
+                                   "property-definition": [
+                                             {
+                                                  "property-name": "location",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             },
+                                             {
+                                                  "property-name": "operating-mode",
+                                                  "property-value-type": "string",
+                                                  "is-required": "required"
+                                             }
+                                        ]
+                              }
+                         ]
+                    }
+}
diff --git a/csit/variables/nemo/predefine/role.json b/csit/variables/nemo/predefine/role.json
new file mode 100644 (file)
index 0000000..5204538
--- /dev/null
@@ -0,0 +1,10 @@
+{
+    "user-roles": {
+            "user-role": [
+                {
+                    "role-name": "tenant",
+                    "role-description": "It's a non-administor user"
+                }
+            ]
+    }
+}
diff --git a/csit/variables/nemo/register-user.json b/csit/variables/nemo/register-user.json
new file mode 100644 (file)
index 0000000..1c4d00f
--- /dev/null
@@ -0,0 +1,8 @@
+{
+    "input":{
+                "user-id":"14ce424a-3e50-4a2a-ad5c-b29845158c8b",
+                "user-name":"user2",
+                "user-password":"abc",
+                "user-role":"tenant"
+            }
+}
\ No newline at end of file
diff --git a/csit/variables/nemo/structure-intent.json b/csit/variables/nemo/structure-intent.json
new file mode 100644 (file)
index 0000000..4ecb316
--- /dev/null
@@ -0,0 +1,158 @@
+{
+    "input":{
+            "user-id": "14ce424a-3e50-4a2a-ad5c-b29845158c8b",
+            "objects":{
+            "node":[
+                    {
+                        "node-name": "dmz",
+                        "node-type": "l2-group",
+                        "sub-node": [
+                                        {
+                                          "node-id":"7b796915-adf4-4356-b5ca-de005ac410c1",
+                                          "order":"0"
+                                        }
+                                ],
+                        "property": [
+                                        {
+                                            "property-name": "location",
+                                            "property-values": {
+                                                    "string-value": [
+                                                            {
+                                                              "order": "0",
+                                                              "value": "openflow:3"
+                                                            }
+                                                           ]
+                                                   }
+                                        },
+                                        {
+                                            "property-name": "ip-prefix",
+                                            "property-values": {
+                                                    "string-value": [
+                                                            {
+                                                              "order": "0",
+                                                              "value": "192.168.11.0/24"
+                                                            }
+                                                        ]
+                                                    }
+                                        },
+                                        {
+                                            "property-name": "gateway-ip",
+                                            "property-values": {
+                                                      "string-value": [
+                                                            {
+                                                              "order": "0",
+                                                              "value": "192.168.11.1"
+                                                            }
+                                                        ]
+                                                    }
+                                              }
+                                            ],
+                            "node-id": "b46cfa7f-93a3-43f4-ac20-09307c75feca"
+                    },
+                    {
+                        "node-name": "interior",
+                        "node-type": "l2-group",
+                        "sub-node": [
+                                        {
+                                          "node-id":"22282cca-9a13-4d0c-a67e-a933ebb0b0ae",
+                                          "order":"0"
+                                        },
+                                        {
+                                          "node-id":"1eaf9a67-a171-42a8-9282-71cf702f61dd",
+                                          "order":"0"
+                                        }
+                                ],
+                        "property": [
+                                        {
+                                            "property-name": "location",
+                                            "property-values": {
+                                                    "string-value": [
+                                                            {
+                                                              "order": "0",
+                                                              "value": "openflow:3"
+                                                            }
+                                                           ]
+                                                   }
+                                        },
+                                        {
+                                            "property-name": "ip-prefix",
+                                            "property-values": {
+                                                    "string-value": [
+                                                            {
+                                                              "order": "0",
+                                                              "value": "192.168.12.0/24"
+                                                            }
+                                                        ]
+                                                    }
+                                        },
+                                        {
+                                            "property-name": "gateway-ip",
+                                            "property-values": {
+                                                      "string-value": [
+                                                            {
+                                                              "order": "0",
+                                                              "value": "192.168.12.1"
+                                                            }
+                                                        ]
+                                                    }
+                                              }
+                                            ],
+                            "node-id": "175425f7-c9c9-474a-962c-70cb6c180d4d"
+                    }
+            ],
+            "connection":[
+                        {
+                            "connection-name": "c1",
+                            "connection-id": "e0d56fee-7235-4748-a2a1-eb5e3733d866",
+                            "end-node": [
+                              {
+                                "order": "0",
+                                "node-id": "b46cfa7f-93a3-43f4-ac20-09307c75feca"
+                              },
+                              {
+                                "order": "0",
+                                "node-id": "175425f7-c9c9-474a-962c-70cb6c180d4d"
+                              }
+                            ],
+                            "connection-type": "p2p"
+                        }
+            ],
+            "flow":[
+                        {
+                            "match-item": [
+                                {
+                                    "match-item-value": {
+                                        "string-value": "192.168.12.0/24"
+                                    },
+                                    "match-item-name": "src-ip"
+                                },
+                                {
+                                    "match-item-value": {
+                                        "string-value": "192.168.11.0/24"
+                                    },
+                                    "match-item-name": "dst-ip"
+                                }
+                            ],
+                            "flow-id": "cf48eeee-882e-435a-adf4-ea22ba88331f",
+                            "flow-name": "f1"
+                        }
+            ]
+            },
+            "operations":{
+            "operation":[
+                       {
+                            "operation-name": "o1",
+                            "target-object": "cf48eeee-882e-435a-adf4-ea22ba88331f",
+                            "priority":"0",
+                            "operation-id": "619ee3bb-1e40-480f-b0fa-a331820a5518",
+                            "action":[
+                                        {
+                                            "action-name":"allow",
+                                            "order":"0"
+                                        }
+                                   ]
+                        }
+                ]
+            }
+   }
+}