HPA Score Multi-Objective function tests 87/66787/5
authorDileep Ranganathan <dileep.ranganathan@intel.com>
Fri, 14 Sep 2018 19:12:56 +0000 (12:12 -0700)
committerDileep Ranganathan <dileep.ranganathan@intel.com>
Sat, 15 Sep 2018 16:17:10 +0000 (09:17 -0700)
Added CSIT for HPA Score Multi-Objective function

Change-Id: If2da01302f7b47507c212278b1cc42c59a52e168
Issue-ID: OPTFRA-313
Signed-off-by: Dileep Ranganathan <dileep.ranganathan@intel.com>
test/csit/tests/optf-has/has/data/plan_with_hpa_score_multi_objective.json [new file with mode: 0644]
test/csit/tests/optf-has/has/optf_has_test.robot

diff --git a/test/csit/tests/optf-has/has/data/plan_with_hpa_score_multi_objective.json b/test/csit/tests/optf-has/has/data/plan_with_hpa_score_multi_objective.json
new file mode 100644 (file)
index 0000000..55536f3
--- /dev/null
@@ -0,0 +1,237 @@
+{
+  "name": "vCPE-HPA-Requirement-Optional",
+  "template": {
+    "homing_template_version": "2017-10-10",
+    "parameters": {
+      "service_name": "Residential vCPE",
+      "service_id": "vcpe_service_id",
+      "customer_lat": 45.395968,
+      "customer_long": -71.135344,
+      "REQUIRED_MEM": 4,
+      "REQUIRED_DISK": 100,
+      "pnf_id": "some_pnf_id"
+    },
+    "locations": {
+      "customer_loc": {
+        "latitude": {
+          "get_param": "customer_lat"
+        },
+        "longitude": {
+          "get_param": "customer_long"
+        }
+      }
+    },
+    "demands": {
+      "vG": [
+        {
+          "inventory_provider": "aai",
+          "inventory_type": "cloud"
+        }
+      ]
+    },
+    "constraints": {
+      "constraint_vg_customer": {
+        "type": "distance_to_location",
+        "demands": [
+          "vG"
+        ],
+        "properties": {
+          "distance": "< 100 km",
+          "location": "customer_loc"
+        }
+      },
+      "hpa_constraint": {
+        "type": "hpa",
+        "demands": [
+          "vG"
+        ],
+        "properties": {
+          "evaluate": [
+            {
+              "flavorLabel": "flavor_label_1",
+              "flavorProperties": [
+                {
+                  "hpa-feature": "basicCapabilities",
+                  "hpa-version": "v1",
+                  "architecture": "generic",
+                  "mandatory": "True",
+                  "hpa-feature-attributes": [
+                    {
+                      "hpa-attribute-key": "numVirtualCpu",
+                      "hpa-attribute-value": "4",
+                      "operator": ">="
+                    },
+                    {
+                      "hpa-attribute-key": "virtualMemSize",
+                      "hpa-attribute-value": "8",
+                      "operator": ">=",
+                      "unit": "GB"
+                    }
+                  ]
+                },
+                {
+                  "hpa-feature": "instructionSetExtensions",
+                  "hpa-version": "v1",
+                  "architecture": "Intel64",
+                  "mandatory": "True",
+                  "hpa-feature-attributes": [
+                    {
+                      "hpa-attribute-key": "instructionSetExtensions",
+                      "hpa-attribute-value": [
+                        "aes",
+                        "sse",
+                        "avx",
+                        "smt"
+                      ],
+                      "operator": "ALL",
+                      "unit": ""
+                    }
+                  ]
+                },
+                {
+                  "hpa-feature": "numa",
+                  "hpa-version": "v1",
+                  "architecture": "generic",
+                  "mandatory": "False",
+                  "score": "3",
+                  "hpa-feature-attributes": [
+                    {
+                      "hpa-attribute-key": "numaNodes",
+                      "hpa-attribute-value": "2",
+                      "operator": "="
+                    },
+                    {
+                      "hpa-attribute-key": "numaCpu-0",
+                      "hpa-attribute-value": "2",
+                      "operator": "="
+                    },
+                    {
+                      "hpa-attribute-key": "numaCpu-1",
+                      "hpa-attribute-value": "4",
+                      "operator": "="
+                    },
+                    {
+                      "hpa-attribute-key": "numaMem-0",
+                      "hpa-attribute-value": "2",
+                      "operator": "=",
+                      "unit": "GB"
+                    },
+                    {
+                      "hpa-attribute-key": "numaMem-1",
+                      "hpa-attribute-value": "4",
+                      "operator": "=",
+                      "unit": "GB"
+                    }
+                  ]
+                }
+              ]
+            },
+            {
+              "flavorLabel": "flavor_label_2",
+              "flavorProperties": [
+                {
+                  "hpa-feature": "basicCapabilities",
+                  "hpa-version": "v1",
+                  "architecture": "generic",
+                  "mandatory": "True",
+                  "hpa-feature-attributes": [
+                    {
+                      "hpa-attribute-key": "numVirtualCpu",
+                      "hpa-attribute-value": "4",
+                      "operator": ">="
+                    },
+                    {
+                      "hpa-attribute-key": "virtualMemSize",
+                      "hpa-attribute-value": "8",
+                      "operator": ">=",
+                      "unit": "GB"
+                    }
+                  ]
+                },
+                {
+                  "hpa-feature": "ovsDpdk",
+                  "hpa-version": "v1",
+                  "architecture": "generic",
+                  "mandatory": "False",
+                  "score": "5",
+                  "hpa-feature-attributes": [
+                    {
+                      "hpa-attribute-key": "dataProcessingAccelerationLibrary",
+                      "hpa-attribute-value": "v18.02",
+                      "operator": "="
+                    }
+                  ]
+                },
+                {
+                  "hpa-feature": "numa",
+                  "hpa-version": "v1",
+                  "architecture": "generic",
+                  "mandatory": "False",
+                  "score": "3",
+                  "hpa-feature-attributes": [
+                    {
+                      "hpa-attribute-key": "numaNodes",
+                      "hpa-attribute-value": "2",
+                      "operator": "="
+                    },
+                    {
+                      "hpa-attribute-key": "numaCpu-0",
+                      "hpa-attribute-value": "2",
+                      "operator": "="
+                    },
+                    {
+                      "hpa-attribute-key": "numaCpu-1",
+                      "hpa-attribute-value": "4",
+                      "operator": "="
+                    },
+                    {
+                      "hpa-attribute-key": "numaMem-0",
+                      "hpa-attribute-value": "2",
+                      "operator": "=",
+                      "unit": "GB"
+                    },
+                    {
+                      "hpa-attribute-key": "numaMem-1",
+                      "hpa-attribute-value": "4",
+                      "operator": "=",
+                      "unit": "GB"
+                    }
+                  ]
+                }
+              ]
+            }
+          ]
+        }
+      }
+    },
+    "optimization": {
+      "minimize": {
+        "sum": [
+          {
+            "product": [
+              100,
+              {
+                "distance_between": [
+                  "customer_loc",
+                  "vG"
+                ]
+              }
+            ]
+          },
+          {
+            "product": [
+              200,
+              {
+                "hpa_score": [
+                  "vG"
+                ]
+              }
+            ]
+          }
+        ]
+      }
+    }
+  },
+  "timeout": 5,
+  "limit": 3
+}
index deba647..3b3ee7a 100644 (file)
@@ -482,6 +482,41 @@ GetPlanWithHpaUnmatched
     Should Be Equal As Integers    ${resp.status_code}    200
     Should Be Equal    not found    ${resultStatus}
 
