|
1 | | -# Performance Test |
| 1 | +# CCNP Performance Test |
2 | 2 |
|
3 | | -We have these KPIs for performance test. |
4 | | - |
5 | | -| KPI | HIB/LIB | Unit | Comment | |
6 | | -| ------------------------------------------- | -------- | ----- | ----------------------------------------------------- | |
7 | | -| CCNP service get measurement throughput | HIB | ops | Service Throughput | |
8 | | -| CCNP service get measurement response time | LIB | ms | Service Response time | |
9 | | -| CCNP service get eventlog throughput | HIB | ops | Service Throughput | |
10 | | -| CCNP service get eventlog response time | LIB | ms | Service Response time | |
11 | | -| CCNP service get quote throughput | HIB | ops | Service Throughput | |
12 | | -| CCNP service get quote response time | LIB | ms | Service Response time | |
13 | | -| CCNP initialization time | LIB | s | CCNP device plugin, DaemonSet and service readiness. | |
14 | | - |
15 | | -*Note: we use the CCNP SDK to access the CCNP service because it's convenient to prepare the request data (e.g. container ID, etc.) |
| 3 | +CCNP performance tests focus on the latency of calling CCNP SDK key APIs: `get_cc_eventlog`, `get_cc_report` and `get_cc_measurement`. |
| 4 | +It will simulate requests from multiple pods in parallel and calculate average time of all the requests. |
16 | 5 |
|
17 | 6 | Below are the steps for you to build and run the performance test. |
18 | 7 |
|
19 | 8 | ## Prerequisites |
20 | 9 |
|
21 | | -To run the test, you need a K8S cluster with CCNP enabled (CCNP Device Plugin and CCNP Service deployed and ready). |
22 | | - |
23 | | -## Build |
24 | | - |
25 | | -```bash |
26 | | -# Make sure you are on the repo's top dir |
27 | | -cd <the-dir-of-confidential-cloud-native-primitives> |
| 10 | +Please make sure you have CCNP deployed in a K8S cluster, and ccnp-example image has been built. |
| 11 | +Please refer to [here](../../deployment/README.md) for image building and CCNP deployment. |
28 | 12 |
|
29 | | -# Run doker build |
30 | | -docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --build-arg no_proxy=$no_proxy -t ccnp-perf:latest -f container/ccnp-perf/Dockerfile . |
| 13 | +## Run Tests |
31 | 14 |
|
32 | | -# View build result |
33 | | -docker image ls | grep ccnp-perf |
| 15 | +### Deploy pods for performance testing |
34 | 16 |
|
35 | | -# Save the docker image for later use |
36 | | -docker save ccnp-perf:latest > ccnp-perf_latest.tar |
| 17 | +```bash |
| 18 | +# Deploy ccnp-example pods |
| 19 | +$ sudo ./deploy-perf.sh -r <ccnp-example image registry> -g <ccnp-example image tag> -n <number of pods> |
37 | 20 | ``` |
38 | 21 |
|
39 | | -## Deploy |
| 22 | +### Run Tests |
| 23 | + |
| 24 | +The script will run tests in parallel. The log will be saved in files with prefix `perf_output` under current directory. |
40 | 25 |
|
41 | 26 | ```bash |
42 | | -# Load the docker image for K8S using containerd. |
43 | | -# You need to run this on the node where you want to deploy the ccnp-perf test |
44 | | -ctr -n=k8s.io image import ccnp-perf_latest.tar |
| 27 | +# Test for get event log |
| 28 | +$ sudo ./perf-para.sh -n <number of pods> -e |
45 | 29 |
|
46 | | -# Make sure you are on the repo's top dir |
47 | | -cd <the-dir-of-confidential-cloud-native-primitives> |
| 30 | +# Test for get measurement |
| 31 | +$ sudo ./perf-para.sh -n <number of pods> -m |
48 | 32 |
|
49 | | -# Deploy ccnp-perf test |
50 | | -kubectl apply -f deployment/kubernetes/manifests/ccnp-perf-deployment.yaml |
| 33 | +# Test for get quote |
| 34 | +$ sudo ./perf-para.sh -n <number of pods> -r |
51 | 35 | ``` |
52 | 36 |
|
53 | | -## Test |
| 37 | +Run below script to calculate average time of a request. |
54 | 38 |
|
55 | 39 | ```bash |
56 | | -# Get the pod name of ccnp-perf |
57 | | -kubectl get pod | grep ccnp-perf |
58 | | - |
59 | | -# Run all perf test on the specified pod name got from above command |
60 | | -kubectl exec -ti <ccnp-perf-pod-name> -- python3 -m pytest --log-cli-level=INFO --verbose ccnp_perf.py |
| 40 | +$ sudo ./average.sh -f perf_output_quote |
61 | 41 | ``` |
62 | 42 |
|
63 | | -Sample test output looks like this: |
| 43 | +### Clear |
| 44 | + |
| 45 | +Run below command to delete the pods for performance testing. |
64 | 46 |
|
65 | 47 | ```bash |
66 | | -root@ccnp-perf-0:~/ccnp/confidential-cloud-native-primitives# kubectl exec -ti ccnp-perf-7f8798bf85-8s6zg -- python3 -m pytest --log-cli-level=INFO --verbose |
67 | | - ccnp_perf.py |
68 | | -==================================================================== test session starts ==================================================================== |
69 | | -platform linux -- Python 3.12.2, pytest-8.1.1, pluggy-1.4.0 -- /usr/local/bin/python3 |
70 | | -cachedir: .pytest_cache |
71 | | -rootdir: /run/ccnp |
72 | | -collected 7 items |
73 | | - |
74 | | -ccnp_perf.py::test_svc_get_cc_measurement_throughput |
75 | | ------------------------------------------------------------------------ live log call ----------------------------------------------------------------------- |
76 | | -INFO ccnp_perf:ccnp_perf.py:191 Perf test average throughput is: 70.75 ops (operations per second) |
77 | | -PASSED [ 14%] |
78 | | -ccnp_perf.py::test_svc_get_cc_measurement_response |
79 | | ------------------------------------------------------------------------ live log call ----------------------------------------------------------------------- |
80 | | -INFO ccnp_perf:ccnp_perf.py:213 Perf test average response time is: 25.89662575 ms (milliseconds) |
81 | | -PASSED [ 28%] |
82 | | -ccnp_perf.py::test_svc_get_cc_eventlog_throughput |
83 | | ------------------------------------------------------------------------ live log call ----------------------------------------------------------------------- |
84 | | -INFO ccnp_perf:ccnp_perf.py:191 Perf test average throughput is: 57.8 ops (operations per second) |
85 | | -PASSED [ 42%] |
86 | | -ccnp_perf.py::test_svc_get_cc_eventlog_response |
87 | | ------------------------------------------------------------------------ live log call ----------------------------------------------------------------------- |
88 | | -INFO ccnp_perf:ccnp_perf.py:213 Perf test average response time is: 76.130223 ms (milliseconds) |
89 | | -PASSED [ 57%] |
90 | | -ccnp_perf.py::test_svc_get_cc_report_throughput |
91 | | ------------------------------------------------------------------------ live log call ----------------------------------------------------------------------- |
92 | | -INFO ccnp_perf:ccnp_perf.py:191 Perf test average throughput is: 54.9 ops (operations per second) |
93 | | -PASSED [ 71%] |
94 | | -ccnp_perf.py::test_svc_get_cc_report_response |
95 | | ------------------------------------------------------------------------ live log call ----------------------------------------------------------------------- |
96 | | -INFO ccnp_perf:ccnp_perf.py:213 Perf test average response time is: 29.38618825 ms (milliseconds) |
97 | | -PASSED [ 85%] |
98 | | -ccnp_perf.py::test_ccnp_init PASSED [100%] |
99 | | - |
100 | | -=============================================================== 7 passed in 66.95s (0:01:06) ================================================================ |
101 | | -root@ccnp-perf-0:~/ccnp/confidential-cloud-native-primitives# |
102 | | -``` |
| 48 | +$ sudo ./deploy-per.sh -n <number of pods> -d |
| 49 | +``` |
0 commit comments