Skip to content

Commit 42410e1

Browse files
committed
update venv to activate and have same dir name in yelp and oss envs
1 parent a2c374a commit 42410e1

File tree

5 files changed

+26
-49
lines changed

5 files changed

+26
-49
lines changed

Makefile

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
UID:=`id -u`
1515
GID:=`id -g`
1616
ITERATION=yelp1
17+
VENV_DIR=venv
18+
VENV_BIN=$(VENV_DIR)/bin
1719

1820
# Determine environment (YELP or OSS)
1921
# Set SCL_ENV to 'YELP' if FQDN ends in '.yelpcorp.com'
@@ -24,7 +26,7 @@ else
2426
SCL_ENV ?= OSS
2527
endif
2628

27-
.PHONY: test tests-yelp tests-oss coverage clean venv venv-yelp venv-oss
29+
.PHONY: test tests-yelp tests-oss coverage clean venv
2830

2931

3032
# Main test target dispatches to environment-specific test target
@@ -35,15 +37,24 @@ else
3537
$(MAKE) tests-oss
3638
endif
3739

38-
tests-yelp: venv-yelp
39-
tox -e py3-yelp # Assumes py3-yelp will be the tox env for yelp
40+
tests-yelp: venv
41+
. $(VENV_BIN)/activate && $(VENV_BIN)/tox -e tests-yelp
4042

41-
tests-oss: venv-oss
42-
tox -e py3 # Assumes py3 will be the default/OSS tox env
43+
tests-oss: venv
44+
. $(VENV_BIN)/activate && $(VENV_BIN)/tox -e tests-oss
4345

4446
tests: test # Alias for backward compatibility or general use
4547
coverage: test
4648

49+
# Main venv target, creates venv with tox
50+
$(VENV_BIN)/activate: setup.py tox.ini requirements-dev.txt
51+
test -d $(VENV_DIR) || virtualenv -p python3.8 $(VENV_DIR)
52+
$(VENV_BIN)/pip install -U pip
53+
$(VENV_BIN)/pip install -U tox
54+
touch $(VENV_BIN)/activate
55+
56+
venv: $(VENV_BIN)/activate
57+
4758
itest_%: package_%
4859
docker run -h fake.docker.hostname -v $(CURDIR):/work:rw docker-dev.yelpcorp.com/$*_yelp /bin/bash -c "/work/tests/ubuntu.sh"
4960
docker run -v $(CURDIR):/work:rw docker-dev.yelpcorp.com/$*_yelp chown -R $(UID):$(GID) /work
@@ -71,26 +82,12 @@ package_%:
7182
'
7283
docker run -v $(CURDIR):/work:rw docker-dev.yelpcorp.com/$*_yelp chown -R $(UID):$(GID) /work
7384

74-
# Main venv target dispatches to environment-specific target
75-
venv:
76-
ifeq ($(SCL_ENV),YELP)
77-
$(MAKE) venv-yelp
78-
else
79-
$(MAKE) venv-oss
80-
endif
81-
82-
venv-yelp: requirements-yelp.txt requirements-oss.txt setup.py tox.ini
83-
tox -e venv-yelp # This tox env should install .[yelp]
84-
85-
venv-oss: requirements-oss.txt setup.py tox.ini
86-
tox -e venv-oss # This tox env should install normally
87-
8885
clean:
8986
rm -rf .cache
9087
rm -rf dist/
9188
rm -rf build/
9289
rm -rf .tox
9390
rm -rf service_configuration_lib.egg-info/
94-
rm -rf venv
91+
rm -rf $(VENV_DIR)
9592
find . -name '*.pyc' -delete
9693
find . -name '__pycache__' -delete

mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ warn_incomplete_stub = True
55
follow_imports = silent
66
ignore_missing_imports = True
77
mypy_path = stubs
8+
strict_optional = False

service_configuration_lib/spark_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ def _handle_jira_ticket_validation(
10561056
try:
10571057
clog.config.configure(
10581058
scribe_host='169.254.255.254', # Standard Scribe host
1059-
scribe_port=1463, # Standard Scribe port
1059+
scribe_port='1463', # Standard Scribe port
10601060
monk_disable=False, # Ensure Monk (for clog) is enabled
10611061
scribe_disable=False, # Ensure Scribe is enabled
10621062
)

tests/spark_config_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,6 +1878,7 @@ def test_get_spark_conf_without_jira_ticket(self, mock_spark_srv_conf_file_with_
18781878
assert 'ticket "None" is missing or invalid for user "regular_user"' in str(excinfo.value)
18791879

18801880
@mock.patch.dict(os.environ, {'USER': 'regular_user'})
1881+
@mock.patch('service_configuration_lib.spark_config.clog', None)
18811882
def test_get_spark_conf_with_jira_validation_disabled(
18821883
self, mock_spark_srv_conf_file_with_jira_disabled, mock_log, mock_time,
18831884
):
@@ -1963,6 +1964,7 @@ def test_jira_ticket_check_for_different_users(
19631964
mock_log.debug.assert_called_with('Jira ticket check not required for this job configuration.')
19641965

19651966
@mock.patch.dict(os.environ, {'USER': 'regular_user'})
1967+
@mock.patch('service_configuration_lib.spark_config.clog', None)
19661968
def test_get_spark_conf_jira_disabled_invalid_ticket(
19671969
self, mock_spark_srv_conf_file_with_jira_disabled, mock_log, mock_time,
19681970
):

tox.ini

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[tox]
2-
envlist = py38, py38-yelp, venv-oss, venv-yelp
2+
envlist = tests-oss, tests-yelp
3+
skipsdist = True
34
tox_pip_extensions_ext_pip_custom_platform = true
45
tox_pip_extensions_ext_venv_update = true
56

67
# Base environment for tests
78
[testenv]
9+
basepython = python3.8
810
deps =
911
-rrequirements-dev.txt
1012
commands=
@@ -17,42 +19,17 @@ commands=
1719
usedevelop = true
1820

1921
# OSS test environment
20-
[testenv:py38]
22+
[testenv:tests-oss]
2123
deps =
2224
{[testenv]deps}
2325
.
2426

2527
# Yelp test environment
26-
[testenv:py38-yelp]
28+
[testenv:tests-yelp]
2729
deps =
2830
{[testenv]deps}
2931
.[yelp]
3032

31-
# Environment for creating an OSS venv
32-
[testenv:venv-oss]
33-
basepython = /usr/bin/python3.8
34-
envdir = venv-oss
35-
deps =
36-
packaging
37-
more_itertools
38-
jaraco.functools
39-
jaraco.text
40-
platformdirs==4.3.6
41-
.
42-
commands =
43-
44-
# Environment for creating a Yelp venv
45-
[testenv:venv-yelp]
46-
basepython = /usr/bin/python3.8
47-
envdir = venv-yelp
48-
deps =
49-
packaging
50-
more_itertools
51-
jaraco.functools
52-
jaraco.text
53-
platformdirs==4.3.6
54-
.[yelp]
55-
commands =
5633

5734
[flake8]
5835
max-line-length = 119

0 commit comments

Comments
 (0)