aboutsummaryrefslogtreecommitdiffstats
path: root/infra-healthcheck/README.md
blob: 117bd96f9356ff28d6d1470a8a413fb4dd439390 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# infra-healthcheck

## Goal

This infra-healthcheck docker includes the test suites checking kubernetes and
healm charts of an ONAP deployment.

It includes 2 tests:

- onap-k8s: list pods, deployments, events, cm, ... For any faulty pod, it
  collects the logs and the describe. The success criteria is 100% of the pods
  are up and running
- onap-helm: list the helm charts. The success criteria is all the helm charts
  are completed.
- nodeport_ingress: check that we have a 1:1 correspondance between nodeports
  and ingress (run only when the env variable DEPLOY_SCENARIO includes ingress)

Please note that you will find another test (onap-k8s-teardown) in CI. It is exactly
the same than onap-k8s (status of the onap cluster) executed at the end of the
CI, after all the other tests. It allows to collect the logs of the components.

## Usage

### Configuration

Mandatory:

- The kubernetes configuration: usually hosted on the.kube/config of your
  jumphost. It corresponds the kubernetes credentials and are needed to perform
  the different operations. This file shall be copied in /root/.kube/config in
  the docker.

Optional:

- The local result directory path: to store the results in your local
  environement. It shall corresponds to the internal result docker path
  /var/lib/xtesting/results

### Command

You can run this docker by typing:

```
docker run -v <the kube config>:/root/.kube/config -v
<result directory>:/var/lib/xtesting/results
nexus3.onap.org:10003/onap/xtesting-infra-healthcheck:master
```

Options:

- \-r: by default the reporting to the Database is not enabled. You need to
  specify the -r option in the command line. Please note that in this case, you
  must precise some env variables.

environment variables:

- Mandatory (if you want to report the results in the database):
  - TEST_DB_URL: the url of the target Database with the env variable .
  - NODE_NAME: the name of your test environement. It must be declared in the
    test database (e.g. windriver-SB00)
- Optional:
  - INSTALLER_TYPE: precise how your ONAP has been installed (e.g. kubespray-oom,
    rke-oom)
  - BUILD_TAG: a unique tag of your CI system. It can be usefull to get all the
    tests of one CI run. It uses the regex (dai|week)ly-(.+?)-\[0-9]\* to find the
    version (e.g. daily-elalto-123456789).
  - DEPLOY_SCENARIO: your scenario deployment. ingress test run only if the
    scenario includes 'ingress'
  - ONAP_RELEASE: the name of the onap release in Helm. Default is "onap".
  - ONAP_HELM_LOG_PATH: the path where to retrieve specific logs that helm
    deploy has captured. you should add a volume if you want to retrieve them:
    `-v <the user home dir>/.helm/plugins/deploy/cache/onap/logs:/onap_helm_logs`.
    `/onap_helm_logs` is the default value.

The command becomes:

```
docker run -v <the kube config>:/root/.kube/config
-v <the user home dir>/.helm/plugins/deploy/cache/onap/logs:/onap_helm_logs
-v <result directory>:/var/lib/xtesting/results
nexus3.onap.org:10003/onap/xtesting-infra-healthcheck:master
/bin/bash -c "run_tests -r -t all"
```

Note that you can run only a subset of the tests and decide if you report the
results to the test BD or not.
The following commands are correct:

```
docker run -v <the kube config>:/root/.kube/config
-v <result directory>:/var/lib/xtesting/results
nexus3.onap.org:10003/onap/xtesting-infra-healthcheck:master
/bin/bash -c "run_tests -t onap-k8s"
```

```
docker run -v <the kube config>:/root/.kube/config
-v <the user home dir>/.helm/plugins/deploy/cache/onap/logs:/onap_helm_logs
-v <result directory>:/var/lib/xtesting/results
nexus3.onap.org:10003/onap/xtesting-infra-healthcheck:master
/bin/bash -c "run_tests -r -t onap-helm"
```

You can also run the docker in interactive mode, so you can run the tests from
inside the docker and directly modify the code of the test if you want.

```
docker run -it -v <the kube config>:/root/.kube/config
-v <the user home dir>/.helm/plugins/deploy/cache/onap/logs:/onap_helm_logs
-v <result directory>:/var/lib/xtesting/results
nexus3.onap.org:10003/onap/xtesting-infra-healthcheck:master bash
```

In this case you will get the bash prompt, you can run the test by typing in
the console

```
# run_tests -t onap-k8s
```

The code of the tests is in the docker. For python test, have a look at
/usr/lib/python3.8/site-packages. See the Dockerfile for more information.

### Output

```
+------------------+-------------+-------------------+----------+--------+
| TEST CASE        | PROJECT     | TIER              | DURATION | RESULT |
+------------------+-------------+-------------------+----------+--------+
| onap-k8s         | integration | infra-healthcheck | 00:06    | PASS   |
| onap-helm        | integration | infra-healthcheck | 00:01    | PASS   |
| nodeport_ingress |  security   |  security         | 00:01    | FAIL   |
+------------------+-------------+-------------------+----------+--------+
```