Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Add feature flag webconnectivity_0.5 #315

Merged
merged 5 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/pkg_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ jobs:
runs-on: "ubuntu-20.04"
container: debian:10
steps:
- name: Change Owner of Container Working Directory
run: chown root:root .

- name: Install git
run: |
apt-get update -q
apt-get install -y git

- name: Check out repository code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

Expand Down
6 changes: 6 additions & 0 deletions newapi/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
ooni-api (1.0.35) unstable; urgency=medium

* Add feature flagging

-- Federico Ceratto <[email protected]> Mon, 09 Jan 2023 17:41:05 +0000

ooni-api (1.0.34) unstable; urgency=medium

* Implement MAT granularity
Expand Down
25 changes: 23 additions & 2 deletions newapi/ooniapi/probe_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def check_in() -> Response:
properties:
v:
type: integer
description: response format version
probe_cc:
type: string
description: probe CC inferred from GeoIP or ZZ
Expand All @@ -188,8 +189,19 @@ def check_in() -> Response:
utc_time:
type: string
description: current UTC time as YYYY-mm-ddTHH:MM:SSZ
conf:
type: object
description: auxiliary configuration parameters
psiphon:
type: object
tor:
type: object
features:
type: object
description: feature flags
tests:
type: object
description: test-specific configuration
properties:
web_connectivity:
type: object
Expand Down Expand Up @@ -256,10 +268,19 @@ def check_in() -> Response:
try:
torconf = _load_json(current_app.config["TOR_TARGETS_CONFFILE"])
psconf = _load_json(current_app.config["PSIPHON_CONFFILE"])
conf = dict(tor=torconf, psiphon=psconf)
conf = dict(tor=torconf, psiphon=psconf, features={})
except Exception as e:
log.error(str(e), exc_info=True)
conf = {}
conf = dict(features={})

try:
# set webconnectivity_0.5 feature flag for some probes
ipaddr = extract_probe_ipaddr()
n = int(ipaddr.split(".", 2)[1])
if n in (34,):
conf["features"]["webconnectivity_0.5"] = True
except Exception:
pass

resp["tests"] = {
"web_connectivity": {"urls": test_items},
Expand Down
2 changes: 1 addition & 1 deletion newapi/tests/integ/test_probe_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_check_in_basic(client):
assert cc == "US"

# psiphon and tor configurations
assert sorted(c["conf"]) == ["psiphon", "tor"]
assert sorted(c["conf"]) == ["features", "psiphon", "tor"]


def test_check_in_url_category_news(client):
Expand Down
2 changes: 1 addition & 1 deletion newapi/tests/integ/test_probe_services_nodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def test_check_in(client, mocks):
assert cc == "US"

# psiphon and tor configurations
assert sorted(c["conf"]) == ["psiphon", "tor"]
assert sorted(c["conf"]) == ["features", "psiphon", "tor"]


def test_check_in_url_category_news(client, mocks):
Expand Down