Created
April 27, 2016 18:33
-
-
Save mythmon/6fd7244ab807ce32b94816711b1dce68 to your computer and use it in GitHub Desktop.
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
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": false | |
}, | |
"cell_type": "code", | |
"source": "import requests\nimport json\nimport random\n\ndef trial(base_url, target):\n url = base_url + '/api/v1/fetch_bundle/'\n data = {\n 'locale': 'en-US',\n 'user_id': random.random(),\n 'version': '46.0.0',\n 'release_channel': 'release',\n }\n res = requests.post(url, data=data, verify=False)\n response = json.loads(res.text)\n recipe_names = [r['name'] for r in response['recipes']]\n return target in recipe_names", | |
"execution_count": 43, | |
"outputs": [] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "# Testing pre-prod without the fix" | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": false | |
}, | |
"cell_type": "code", | |
"source": "# sample rate is 1 in 100000\nnum_trials = 100\nnum_hits = 0\nfor _ in range(num_trials):\n if trial('https://normandy.prod.mozaws.net', 'Release - HB General EN*'):\n num_hits += 1\n\n# Expected: ~0/100 \nprint(num_hits, '/', num_trials)\n", | |
"execution_count": 39, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "66 / 100\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": {}, | |
"cell_type": "markdown", | |
"source": "# Testing local dev with the fix" | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": false | |
}, | |
"cell_type": "code", | |
"source": "# sample rate is 1 in 100000\nrequests.packages.urllib3.disable_warnings()\nnum_trials = 100\nnum_hits = 0\nfor _ in range(num_trials):\n if trial('https://normandy', 'Release - HB General EN*'):\n num_hits += 1\n\n# Expected: ~0/100 \nprint(num_hits, '/', num_trials)", | |
"execution_count": 47, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "0 / 100\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true, | |
"collapsed": true | |
}, | |
"cell_type": "code", | |
"source": "", | |
"execution_count": null, | |
"outputs": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3", | |
"language": "python" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"version": 3, | |
"name": "ipython" | |
}, | |
"name": "python", | |
"file_extension": ".py", | |
"version": "3.5.1", | |
"mimetype": "text/x-python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment