Bug 1889272

Summary: Golang test server – new functionality
Product: Red Hat OpenStack Reporter: Arkady Shtempler <ashtempl>
Component: python-octavia-tests-tempestAssignee: Gregory Thiemonge <gthiemon>
Status: CLOSED ERRATA QA Contact: Nikolai Ilushko <nilushko>
Severity: medium Docs Contact:
Priority: medium    
Version: 16.1 (Train)CC: gthiemon, ihrachys, jschluet, lpeer, majopela, nilushko, scohen
Target Milestone: gaKeywords: Triaged
Target Release: 17.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-octavia-tests-tempest-1.7.0-0.20210705161812.41b3aac.el9ost Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-21 12:12:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Arkady Shtempler 2020-10-19 08:44:22 UTC
Octavia tempest plugin tests are using server side server/stub implemented with Go) [1]
In order to be able to add more Octavia automated tests we need to add some new functionality into this server.
For example in order to test  “--insert-headers” (it’s possible that the LB will be configured to add HTTP headers into the client’s requests) we need and option to get HTTP headers received on the server side.
For example we could add the following logic, when the server app is receiving HTTP request with URL query like “send_back_requests_headers=True” it will automatically add all received HTTP request headers into the body of response. (payload).

[1] - https://github.com/openstack/octavia-tempest-plugin/tree/master/octavia_tempest_plugin/contrib/test_server


URL query string parameters to support:
1) respond_with_request_headers - server should send back all received GET request header in response body.
2) delay_response - delay the response with a value set as parameter (to simulate busy server, hatcheck response id delayed)
3) response_with_status_code - response with the status code set as parameter 

Path to support:
1) test_server.bin 
In order to automate LB scenario with Neutron QoS activated, we can use a binary file itself.
We can measure limited BW by downloading this binary file that is already existing on Cirros members.

Comment 3 Gregory Thiemonge 2022-07-12 13:20:13 UTC
These features are now implemented in test_server.go

> URL query string parameters to support:
> 1) respond_with_request_headers - server should send back all received GET
> request header in response body.

the /request endpoint replies with a content that includes the provided headers:

$ curl -H "Foo: bar" http://127.0.0.1:8080/request   
GET /request HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/7.76.1
Accept: */*
Foo: bar

1


> 2) delay_response - delay the response with a value set as parameter (to
> simulate busy server, hatcheck response id delayed)

the /delay endpoint implements it:

$ time curl http://127.0.0.1:8080/slow\?delay\=4s
1curl http://127.0.0.1:8080/slow\?delay\=4s  0.00s user 0.00s system 0% cpu 4.011 total


> 3) response_with_status_code - response with the status code set as
> parameter 

The /request endpoint can take a "response_code" parameter and reply with the desired response_code

$ curl -v http://127.0.0.1:8080/request\?response_code\=402
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /request?response_code=402 HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.76.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 402 Payment Required
< Set-Cookie: JSESSIONID=1
< Date: Tue, 12 Jul 2022 13:17:47 GMT
< Content-Length: 99
< Content-Type: text/plain; charset=utf-8
< 
GET /request?response_code=402 HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/7.76.1
Accept: */*

Comment 8 Nikolai Ilushko 2022-08-18 13:12:18 UTC
Verified after running the following commands: 

# Puddle version:

[stack@undercloud-0 ~]$ cat /var/lib/rhos-release/latest-installed
17.0 -p RHOS-17.0-RHEL-9-20220721.n.1

# Clone the repo
[stack@undercloud-0 ~]$ git clone "https://code.engineering.redhat.com/gerrit/python-octavia-tests-tempest"
Cloning into 'python-octavia-tests-tempest'...
remote: Counting objects: 151, done
remote: Total 2873 (delta 0), reused 2873 (delta 0)
Receiving objects: 100% (2873/2873), 6.22 MiB | 322.00 KiB/s, done.
Resolving deltas: 100% (1675/1675), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

[stack@undercloud-0 ~]$ cd python-octavia-tests-tempest

[stack@undercloud-0 python-octavia-tests-tempest]$ git checkout rhos-17.0-trunk-patches

Branch 'rhos-17.0-trunk-patches' set up to track remote branch 'rhos-17.0-trunk-patches' from 'origin'.
Switched to a new branch 'rhos-17.0-trunk-patches'

[stack@undercloud-0 python-octavia-tests-tempest]$ ls
babel.cfg         devstack  HACKING.rst  octavia_tempest_plugin  README.rst    requirements.txt  setup.py               tox.ini
CONTRIBUTING.rst  doc       LICENSE      playbooks               releasenotes  setup.cfg         test-requirements.txt  zuul.d

[stack@undercloud-0 python-octavia-tests-tempest]$ cd octavia_tempest_plugin/contrib/test_server

[stack@undercloud-0 test_server]$ ls
__init__.py  README.rst  test_server.go

# Build the test_server.go file 

[stack@undercloud-0 test_server]$ go version
go version go1.17.7 linux/amd64

[stack@undercloud-0 test_server]$ CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-s -w -extldflags -static' -o test_server.bin test_server.go

[stack@undercloud-0 test_server]$ ls
__init__.py  README.rst  test_server.bin  test_server.go

[stack@undercloud-0 test_server]$ chmod +x test_server.bin

# Checking if it's responsive.

[stack@undercloud-0 test_server]$ ./test_server.bin --help
Usage of ./test_server.bin:
  -cert string
    	Server side PEM format certificate file path.
  -client_ca string
    	Client auth PEM format CA certificate file path.
  -https_client_auth_port int
    	HTTPS with client authentication port to listen on, -1 is disabled. (default -1)
  -https_port int
    	HTTPS port to listen on, -1 is disabled. (default -1)
  -id string
    	Server ID (default "1")
  -key string
    	Server side PEM format key file path.
  -port int
    	Port to listen on (default 8080)

# Run the test_server.bin 

[stack@undercloud-0 test_server]$ ./test_server.bin -id 1 -port 8080 . &
[1] 573242

# The /request endpoint replies with content that includes the provided headers

[stack@undercloud-0 test_server]$ curl -H "Foo: bar" http://127.0.0.1:8080/request
GET /request HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/7.76.1
Accept: */*
Foo: bar

# delay_response - delay the response with a value set as a parameter (to simulate busy server, hatcheck response id delayed)

[stack@undercloud-0 test_server]$ time curl http://127.0.0.1:8080/slow\?delay\=4s
1
real	0m4.015s
user	0m0.004s
sys	0m0.007s

# The /request endpoint can take a "response_code" parameter and reply with the desired response_code

[stack@undercloud-0 test_server]$ curl -v http://127.0.0.1:8080/request\?response_code\=402
*   Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /request?response_code=402 HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.76.1
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 402 Payment Required
< Set-Cookie: JSESSIONID=1
< Date: Thu, 18 Aug 2022 11:07:21 GMT
< Content-Length: 99
< Content-Type: text/plain; charset=utf-8
< 
GET /request?response_code=402 HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: curl/7.76.1
Accept: */*

Moving the bug to "verified".

Comment 13 errata-xmlrpc 2022-09-21 12:12:14 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Release of components for Red Hat OpenStack Platform 17.0 (Wallaby)), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2022:6543