Skip to content

Commit 17da615

Browse files
committed
python 3.9 upgrade
Change-Id: I13b9448458b34d122c1b5bc5809adafbbf61d36a Reviewed-on: https://review.couchbase.org/c/perfrunner/+/163891 Reviewed-by: Bo-Chun Wang <[email protected]> Tested-by: Korrigan Clark <[email protected]>
1 parent 61106b9 commit 17da615

36 files changed

+176
-78
lines changed

Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ SHELL := /bin/bash
33
PATH := ${GOPATH}/bin:$(PATH)
44

55
ENV := env
6-
PYTHON := python3.6
6+
PYTHON := python3.9
77
PYTHON_PROJECTS := cbagent perfdaily perfrunner scripts spring
88
.PHONY: docker
99

1010
all:
1111
export PYENV_ROOT="$$HOME/.pyenv" && \
1212
export PATH="$$PYENV_ROOT/bin:$$PATH" && \
13-
eval "$$(pyenv init -)" && \
14-
pyenv local 3.6.12 && \
13+
eval "$$(pyenv init --path)" && \
14+
pyenv install 3.9.7 -s && \
15+
pyenv local 3.9.7 && \
1516
virtualenv --quiet --python ${PYTHON} ${ENV}
1617
${ENV}/bin/pip install --upgrade --quiet pip wheel
1718
${ENV}/bin/pip install --quiet --no-warn-script-location -r requirements.txt
@@ -70,7 +71,7 @@ docker:
7071
docker build -t docker.io/perflab/perfrunner docker
7172

7273
docker-cloud-worker:
73-
pyenv local 3.6.12 && \
74+
pyenv local 3.9.7 && \
7475
virtualenv --quiet --python ${PYTHON} ${ENV}
7576
${ENV}/bin/pip install --upgrade --quiet pip wheel
7677
${ENV}/bin/pip install --quiet --no-warn-script-location -r requirements.txt

cbagent/collectors/eventing_stats.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,20 @@ def _get_pid_stats(self, node_pids):
145145
pid_list_top = []
146146
pid_list_top_str = ""
147147
grep_text_top = []
148-
grep_text_top_str = "^\s*"
148+
grep_text_top_str = "^\\s*"
149149
counter = 0
150150
# run top command in batches of 20 pids as per top command limitation
151151
for pid in pids.values():
152-
grep_text_ps += '^[[:space:]]*{}\|'.format(pid)
152+
grep_text_ps += '^[[:space:]]*{}\\|'.format(pid)
153153
pid_list_top_str += '{},'.format(pid)
154-
grep_text_top_str += '{}\|'.format(pid)
154+
grep_text_top_str += '{}\\|'.format(pid)
155155
counter += 1
156156
if counter == 20:
157157
counter = 0
158158
pid_list_top.append(pid_list_top_str[:-1])
159159
grep_text_top.append(grep_text_top_str[:-2])
160160
pid_list_top_str = ""
161-
grep_text_top_str = "^\s*"
161+
grep_text_top_str = "^\\s*"
162162
grep_text_ps = grep_text_ps[:-2]
163163
with settings(host_string=node):
164164
rss_used = run(self.PS_CMD.format(grep_text_ps))

cbagent/collectors/libstats/pcstat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class PCStat(RemoteStats):
77

88
def get_pcstat(self, partition: str) -> float:
99
stdout = self.run(
10-
'find {} -regex .*[0-9]+\.couch\.[0-9]+ \
10+
'find {} -regex .*[0-9]+\\.couch\\.[0-9]+ \
1111
| xargs pcstat -nohdr -terse 2>/dev/null'.format(partition),
1212
)
1313
percents = []

cbagent/collectors/libstats/psstats.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class PSStats(RemoteStats):
1111
PS_CMD = "ps -eo pid,rss,vsize,comm | " \
1212
"grep {} | grep -v grep | sort -n -k 2 | tail -n 1"
1313

14-
TOP_CMD = "top -b -n2 -d{0} -p {1} | grep '^\s*{1}' | tail -n 1"
14+
TOP_CMD = "top -b -n2 -d{0} -p {1} | grep '^\\s*{1}' | tail -n 1"
1515

1616
MAX_TOP_INTERVAL = 10 # seconds
1717

cbagent/stores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def build_dbname(cluster: str,
1919
index: str = None,
2020
collector: str = None) -> str:
2121
db_name = (collector or "") + cluster + (bucket or "") + (index or "") + (server or "")
22-
for char in "[]/\;.,><&*:%=+@!#^()|?^'\"":
22+
for char in "[ ] / \\ ; . , > < & * : % = + @ ! # ^ ( ) | ? ^ ' \"":
2323
db_name = db_name.replace(char, "")
2424
return db_name
2525

