1.14.1 release
[testsuite.git] / README.md
1 # Getting Started
2
3 This repository contains the end-to-end testsuite of ONAP. It is based on the [Robot Framework](https://robotframework.org/#resources), which is a automation framework for test automation and robotic process automation.
4 This repo also makes use of a custom robot library - the `robotframework-onap` package - that provides common functions that are written in 'plain' python. The repository that defines this library is the [testsuite/python-testing-utils](https://gerrit.onap.org/r/admin/repos/testsuite/python-testing-utils).
5
6 ## Prerequisites
7
8 This guide assumes you have run git clone on https://gerrit.onap.org/r/testsuite.git
9
10 For more info please see the [Development Guide](https://wiki.onap.org/display/DW/Robot+Framework+Development+Guide)
11
12 ## Development Environment Setup
13
14 ### Create a virtual environment
15
16 ```sh
17 python3 -m venv .venv
18 ```
19
20 ```sh
21 source .venv/bin/activate
22 ```
23
24 ### Install dependencies
25
26 Make sure that you have activated the `venv` that you have created in the previous step. Then run
27
28 ```sh
29 pip install -r requirements.txt
30 ```
31
32 ### Proxy setup
33
34 Depending on your environment, it may be needed to configure proxy environment variables for your system.
35 For Windows, right click the Computer icon. Choose Properties from the context menu.
36 Click the Advanced system settings link. Click Environment Variables. In the section System Variables, click New.
37 In the New System Variable window, set the name as `HTTPS_PROXY` then specify the value of the `HTTPS_PROXY` environment variable as your proxy. Click OK. Close all remaining windows by clicking OK.
38
39 ## Project Setup
40
41 Note: You do not need to run these commands every time, only on a library update or initial checkout.
42
43 ```sh
44 ./setup.sh
45 ```
46
47 Note that this script will download the chromedriver for the current OS. The default is linux64 which will download the appropriate chromedriver to /usr/local/bin so that it will be in the execution PATH.
48
49 Windows and Mac hosts will download into the current working directory. Windows and MAC users will need to ensure that the driver is in the execution PATH.
50
51 ## Executing ETE Testcases
52
53 ### Overview
54 Two scripts have been provided in the root of the ete-testsuite project to enable test execution.
55
56 * `runTags.sh` - This shell uses Robot [Tags] to drive which tests are executed and is designed for automated testing.
57 * `oneTest.sh` - This shell is designed for unit testing of individual .robot files. It accepts a single argument identifying the `.robot` file in `robot/testsuites` to execute.
58
59 ### Invoke directly
60
61 ```sh
62 $ robot -V robot_properties.py robot/testsuites/health-check.robot
63 ...
64 ------------------------------------------------------------------------------
65 Mariadb Galera SO Connectivity Test                                   | FAIL |
66 catalogdb: 'error: pod, type/name or --filename must be specified' does not contain 'current database:'
67 ------------------------------------------------------------------------------
68 Health-Check :: Test that ONAP components are available via basic ... | FAIL |
69 66 critical tests, 1 passed, 65 failed
70 66 tests total, 1 passed, 65 failed
71 ==============================================================================
72 Output:  /home/ubuntu/development/onap/testsuite/output.xml
73 Log:     /home/ubuntu/development/onap/testsuite/log.html
74 Report:  /home/ubuntu/development/onap/testsuite/report.html
75 ```
76
77 #### Filter by tags
78
79 You can provide a `--include` or `-i` argument to filter the tests by tag.
80 Tags are declared in the `.robot` files. For instance
81
82 ```python
83 # excerpt from robot/testsuites/health-check.robot
84 *** Test Cases ***
85 Basic A&AI Health Check
86     [Tags]    health    core  health-aai
87     Run A&AI Health Check
88 ```
89
90 ```sh
91 $ robot -V robot_properties.py --include health-aai robot/testsuites/health-check.robot
92 ...
93 Enhanced A&AI Health Check                                            | FAIL |
94 ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /aai/v19/service-design-and-creation/models/model/AAI-HealthCheck-Dummy (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f9dd6aa06a0>: Failed to establish a new connection: [Errno -2] Name or service not known'))
95 ------------------------------------------------------------------------------
96 Health-Check :: Test that ONAP components are available via basic ... | FAIL |
97 2 critical tests, 0 passed, 2 failed
98 2 tests total, 0 passed, 2 failed
99 ==============================================================================
100 Output:  /home/ubuntu/development/onap/testsuite/output.xml
101 Log:     /home/ubuntu/development/onap/testsuite/log.html
102 Report:  /home/ubuntu/development/onap/testsuite/report.html
103 ```
104
105 #### Run/Debug inside Kubernetes cluster
106
107 ```sh
108 $ kubectl -n onap run tmp-testsuite -it --rm --restart=Nev
109 er --image=nexus3.onap.org:10001/onap/testsuite:latest -- /bin/bash
110 root@tmp-testsuite:/#
111 ```
112
113 ```sh
114 $ cd /var/opt/ONAP
115 $ root@tmp-testsuite:/var/opt/ONAP# ls -lh
116 total 48K
117 drwxr-xr-x 10 root root 4.0K Mar  3 08:03 demo
118 -rwxrwxrwx  1 root root 1.3K Mar  3 08:02 dnstraffic.sh
119 drwxr-xr-x  2 root root 4.0K Mar  3 08:03 html
120 drwxr-xr-x  1 root root 4.0K Mar  3 08:03 robot
121 -rwxrwxrwx  1 root root 2.9K Mar  3 08:02 runEteTag.sh
122 -rwxrwxrwx  1 root root 1016 Mar  3 08:02 runSoak.sh
123 -rwxrwxrwx  1 root root 2.5K Mar  3 08:02 runTags.sh
124 -rwxrwxrwx  1 root root 1.7K Mar  3 08:02 setup-hvves.sh
125 -rwxrwxrwx  1 root root 2.1K Mar  3 08:02 setup.sh
126 -rwxrwxrwx  1 root root 500 Mar   3 08:02 robot_properties.py
127 $ root@tmp-testsuite:/var/opt/ONAP# robot -V robot_properties.py --include health-aai robot/testsuites/health-check.robot
128 ```
129
130 #### runTags.sh
131
132 For further information on using Robot [Tags], see [Configuring Execution](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#configuring-execution) and [Simple Patterns](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#simple-patterns)
133
134 When executing tests via tags, all of the robot files in the project are scanned for tests cases with the specified tags.
135
136 There are 3 flavors of runTags.sh
137
138 * runTags.sh with no arguments. This defaults to the default tag or runTags.sh -i health
139 * runTags.sh with a single include tag. In this case the -i or --include may be omitted. So runTags.sh ete is the same as runTags.sh -i ete
140 * runTags.sh with multiple tags. In this case, tags must be accompanied by a -i/--include or -e/--exclude to properly identify the disposition of the tagged testcase.
141
142 ```sh
143 runTags.sh -i health -i ete -e garbage
144 ```
145
146 ## Contributing
147 Follow [Robot Framework Development Guide](https://wiki.onap.org/display/DW/Robot+Framework+Development+Guide).