-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CART-831 TEST: add support for arbitrary envariables in yaml files #4445
Changes from 6 commits
44bd102
d102ccb
cc9d127
3de71a5
cf43b31
ef8c5fe
9430ca3
7cecc44
578b9c5
862cfde
e2f522d
e1f9f3c
6cc1e12
589f7e9
7910a54
7636910
5bc5d57
0c9c262
966b445
502210c
fd6637a
2e2ffda
8588d5e
69f6b9e
903c4a5
5c75a2e
25412f9
a614036
4a76526
f5dcccb
09adc5d
5f04779
86294b4
28b66cd
28f106d
db256a9
2094671
7bccab9
8cdc8a9
286521a
b780fb8
44c9acd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,34 @@ def stop_process(proc): | |
|
||
return procrtn | ||
|
||
@staticmethod | ||
def set_other_env_vars(cartobj): | ||
""" import env vars from other_env_var param """ | ||
other_env_vars = cartobj.params.get("other_env_vars", | ||
"/run/defaultENV/") | ||
if other_env_vars is None: | ||
print("other_env_vars was not set in yaml file.\n") | ||
return | ||
|
||
for kv_pair in other_env_vars: | ||
key, value = kv_pair[0] | ||
print("Adding {}={} to environment.\n".format(key, value)) | ||
os.environ[key] = value | ||
|
||
@staticmethod | ||
def unset_other_env_vars(cartobj): | ||
""" import env vars from other_env_var param """ | ||
other_env_vars = cartobj.params.get("other_env_vars", | ||
"/run/defaultENV/") | ||
if other_env_vars is None: | ||
print("other_env_vars was not set in yaml file.\n") | ||
return | ||
|
||
for kv_pair in other_env_vars: | ||
key = kv_pair[0][0] | ||
print("Removing key {} from environment.\n".format(key)) | ||
del os.environ[key] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure i see the purpose of this function |
||
|
||
# What is special about pylint's 15 variable limit? | ||
# pylint: disable=too-many-locals | ||
def get_env(self, cartobj): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/python | ||
''' | ||
(C) Copyright 2018-2021 Intel Corporation. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
GOVERNMENT LICENSE RIGHTS-OPEN SOURCE SOFTWARE | ||
The Government's rights to use, modify, reproduce, release, perform, display, | ||
or disclose this software are subject to the terms of the Apache License as | ||
provided in Contract No. B609815. | ||
Any reproduction of computer software, computer software documentation, or | ||
portions thereof marked with this legend must also reproduce the markings. | ||
''' | ||
|
||
from __future__ import print_function | ||
|
||
import sys | ||
import subprocess | ||
|
||
from apricot import TestWithoutServers | ||
|
||
sys.path.append('./util') | ||
|
||
# Can't all this import before setting sys.path | ||
# pylint: disable=wrong-import-position | ||
from cart_utils import CartUtils | ||
|
||
class SetOtherEnvVars(TestWithoutServers): | ||
""" | ||
Runs basic test of cart_utils.py:set_other_env_vars | ||
|
||
:avocado: recursive | ||
""" | ||
def setUp(self): | ||
""" Test setup """ | ||
print("Running setup\n") | ||
self.utils = CartUtils() | ||
|
||
def tearDown(self): | ||
""" Tear down """ | ||
print("Running tearDown\n") | ||
|
||
def test_cart_no_pmix(self): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. modify test name here |
||
""" | ||
Test set_other_env_vars | ||
|
||
:avocado: tags=set_other_env_vars | ||
""" | ||
|
||
print("Before set_other_env_vars\n") | ||
print(subprocess.check_output("env", shell=True)) | ||
self.utils.set_other_env_vars(self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (pylint-no-member) Instance of 'CartUtils' has no 'set_other_env_vars' member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (pylint-no-member) Instance of 'CartUtils' has no 'set_other_env_vars' member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (pylint-no-member) Instance of 'CartUtils' has no 'set_other_env_vars' member |
||
print("After set_other_env_vars\n") | ||
print(subprocess.check_output("env", shell=True)) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. test here should check and ensure that env was set as yaml set it, so add some inline verification for each 'other' env var |
||
print("Before unset_other_env_vars\n") | ||
print(subprocess.check_output("env", shell=True)) | ||
self.utils.unset_other_env_vars(self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (pylint-no-member) Instance of 'CartUtils' has no 'unset_other_env_vars' member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (pylint-no-member) Instance of 'CartUtils' has no 'unset_other_env_vars' member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (pylint-no-member) Instance of 'CartUtils' has no 'unset_other_env_vars' member |
||
print("After unset_other_env_vars\n") | ||
print(subprocess.check_output("env", shell=True)) | ||
|
||
if __name__ == "__main__": | ||
main() | ||
mallove79 marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
defaultENV: | ||
mallove79 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
D_LOG_MASK: "WARN" | ||
CRT_PHY_ADDR_STR: "ofi+sockets" | ||
OFI_INTERFACE: "eth0" | ||
CRT_CTX_NUM: "8" | ||
CRT_CTX_SHARE_ADDR: "0" | ||
other_env_vars: | ||
- ARBITRARY_ENV_VAR1: apple | ||
- ARBITRARY_ENV_VAR2: orange | ||
- ARBITRARY_ENV_VAR3: banana pear | ||
tests: !mux | ||
set_other_env_vars: | ||
name: set_other_env_var |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we want to make it so that every cart test automatically calls this without having to do anything extra