+# HPA Score Multi objective Optimization
+SendPlanWithHpaScoreMultiObj
+    [Documentation]    It sends a POST request to conductor
+    Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
+    ${data}=         Get Binary File     ${CURDIR}${/}data${/}plan_with_hpa_score_multi_objective.json
+    &{headers}=      Create Dictionary    Content-Type=application/json  Accept=application/json
+    ${resp}=         Post Request        optf-cond   /v1/plans     data=${data}     headers=${headers}
+    Log To Console              *********************
+    Log To Console              response = ${resp}
+    Log To Console              body = ${resp.text}
+    ${response_json}    json.loads    ${resp.content}
+    ${generatedPlanId}=    Convert To String      ${response_json['id']}
+    Set Global Variable     ${generatedPlanId}
+    Log To Console              generatedPlanId = ${generatedPlanId}
+    Should Be Equal As Integers    ${resp.status_code}    201
+    Sleep    60s    Wait Plan Resolution
+
+GetPlanWithHpaScoreMultiObj
+    [Documentation]    It sends a REST GET request to capture recommendations
+    Create Session   optf-cond            ${COND_HOSTNAME}:${COND_PORT}
+    &{headers}=      Create Dictionary    Content-Type=application/json  Accept=application/json
+    ${resp}=         Get Request        optf-cond   /v1/plans/${generatedPlanId}    headers=${headers}
+    Log To Console              *********************
+    Log To Console              response = ${resp}
+    ${response_json}    json.loads    ${resp.content}
+    ${resultStatus}=    Convert To String      ${response_json['plans'][0]['status']}
+    ${vim-id}=    Convert To String      ${response_json['plans'][0]['recommendations'][0]['vG']['candidate']['vim-id']}
+    # ${hpa_score}=    Convert To String      ${response_json['plans'][0]['recommendations']['vG']['hpa_score']}
+    Set Global Variable     ${resultStatus}
+    Log To Console              resultStatus = ${resultStatus}
+    Log To Console              body = ${resp.text}
+    Should Be Equal As Integers    ${resp.status_code}    200
+    Should Be Equal    done    ${resultStatus}
+    Should Be Equal    HPA-cloud_cloud-region-1    ${vim-id}
+
 
 *** Keywords ***