-
Notifications
You must be signed in to change notification settings - Fork 16
Test helpers machine #267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Test helpers machine #267
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
69334da
Add role to deploy test helpers repo
LDiazN cc15c5e
Change test helpers url
LDiazN 0904fea
Set up echo and jsonth services
LDiazN 620d5a1
Fix bad comment
LDiazN b1ee5cc
fix certificate deadlock issue
LDiazN 3beab5d
Routing test helper traffic with nginx
LDiazN d0a9298
nginx config for test helpers
LDiazN 4c5fcc6
Creating echo machine
LDiazN 61d705e
Creating host for each th
LDiazN 91bfe43
Fix bad module name
LDiazN 1f08b62
Set up ansible for each test helper
LDiazN b773393
Run prometheus without dehydrated when no https is required
LDiazN ed6f3a2
removing unused listen 80 entry in prometheus config
LDiazN 94b24cd
Allow services to run on port 80
LDiazN 393803e
Add port parameters to use a different port for test helpers metrics
LDiazN f5f5819
Remove unused firewall rules
LDiazN 901639d
Updated comment
LDiazN e45f173
Add checksum for test helpers tar download
LDiazN 7ca3083
Merge conflict
LDiazN 1ef7431
update with main
LDiazN 335152a
Add test helpers machines; build th from scratch since we don't have …
LDiazN 61c8f79
Fix edge case where service won't be properly restarted if a new vers…
LDiazN 9e27329
Merge branch 'main' into test-helpers-machine
LDiazN 824a2bf
Point oonimeasurements to the temp branch
LDiazN 7d85944
remove test helpers from dev env; point ooniprobe to dev branch
LDiazN 41a344c
Pull binaries from ooniprobe-rs repo
LDiazN 8f74d5d
Merge branch 'main' into test-helpers-machine
LDiazN abf93a2
Get monitoring ip by digging it
LDiazN cd7d168
Add oonidevops ssh key to digitalocean hosts
LDiazN b8b458b
Fix small issues on playbooks for debian
LDiazN a40258f
Add simpler test helper module
LDiazN f88a07f
Fix test helper restart
LDiazN 0e057b4
merge conflict
LDiazN 01214d6
rename binaries; do checksum on download
LDiazN File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| - name: Deploy test helpers | ||
| hosts: | ||
| - echo.th.dev.ooni.io | ||
| - echo.th.prod.ooni.io | ||
| become: true | ||
| roles: | ||
| - role: bootstrap | ||
| - role: prometheus_node_exporter | ||
| vars: | ||
| node_exporter_port: 9100 | ||
| node_exporter_host: "0.0.0.0" | ||
| prometheus_nginx_proxy_config: | ||
| - location: /metrics/node_exporter | ||
| proxy_pass: http://127.0.0.1:9100/metrics | ||
| use_https: false | ||
| http_port: 8080 # if we leave port 80, it's taken by nginx | ||
| - role: test_helpers | ||
| vars: | ||
| helper: ooechohelpd | ||
| # sha256 of https://github.com/ooni/ooniprobe-rs/releases/download/v0.1.6/ooechohelpd | ||
| test_helpers_checksum: 10511a8b918c2244eba9e17c32f3cec9efbc5ffa51d6ad7f59fe648cd0986615 | ||
| port: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| - name: Deploy test helpers | ||
| hosts: | ||
| - json.th.dev.ooni.io | ||
| - json.th.prod.ooni.io | ||
| become: true | ||
| roles: | ||
| - role: bootstrap | ||
| - role: prometheus_node_exporter | ||
| vars: | ||
| node_exporter_port: 9100 | ||
| node_exporter_host: "0.0.0.0" | ||
| prometheus_nginx_proxy_config: | ||
| - location: /metrics/node_exporter | ||
| proxy_pass: http://127.0.0.1:9100/metrics | ||
| use_https: false | ||
| http_port: 8080 # if we leave port 80, it's taken by nginx | ||
| - role: test_helpers | ||
| vars: | ||
| helper: oojsonhelpd | ||
| # sha256 of https://github.com/ooni/ooniprobe-rs/releases/download/v0.1.6/oojsonhelpd | ||
| test_helpers_checksum: 3d977e1418ea398f520dff3de951e36010a294dc3d1b564c961542cc3729a224 | ||
| port: 80 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| test_helpers_version: v0.1.6 | ||
| test_helpers_base_url: "https://github.com/ooni/ooniprobe-rs/releases/download/{{ test_helpers_version }}" | ||
|
|
||
| # monitoring server IP | ||
| monitoring_server_ip: "{{ lookup('dig', 'monitoring.ooni.org') }}" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| - name: reload nftables | ||
| tags: nftables | ||
| ansible.builtin.systemd_service: | ||
| name: nftables | ||
| state: reloaded | ||
|
|
||
| - name: reload nginx | ||
| service: | ||
| name: nginx | ||
| state: reloaded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| --- | ||
|
|
||
| # For prometheus scrape requests. | ||
| - name: Allow traffic on port 9100 from the monitoring host only | ||
| become: true | ||
| tags: prometheus-proxy | ||
| blockinfile: | ||
| path: /etc/ooni/nftables/tcp/9100.nft | ||
| create: yes | ||
| block: | | ||
| add rule inet filter input ip saddr {{ monitoring_server_ip }} tcp dport 9100 counter accept comment "node exporter" | ||
| notify: | ||
| - reload nftables | ||
|
|
||
| - name: Allow traffic on the {{ helper }} test helper port | ||
| become: true | ||
| tags: test-helpers | ||
| blockinfile: | ||
| path: "/etc/ooni/nftables/tcp/{{ port }}.nft" | ||
| create: yes | ||
| block: | | ||
| add rule inet filter input tcp dport {{ port }} counter accept comment "{{ helper }} test helper" | ||
| notify: | ||
| - reload nftables | ||
|
|
||
| # Create test helpers user | ||
| - name: Create the testhelpers user | ||
| ansible.builtin.user: | ||
| name: "testhelpers" | ||
| shell: "/bin/bash" | ||
| create_home: no | ||
| system: yes | ||
| become: yes | ||
|
|
||
| # Install test helpers | ||
| - name: Download the {{ helper }} test helper binary | ||
| ansible.builtin.get_url: | ||
| url: "{{ test_helpers_base_url }}/{{ helper }}" | ||
| dest: "/usr/local/bin/{{ helper }}" | ||
| checksum: "sha256:{{ test_helpers_checksum }}" | ||
| mode: '0755' | ||
| force: yes | ||
| become: yes | ||
| register: helper_binary | ||
|
|
||
| # Create systemd units | ||
|
|
||
| - name: Create <helper>.service file | ||
| tags: test-helpers | ||
| ansible.builtin.template: | ||
| src: templates/{{helper}}.service | ||
| dest: /etc/systemd/system/{{helper}}.service | ||
| mode: '0755' | ||
| owner: root | ||
| register: helper_unit | ||
|
|
||
| - name: reload systemd | ||
| tags: test-helpers | ||
| ansible.builtin.systemd_service: | ||
| daemon_reload: yes | ||
| when: helper_unit.changed | ||
|
|
||
| - name: Start helper | ||
| tags: test-helpers | ||
| systemd: | ||
| name: "{{helper}}.service" | ||
| state: started | ||
| enabled: yes | ||
|
|
||
| - name: Restart helper if its binary or unit file changed | ||
| tags: test-helpers | ||
| ansible.builtin.systemd_service: | ||
| name: "{{ helper }}.service" | ||
| state: restarted | ||
| become: yes | ||
| when: helper_binary.changed or helper_unit.changed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [Unit] | ||
| Description=Test helper that will start an echo session on request | ||
| After=network.target | ||
| StartLimitIntervalSec=60 | ||
| StartLimitBurst=3 | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=/usr/local/bin/ooechohelpd --port {{port}} | ||
| Restart=on-failure | ||
| RestartSec=5 | ||
| User=testhelpers | ||
| Group=testhelpers | ||
| ProtectSystem=full | ||
| ProtectHome=yes | ||
| NoNewPrivileges=yes | ||
| PrivateTmp=yes | ||
| AmbientCapabilities=CAP_NET_BIND_SERVICE | ||
| CapabilityBoundingSet=CAP_NET_BIND_SERVICE | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| [Unit] | ||
| Description=Test helper that will respond with a json showing the headers it received | ||
| After=network.target | ||
| StartLimitIntervalSec=60 | ||
| StartLimitBurst=3 | ||
|
|
||
| [Service] | ||
| Type=simple | ||
| ExecStart=/usr/local/bin/oojsonhelpd --port {{port}} | ||
| Restart=on-failure | ||
| RestartSec=5 | ||
| User=testhelpers | ||
| Group=testhelpers | ||
| ProtectSystem=full | ||
| ProtectHome=yes | ||
| NoNewPrivileges=yes | ||
| PrivateTmp=yes | ||
| AmbientCapabilities=CAP_NET_BIND_SERVICE | ||
| CapabilityBoundingSet=CAP_NET_BIND_SERVICE | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
|
|
||
| # choices: oojsonhelpd, ooechohelpd | ||
| helper: "oojsonhelpd" | ||
| port: "80" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| terraform { | ||
| required_providers { | ||
| digitalocean = { | ||
| source = "digitalocean/digitalocean" | ||
| version = "~> 2.0" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| resource "digitalocean_droplet" "ooni_th" { | ||
| image = "debian-13-x64" | ||
| name = "${var.name}-${var.stage}" | ||
| region = var.instance_location | ||
| size = var.instance_size | ||
| ipv6 = true | ||
| ssh_keys = var.ssh_keys | ||
|
|
||
| lifecycle { | ||
| create_before_destroy = true | ||
| ignore_changes = all | ||
| } | ||
| } | ||
|
|
||
| resource "aws_route53_record" "ooni_th" { | ||
| zone_id = var.dns_zone_ooni_io | ||
| name = "${var.hostname}.${var.stage}.ooni.io" | ||
| type = "A" | ||
| ttl = 60 | ||
|
|
||
| records = [digitalocean_droplet.ooni_th.ipv4_address] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| output "droplet_ipv4_address" { | ||
| value = digitalocean_droplet.ooni_th.ipv4_address | ||
| } | ||
|
|
||
| output "fqdn" { | ||
| value = aws_route53_record.ooni_th.fqdn | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| variable "stage" { | ||
| type = string | ||
| } | ||
|
|
||
| variable "name" { | ||
| description = "Name of the droplet (will be suffixed with -<stage>)" | ||
| type = string | ||
| } | ||
|
|
||
| variable "hostname" { | ||
| description = "DNS label for the helper, e.g. \"json.th\" or \"echo.th\". The record is created as <hostname>.<stage>.ooni.io" | ||
| type = string | ||
| } | ||
|
|
||
| variable "instance_location" { | ||
| type = string | ||
| default = "fra1" | ||
| } | ||
|
|
||
| variable "instance_size" { | ||
| type = string | ||
| default = "s-1vcpu-1gb" | ||
| } | ||
|
|
||
| variable "ssh_keys" { | ||
| description = "Fingerprints of the DigitalOcean account SSH keys to grant root access to" | ||
| type = list(string) | ||
| } | ||
|
|
||
| variable "dns_zone_ooni_io" { | ||
| description = "id of the DNS zone for ooni_io" | ||
| type = string | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.