perfrunner/celerylocal.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
from kombu.serialization import registry
2+
13
broker_url = 'sqla+sqlite:///perfrunner.db'
24
result_backend = 'database'
35
database_url = 'sqlite:///results.db'
46
task_serializer = 'pickle'
57
result_serializer = 'pickle'
6-
accept_content = {'pickle'}
8+
accept_content = {'pickle', 'json', 'application/json', 'application/data', 'application/text'}
79
task_protocol = 1
10+
11+
registry.enable('json')
12+
registry.enable('application/json')
13+
registry.enable('application/data')
14+
registry.enable('application/text')

perfrunner/celeryremote.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
from kombu.serialization import registry
2+
13
broker_url = 'amqp://couchbase:[email protected]:5672/broker'
24
broker_pool_limit = None
35
worker_hijack_root_logger = False
4-
result_backend = "amqp://"
6+
result_backend = "rpc://"
57
result_persistent = False
68
result_exchange = "perf_results"
7-
accept_content = ['pickle']
9+
accept_content = ['pickle', 'json', 'application/json', 'application/data', 'application/text']
810
result_serializer = 'pickle'
911
task_serializer = 'pickle'
1012
task_protocol = 1
1113
broker_connection_timeout = 60
1214
broker_connection_retry = True
1315
broker_connection_max_retries = 100
16+
17+
registry.enable('json')
18+
registry.enable('application/json')
19+
registry.enable('application/data')
20+
registry.enable('application/text')

perfrunner/helpers/cluster.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,15 @@ def set_services(self):
236236
def add_nodes(self):
237237
if self.dynamic_infra:
238238
return
239-
for (_, servers), initial_nodes \
240-
in zip(self.cluster_spec.clusters, self.initial_nodes):
239+
for (_, servers), initial_nodes in zip(self.cluster_spec.clusters, self.initial_nodes):
241240

242-
if initial_nodes < 2: # Single-node cluster
243-
continue
241+
if initial_nodes < 2: # Single-node cluster
242+
continue
244243

245-
master = servers[0]
246-
for node in servers[1:initial_nodes]:
247-
roles = self.cluster_spec.roles[node]
248-
self.rest.add_node(master, node, roles)
244+
master = servers[0]
245+
for node in servers[1:initial_nodes]:
246+
roles = self.cluster_spec.roles[node]
247+
self.rest.add_node(master, node, roles)
249248

250249
def rebalance(self):
251250
if self.dynamic_infra:

perfrunner/helpers/local.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,8 @@ def start_celery_worker(queue: str):
866866
with shell_env(PYTHONOPTIMIZE='1', PYTHONWARNINGS='ignore', C_FORCE_ROOT='1'):
867867
local('WORKER_TYPE=local '
868868
'BROKER_URL=sqla+sqlite:///perfrunner.db '
869-
'nohup env/bin/celery worker '
870-
'-A perfrunner.helpers.worker -l INFO -Q {} -f worker.log &'.format(queue))
869+
'nohup env/bin/celery -A perfrunner.helpers.worker worker '
870+
'-l INFO -Q {} -f worker.log &'.format(queue))
871871

872872

873873
def clone_git_repo(repo: str, branch: str, commit: str = None):

perfrunner/helpers/monitor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ def _get_num_items(self, host: str, bucket: str, total: bool = False) -> int:
322322
return curr_items[-1]
323323
return 0
324324

325-
def monitor_num_items(self, host: str, bucket: str, num_items: int, max_retry: int=None):
325+
def monitor_num_items(self, host: str, bucket: str, num_items: int, max_retry: int = None):
326326
logger.info('Checking the number of items in {}'.format(bucket))
327327
if not max_retry:
328328
max_retry = self.MAX_RETRY
@@ -1040,7 +1040,7 @@ def _wait_for_replica_count_match(self, host, bucket):
10401040
if time.time() - start_time > self.TIMEOUT:
10411041
raise Exception('Replica items monitoring got stuck')
10421042

1043-
def monitor_num_items(self, host: str, bucket: str, num_items: int, max_retry: int=None):
1043+
def monitor_num_items(self, host: str, bucket: str, num_items: int, max_retry: int = None):
10441044
logger.info('Checking the number of items in {}'.format(bucket))
10451045
if not max_retry:
10461046
max_retry = self.MAX_RETRY

0 commit comments

Comments
 (0)