{"id":1668,"date":"2023-03-21T23:10:51","date_gmt":"2023-03-21T23:10:51","guid":{"rendered":"https:\/\/community.5gasp.eu\/?page_id=1668"},"modified":"2023-03-21T23:10:52","modified_gmt":"2023-03-21T23:10:52","slug":"how-to-test-your-vnfs-with-the-robot-framework","status":"publish","type":"page","link":"https:\/\/community.5gasp.eu\/index.php\/how-to-test-your-vnfs-with-the-robot-framework\/","title":{"rendered":"How to test your VNFs with the Robot Framework"},"content":{"rendered":"\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Robot Framework<\/h3>\n\n\n\n<p>For this tutorial, we will use the <strong>Robot Framework<\/strong>, which is an open source framework that is used to test automation. Obviously, there are similar tools that you can also use.<\/p>\n\n\n\n<p>The robot tests can analyse the connection between 2 VNFs, but they can do a lot of different things. For example, it can test the connection between 2 VMs.<\/p>\n\n\n\n<p>The tests performed for 2 VNFs can be:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>BandWidth<\/li>\n\n\n\n<li>Open Ports<\/li>\n\n\n\n<li>Packet Loss<\/li>\n\n\n\n<li>Transmission Speed<\/li>\n\n\n\n<li>Jitter<\/li>\n\n\n\n<li>etc<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Installation<\/h3>\n\n\n\n<p>Firs of all, you need to install the robot framework in your machine:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"938\" height=\"83\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-37.png\" alt=\"\" class=\"wp-image-1669\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-37.png 938w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-37-300x27.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-37-768x68.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-37-611x54.png 611w\" sizes=\"auto, (max-width: 938px) 100vw, 938px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In this case, we will be testing the <strong>Jitter<\/strong>. Before that, create the needed files:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"936\" height=\"171\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-38.png\" alt=\"\" class=\"wp-image-1670\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-38.png 936w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-38-300x55.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-38-768x140.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-38-611x112.png 611w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>After that, you can check the structure of your file using the tree command:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"936\" height=\"137\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-40.png\" alt=\"\" class=\"wp-image-1672\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-40.png 936w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-40-300x44.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-40-768x112.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-40-611x89.png 611w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Code<\/h3>\n\n\n\n<p>To avoid changing the variables in the script, we will use environment variables:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"939\" height=\"310\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-41.png\" alt=\"\" class=\"wp-image-1673\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-41.png 939w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-41-300x99.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-41-768x254.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-41-611x202.png 611w\" sizes=\"auto, (max-width: 939px) 100vw, 939px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>As you can see, we defined the <strong>IP<\/strong> and <strong>credentials<\/strong> for both VNFs.<\/p>\n\n\n\n<p>The <strong>username<\/strong> and <strong>password<\/strong> also need to be defined because we will be executing commands through SSH.<\/p>\n\n\n\n<p>Finally, the last 2 commands define the <strong>comparator<\/strong> and the <strong>threshold<\/strong> for the Jitter.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">jitter\/jitter.py<\/h4>\n\n\n\n<p>Now, we can start to edit the python script:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"935\" height=\"410\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-42.png\" alt=\"\" class=\"wp-image-1674\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-42.png 935w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-42-300x132.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-42-768x337.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-42-611x268.png 611w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-42-800x350.png 800w\" sizes=\"auto, (max-width: 935px) 100vw, 935px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>As you can see, we are using the environment variables to define the IPs and credentials of the machines.<\/p>\n\n\n\n<p>After that, we are checking if the needed packages are installed and, if not, install them. This can also be done manually.<\/p>\n\n\n\n<p>The <strong><code>paramiko<\/code><\/strong> package is used to run commands through SSH in each VNF.<\/p>\n\n\n\n<p>After that initial code, we can make the test function:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"935\" height=\"532\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-43.png\" alt=\"\" class=\"wp-image-1675\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-43.png 935w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-43-300x171.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-43-768x437.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-43-611x348.png 611w\" sizes=\"auto, (max-width: 935px) 100vw, 935px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In the first part, we are connecting to each VNF using an SSH client from the <strong><code>paramiko<\/code><\/strong> package.<\/p>\n\n\n\n<p>Having the connection to the VNFs, in the second part, we are executing the commands to obtain the <strong>Jitter<\/strong>, using <strong><code>iperf3<\/code><\/strong>, and then returning it.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">jitter\/testJitter.robot<\/h4>\n\n\n\n<p>Now, we will edit our robot file:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"937\" height=\"365\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-44.png\" alt=\"\" class=\"wp-image-1676\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-44.png 937w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-44-300x117.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-44-768x299.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-44-611x238.png 611w\" sizes=\"auto, (max-width: 937px) 100vw, 937px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>In <strong><code>*** Settings ***<\/code><\/strong>, we are defining the python script to be used (jitter.py), which we just created in the previous section.<\/p>\n\n\n\n<p>Inside <strong><code>*** Test Cases ***<\/code><\/strong> we can define the test itself.<\/p>\n\n\n\n<p>Firstly, we are assigning the environment variable <strong><code>jitter_comparator<\/code><\/strong> to the comparator itself. In our case, since our EV had the value <strong><code>less_or_equal_than<\/code><\/strong>, the comparator will have the value <strong><code>&lt;=<\/code><\/strong>.<\/p>\n\n\n\n<p>Then, using the returned jitter value from the python script, the robot test will compare it to our threshold, defined in our EV <strong><code>jitter_threshold<\/code><\/strong> (<strong>0.03<\/strong>).<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Iperf3<\/h4>\n\n\n\n<p>Before running the test, we need to make sure that the <strong><code>iperf3<\/code><\/strong> package is installed in the VNFs, so the jitter can be obtained.<\/p>\n\n\n\n<p>For that, you have 2 options:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install through SSH command in each VNF: <strong><code>sudo apt-get install iperf3<\/code><\/strong><\/li>\n\n\n\n<li>Through the VNF cloud-init files<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Run the test<\/h3>\n\n\n\n<p>Make sure you exported the environment variables.<\/p>\n\n\n\n<p>With that in mind, we can now run our test:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"938\" height=\"86\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-45.png\" alt=\"\" class=\"wp-image-1677\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-45.png 938w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-45-300x28.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-45-768x70.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-45-611x56.png 611w\" sizes=\"auto, (max-width: 938px) 100vw, 938px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>If everything goes accordingly, you should obtain this output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"939\" height=\"326\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-46.png\" alt=\"\" class=\"wp-image-1678\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-46.png 939w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-46-300x104.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-46-768x267.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-46-611x212.png 611w\" sizes=\"auto, (max-width: 939px) 100vw, 939px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>As you can see, the test was successful.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Logs<\/h3>\n\n\n\n<p>The robot framework automatically generates a log.html file that contains the test details:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"936\" height=\"306\" src=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-47.png\" alt=\"\" class=\"wp-image-1679\" srcset=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-47.png 936w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-47-300x98.png 300w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-47-768x251.png 768w, https:\/\/community.5gasp.eu\/wp-content\/uploads\/2023\/03\/image-47-611x200.png 611w\" sizes=\"auto, (max-width: 936px) 100vw, 936px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>As it is visible, you get a very detailed description on what happened, like the values obtained and each step of the test.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Materials<\/h2>\n\n\n\n<p>For a better description of the tutorial, you can check our video\u00a0<a href=\"https:\/\/www.youtube.com\/watch?v=p7zrQcLs9cg\">here<\/a>.<\/p>\n\n\n\n<p>You can also check a PDF version of this tutorial\u00a0<a href=\"https:\/\/community.5gasp.eu\/wp-content\/uploads\/2022\/04\/test_your_vnf.pdf\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Robot Framework For this tutorial, we will use the Robot Framework, which is an open source framework that is used to test automation. Obviously, there are similar tools that you can also use. The robot tests can analyse the connection between 2 VNFs, but they can do a lot of [\u2026]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"pg_page_styles":[],"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"footnotes":""},"class_list":["post-1668","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages\/1668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/comments?post=1668"}],"version-history":[{"count":2,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages\/1668\/revisions"}],"predecessor-version":[{"id":1681,"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/pages\/1668\/revisions\/1681"}],"wp:attachment":[{"href":"https:\/\/community.5gasp.eu\/index.php\/wp-json\/wp\/v2\/media?parent=1668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}