[E2E Test] Add E2E test for webserver release updates
Open
Nobody has claimed this yet.
Tests
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
Add a E2E test that does the following:
- Runs a SLS state file that:
- Installs nginx
- Configures nginx to run a test website that returns
Release 1.0 was successfulin the body - Starts the nginx service
Here's the files for the nginx setup:
/srv/salt/nginx.sls
{% set root_path = "/usr/share/nginx/html/" %}
install_nginx:
pkg.installed:
- name: nginx
nginx_conf:
file.managed:
- name: /etc/nginx/nginx.conf
- source: salt://files/nginx.conf
- template: jinja
- defaults:
root_path: {{ root_path }};
nginx_website:
file.managed:
- name: {{ root_path }}index.html
- makedirs: True
- source: salt://files/index.html
start_nginx:
service.running:
- name: nginx
- reload: True
- enable: True
- watch:
- file: nginx_conf
- file: nginx_website
nginx file (/srv/salt/files/nginx.conf):
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
listen [::]:80;
server_name _;
root {{ root_path }}
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /404.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
index.html contents (/srv/salt/files/index.html)
<!doctype html>
<html>
<head>
<title>Version 1.0 of website</title>
</head>
<body>
<p>Release 1.0 was successful</p>
</body>
</html>
- Run the state again and verify it does not have any changes
- Verify in the test:
- You can query the website and it contains the contents:
Release 1.0 was successful
- Now we need to update the test website and the nginx conf's root dir and update it with Salt.
- update root directive in nginx config
- update the body contents to
Release 2.0 was successful
Run the state now and ensure the changes we expect occur in the state run.
- Verify that the new content is updated:
Release 2.0 was successful
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the repository's existing E2E test entry points, then use the described /srv/salt/nginx.sls, /srv/salt/files/nginx.conf, and /srv/salt/files/index.html setup as the test fixture. Run the state twice to check idempotence, query the website for the Release 1.0 text, update the root and page contents, and verify the second run applies the expected changes and serves Release 2.0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nginx, python
- Domain
- devops, infrastructure, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100