Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 8a797d3

Browse files
authored
Create a simple load test skeleton
1 parent 4730cb2 commit 8a797d3

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Perform a load test on the compatibility server. Usage:
16+
17+
$ pip install locustio
18+
$ locust --host=http://104.197.8.72
19+
"""
20+
21+
import random
22+
import urllib.parse
23+
24+
import locust
25+
26+
27+
PYTHON2_PACKAGES = [
28+
'apache-beam[gcp]',
29+
'google-cloud-bigtable',
30+
'google-cloud-dns',
31+
'google-cloud-vision',
32+
'tensorboard',
33+
'tensorflow',
34+
]
35+
36+
PYTHON3_PACKAGES = [
37+
'google-cloud-bigtable',
38+
'google-cloud-dns',
39+
'google-cloud-vision',
40+
'tensorboard',
41+
'tensorflow',
42+
]
43+
44+
45+
class CompatibilityCheck(locust.TaskSet):
46+
@locust.task
47+
def single_python2(self):
48+
query = urllib.parse.urlencode(
49+
{'python-version': '2',
50+
'package': random.choice(PYTHON2_PACKAGES)})
51+
self.client.get('/?%s' % query)
52+
53+
@locust.task
54+
def single_python3(self):
55+
query = urllib.parse.urlencode(
56+
{'python-version': '3',
57+
'package': random.choice(PYTHON3_PACKAGES)})
58+
self.client.get('/?%s' % query)
59+
60+
@locust.task
61+
def double_python2(self):
62+
package1 = random.choice(PYTHON2_PACKAGES)
63+
package2 = random.choice(list(set(PYTHON2_PACKAGES) - {package1}))
64+
65+
query = urllib.parse.urlencode([('python-version', '2'),
66+
('package', package1),
67+
('package', package2)])
68+
self.client.get('/?%s' % query)
69+
70+
@locust.task
71+
def double_python3(self):
72+
package1 = random.choice(PYTHON3_PACKAGES)
73+
package2 = random.choice(list(set(PYTHON3_PACKAGES) - {package1}))
74+
75+
query = urllib.parse.urlencode([('python-version', '3'),
76+
('package', package1),
77+
('package', package2)])
78+
self.client.get('/?%s' % query)
79+
80+
81+
class CompatibilityChecker(locust.HttpLocust):
82+
task_set = CompatibilityCheck
83+
min_wait = 0
84+
max_wait = 0

0 commit comments

Comments
 (0)