This project analyzes Landscape client's CPU usage when reporting packages to Landscape server. It uses Terraform to set up the client and server and pytest to drive configuration and data collection.
This project uses poetry to manage dependencies.
# Install poetry if needed
pip install poetry
# Install project dependencies (automatically creates and manages venv)
poetry installYou'll need to create Landscape server and client images in LXD. These are required inputs to the Terraform plan. The client image needs to be for a VM to ensure accurate CPU profiling.
Example client image creation:
lxc launch ubuntu:noble client --vm
lxc exec client -- apt install -y landscape-client
lxc stop client
lxc publish client --alias client-imageYou would use client-image in the Terraform inputs.
Note
You may also attach a pro token in the image instead of providing one in the Terraform inputs.
Install Landscape server without the HashIDs database to include a greater number of unknown packages during the package reporting process.
Example server image creation:
lxc launch ubuntu:noble server
lxc exec server -- add-apt-repository -y ppa:landscape/self-hosted-daily
lxc exec server -- apt install landscape-server-quickstart --no-install-recommends
lxc stop server
lxc publish server --alias server-imageYou would use server-image in the Terraform inputs.
You'll also need to identify the hostname from the certificate that is generated by the quickstart installation process. This is a required input server_certificate_hostname for the Terraform plan. This is necessary to ensure server and client can communicate using the self-signed certificate.
openssl s_client -connect <SERVER>:443 | openssl x509For example, this installation has a hostname for server.lxd:
depth=0 CN = server.lxd
verify error:num=18:self-signed certificate
verify return:1
depth=0 CN = server.lxd
verify return:1
-----BEGIN CERTIFICATE-----
MIIC9jCCAd6gAwIBAgIUZA7AdjyYuZEAnwBK7/LhF5YSXr4wDQYJKoZIhvcNAQEL
BQAwFTETMBEGA1UEAwwKc2VydmVyLmx4ZDAeFw0yNjAxMTIxNjUzMzVaFw0zNjAx
MTAxNjUzMzVaMBUxEzARBgNVBAMMCnNlcnZlci5seGQwggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQCltn+0XA1HNrbCcyE4SQN75zfcTbv5hO9yMupiaR2o
zD6mBzX8bLuHkYreFM7nAVZ+WTgQyT9AYVBrssjtvp6gR1WnfRq/UDHRYIosQTlU
0zbAc4wg4xrw+K/7N+1/7EIDc3mq7nzbbK9KuZRfC/jazkI5MKBvAn6/7iloppdY
Sfu6TbstBKfV2EA2/OBIIv1kMpPt76S76cyM/RzGX0jOhcy+oJ0tQoFcyfKSnhl2
Pbvn+hazzlGnHbqoT1YTRya33yXU7Lfq+AYPYBYgHMYhnGHIzRj6PiLc+nLB2ABm
eYHWbZvv4RhYoI9o1C/6m7kTuAeAekOCHDLEaohC8Bi7AgMBAAGjPjA8MBsGA1Ud
EQQUMBKCCnNlcnZlci5seGSHBArCPYAwHQYDVR0OBBYEFKzD/taEv3UT3NULPLsV
UBjST9xOMA0GCSqGSIb3DQEBCwUAA4IBAQB+/gm5J3WQXMgbikdG2DZlRSXzi/G3
1ngnZUPHX2Gw2UibNmCbq0mwpFfdBLbMkBcfVhCUSZ/cqX2Pu9+IClgL1fYNcSq3
gd/TOElowK776n0WnU/+/70EYbqVHp2sa7LdPyITIcq2FPQ8CT0XxZCmuiUjM79x
eZCo0j4/Q9NbFWLgg3UUkvVYHXIZITk0xYZfmWMNKdEYg5FjGAljhRUOHp6Mv6Uv
/FlujyqA7WR4n+5o+vCe6J0m9qMscus9Y0WT1yh0bvCrUyU3HDQmkCfsSWjN5VGz
0YRKvl2oPJ9n5LP9xFizp6iGR2gaNAW5QwBlyZmLjLkUqhCZ+U3eABI1
-----END CERTIFICATE-----
See variables.tf and terraform.tfvars.example for required Terraform inputs and examples of those inputs. See pyproject.toml for configuration options for the profiler tool and Landsacpe client.
Run the profiling tests using poetry and pytest:
poetry run pytest test_profiler.pyData will be collected in a results/ directory. Subsequent runs will create a new timestamped directory. Visualize the data with the plot:
poetry run python plot.pyBy default this will use the most recent data in results/. Pass a path in results to use another run:
poetry run python plot.py results/Mon_Jan_12_15:12:11