Skip to content

Instantly share code, notes, and snippets.

@kefeimo
Created March 11, 2023 06:15
Show Gist options
  • Save kefeimo/2f4c32caa5687b01ff9515f540be4ab6 to your computer and use it in GitHub Desktop.
Save kefeimo/2f4c32caa5687b01ff9515f540be4ab6 to your computer and use it in GitHub Desktop.
pytest-benchmar-platformwrapper-install_agent.log
============================= test session starts ==============================
platform linux -- Python 3.10.6, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/kefei/project/dev-volttron-modular
plugins: cov-3.0.0, line-profiler-0.1.0
collected 1 item
../volttron-lib-dnp3-driver/tests/test_driver.py /tmp/tmp2ew1sbri/volttron_home: Creating platform wrapper
/tmp/tmp2ew1sbri/volttron_home: Starting Platform: /tmp/tmp2ew1sbri/volttron_home
process environment:
{'DEBUG': '',
'DEBUG_MODE': '',
'HOME': '/tmp/tmp2ew1sbri',
'HTTPS_PROXY': '',
'LANG': 'en_US.UTF-8',
'LC_ALL': 'en_US.UTF-8',
'PACKAGED_DIR': '/tmp/tmp2ew1sbri/volttron_home/packaged',
'PATH': '/home/volttron/git/volttron-core:/home/kefei/project/dev-volttron-modular/env/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/kefei/miniconda3/condabin:/home/kefei/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/kefei/.local/bin:/home/kefei/.local/bin',
'PYTHONDONTWRITEBYTECODE': '1',
'SKIP_CLEANUP': '',
'VOLTTRON_HOME': '/tmp/tmp2ew1sbri/volttron_home',
'VOLTTRON_ROOT': '/home/volttron/git/volttron-core',
'https_proxy': ''}
popen params: ['volttron', '-l/tmp/tmp2ew1sbri/volttron.log']
/tmp/tmp2ew1sbri/volttron_home: Building generic agent.
/tmp/tmp2ew1sbri/volttron_home: generating new public secret key pair /tmp/tmp2ew1sbri/volttron_home/keystores/dynamic_agent/keystore.json
/tmp/tmp2ew1sbri/volttron_home: Using vip-address tcp://127.0.0.42:5540
/tmp/tmp2ew1sbri/volttron_home: BUILD agent VOLTTRON HOME: /tmp/tmp2ew1sbri/volttron_home
/tmp/tmp2ew1sbri/volttron_home: platformwrapper.build_agent.address: tcp://127.0.0.42:5540
/tmp/tmp2ew1sbri/volttron_home: platformwrapper.build_agent spawning for identity dynamic_agent
/tmp/tmp2ew1sbri/volttron_home: Has control? True
volttron_home: /tmp/tmp2ew1sbri/volttron_home
/tmp/tmp2ew1sbri/volttron_home: Waiting for control_connection to exit
/tmp/tmp2ew1sbri/volttron_home: Command installation is: ['volttron-ctl', '--json', 'install', 'volttron-platform-driver', '--agent-config', '/tmp/tmp2ew1sbri/volttron_home/volttron-platform-driver_config_file', '--vip-identity', 'platform.driver']
/tmp/tmp2ew1sbri/volttron_home: RESPONSE FROM INSTALL IS: Install agent timed out
{
"agent_uuid": "8174ce61-c7e2-4573-a89e-609051564185"
}
/tmp/tmp2ew1sbri/volttron_home: here are the results: {
"agent_uuid": "8174ce61-c7e2-4573-a89e-609051564185"
}
/tmp/tmp2ew1sbri/volttron_home: resultobj: {'agent_uuid': '8174ce61-c7e2-4573-a89e-609051564185'}
/tmp/tmp2ew1sbri/volttron_home: Starting agent 8174ce61-c7e2-4573-a89e-609051564185
/tmp/tmp2ew1sbri/volttron_home: VOLTTRON_HOME SETTING: /tmp/tmp2ew1sbri/volttron_home
/tmp/tmp2ew1sbri/volttron_home: Waiting for control_connection to exit
/tmp/tmp2ew1sbri/volttron_home: Control connection did not exit
/tmp/tmp2ew1sbri/volttron_home: Waiting for control_connection to exit
/tmp/tmp2ew1sbri/volttron_home: Subprocess res is {
"platform.driver": {
"agent_uuid": "8174ce61-c7e2-4573-a89e-609051564185",
"name": "volttron-platform-driver-0.2.0rc1",
"identity": "platform.driver",
"agent_tag": "",
"status": "running [15598]",
"health": {
"peer": "platform.driver",
"service_agent": false,
"connected": "2023-03-11T00:08:03.964620",
"last_heartbeat": "2023-03-11T00:08:03.968573",
"message": "GOOD"
}
}
}
/tmp/tmp2ew1sbri/volttron_home: Waiting for control_connection to exit
/tmp/tmp2ew1sbri/volttron_home: Control connection did not exit
/tmp/tmp2ew1sbri/volttron_home: Waiting for control_connection to exit
/tmp/tmp2ew1sbri/volttron_home: Control connection did not exit
=============== puid 8174ce61-c7e2-4573-a89e-609051564185
volttron_home: /tmp/tmp2ew1sbri/volttron_home
/tmp/tmp2ew1sbri/volttron_home: Waiting for control_connection to exit
/tmp/tmp2ew1sbri/volttron_home: Control connection did not exit
/tmp/tmp2ew1sbri/volttron_home: Command installation is: ['volttron-ctl', '--json', 'install', 'volttron-platform-driver', '--agent-config', '/tmp/tmp2ew1sbri/volttron_home/volttron-platform-driver_config_file', '--vip-identity', 'platform.driver']
FShutting down instance: /tmp/tmp2ew1sbri/volttron_home, MESSAGE BUS: zmq
/tmp/tmp2ew1sbri/volttron_home: Waiting for control_connection to exit
/tmp/tmp2ew1sbri/volttron_home: Control connection did not exit
/tmp/tmp2ew1sbri/volttron_home: Remove PID file: /tmp/tmp2ew1sbri/volttron_home/VOLTTRON_PID
/tmp/tmp2ew1sbri/volttron_home: VHOME: /tmp/tmp2ew1sbri/volttron_home, Skip clean up flag is
/tmp/tmp2ew1sbri/volttron_home: Removing /tmp/tmp2ew1sbri/volttron_home
=================================== FAILURES ===================================
_______________ test_install_platform_driver[volttron_instance0] _______________
volttron_instance = volttron_home: /tmp/tmp2ew1sbri/volttron_home
@pytest.mark.line_profile.with_args(PlatformWrapper.install_agent,)
def test_install_platform_driver(volttron_instance):
print(volttron_instance)
vi = volttron_instance
# install platform driver
config = {
"driver_scrape_interval": 0.05,
"publish_breadth_first_all": "false",
"publish_depth_first": "false",
"publish_breadth_first": "false"
}
> puid = vi.install_agent(agent_dir="volttron-platform-driver",
config_file=config,
start=False,
vip_identity=PLATFORM_DRIVER)
../volttron-lib-dnp3-driver/tests/test_driver.py:121:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
src/volttrontesting/platformwrapper.py:1010: in install_agent
stdout = execute_command(cmd, logger=_log, env=self.env,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cmds = ['volttron-ctl', '--json', 'install', 'volttron-platform-driver', '--agent-config', '/tmp/tmp2ew1sbri/volttron_home/volttron-platform-driver_config_file', ...]
env = {'DEBUG': '', 'DEBUG_MODE': '', 'HOME': '/tmp/tmp2ew1sbri', 'HTTPS_PROXY': '', ...}
cwd = None, logger = <Logger volttrontesting.platformwrapper (DEBUG)>
err_prefix = 'Error installing agent'
def execute_command(cmds, env=None, cwd=None, logger=None, err_prefix=None) -> str:
"""Executes a command as a subprocess (Not greenlet safe!)
If the return code of the call is 0 then return stdout otherwise
raise a RuntimeError. If logger is specified then write the exception
to the logger otherwise this call will remain silent.
:param cmds:list of commands to pass to subprocess.run
:param env: environment to run the command with
:param cwd: working directory for the command
:param logger: a logger to use if errors occure
:param err_prefix: an error prefix to allow better tracing through the error message
:return: stdout string if successful
:raises RuntimeError: if the return code is not 0 from suprocess.run
"""
results = subprocess.run(cmds,
env=env,
cwd=cwd,
stderr=subprocess.PIPE,
stdout=subprocess.PIPE)
if results.returncode != 0:
err_prefix = err_prefix if err_prefix is not None else "Error executing command"
err_message = ("\n{}: Below Command failed with non zero exit code.\n"
"Command:{} \nStdout:\n{}\nStderr:\n{}\n".format(
err_prefix, results.args, results.stdout, results.stderr))
if logger:
logger.exception(err_message)
> raise RuntimeError()
E RuntimeError
../env/lib/python3.10/site-packages/volttron/utils/commands.py:71: RuntimeError
------------------------------ Captured log setup ------------------------------
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystore
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystore
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/auth.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/auth.json
INFO volttron.services.auth.auth_service:auth_service.py:1205 Created backup of /tmp/tmp2ew1sbri/volttron_home/auth.json at /tmp/tmp2ew1sbri/volttron_home/auth.json.e373bbeb-a385-44cc-bfff-3cc00ff01823.bak
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/keydiscovery/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/keydiscovery/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='PBMwTPyEZ9w4dSjcNFg1gIfxHgBK4Rx7xU7JMMnOS14', user_id='keydiscovery', capabilities={'edit_config_store': {'identity': '/.*/'}}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.auth/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.auth/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='uk6Jo1zZWccFvtOrGH5RORU24gnFeJ15AEg4HQi9-0A', user_id='platform.auth', capabilities={'edit_config_store': {'identity': '/.*/'}}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.config_store/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.config_store/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='Dz_8uE5x4WKN97CzvVzx1HxQ4mKbj7PWiviaN4pnJF4', user_id='platform.config_store', capabilities={'edit_config_store': {'identity': '/.*/'}}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.control/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.control/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='GjXC1IlwiRMpGOXsfV6amvEhmgW5y6g7D0oLABbSpzA', user_id='platform.control', capabilities={'edit_config_store': {'identity': '/.*/'}}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.health/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.health/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='hh4iQEHaf7kd_u-IEcuHJwZoPJma6gn5YUWTUJZQryw', user_id='platform.health', capabilities={'edit_config_store': {'identity': '/.*/'}}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.web/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/platform.web/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='NkfHhtLKUAK-5GYSejz-qS0KAcAHgB56OPOVXlLk1GQ', user_id='platform.web', capabilities={'allow_auth_modifications': None}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/zmq.proxy.router/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/zmq.proxy.router/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='wOvQlwpqHgiS8LaT0c9Y_3T9pEn1P0kBl8GFSLa6RmM', user_id='zmq.proxy.router', capabilities={'edit_config_store': {'identity': '/.*/'}}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/control.connection/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/control.connection/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='Fu1UhDaZd89fcCtt27SXzuYCmaQF8X_fWYU-Qa31ZXo', user_id='control.connection', capabilities={'edit_config_store': {'identity': '/.*/'}}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/keystores/dynamic_agent/keystore.json
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/keystores/dynamic_agent/keystore.json
DEBUG volttron.utils.keystore:keystore.py:178 calling generate from keystore
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG volttron.services.auth.auth_service:auth_service.py:1440 Added auth entry domain=None, address=None, mechanism='CURVE', credentials='JNa6cxNj-hYSuUbAyE-5YEsnW_PnxEtE_SPL2YQ7Bnk', user_id='dynamic_agent', capabilities={'edit_config_store': {'identity': '/.*/'}, 'allow_auth_modifications': None}
DEBUG volttron.utils.file_access:file_access.py:48 missing file /tmp/tmp2ew1sbri/volttron_home/known_hosts
INFO volttron.utils.file_access:file_access.py:49 creating file /tmp/tmp2ew1sbri/volttron_home/known_hosts
DEBUG volttron.services.auth.auth_service:auth_service.py:1044 auth record has unrecognized keys: ['identity']
DEBUG root:__init__.py:134 Creating ZMQ Core dynamic_agent
DEBUG volttron.client.vip.agent.core:core.py:527 address: tcp://127.0.0.42:5540
DEBUG volttron.client.vip.agent.core:core.py:528 identity: dynamic_agent
DEBUG volttron.client.vip.agent.core:core.py:529 agent_uuid: None
DEBUG volttron.client.vip.agent.core:core.py:530 serverkey: oh7vKIMXeizm0ikO14jfCSez0sJQDEcoXRf_Zj9v7w4
DEBUG volttron.client.vip.agent.core:core.py:673 AGENT RUNNING on ZMQ Core dynamic_agent
DEBUG volttron.client.vip.agent.core:core.py:674 keys: server: oh7vKIMXeizm0ikO14jfCSez0sJQDEcoXRf_Zj9v7w4 public: JNa6cxNj-hYSuUbAyE-5YEsnW_PnxEtE_SPL2YQ7Bnk, secret: BuOh3WsXYnvdmI_iR3-_e9_dHEKDlc_h0hOxN01jTTk
DEBUG volttron.client.vip.zmq_connection:zmq_connection.py:48 ZMQ connection dynamic_agent
DEBUG volttron.client.vip.zmq_connection:zmq_connection.py:66 connecting to url tcp://127.0.0.42:5540?publickey=JNa6cxNj-hYSuUbAyE-5YEsnW_PnxEtE_SPL2YQ7Bnk&secretkey=BuOh3WsXYnvdmI_iR3-_e9_dHEKDlc_h0hOxN01jTTk&serverkey=oh7vKIMXeizm0ikO14jfCSez0sJQDEcoXRf_Zj9v7w4
DEBUG volttron.client.vip.zmq_connection:zmq_connection.py:67 url type is <class 'str'>
INFO volttron.client.vip.agent.core:core.py:619 Connected to platform: identity: dynamic_agent version: 1.0
DEBUG volttron.client.vip.agent.core:core.py:620 Running onstart methods.
------------------------------ Captured log call -------------------------------
DEBUG volttrontesting.platformwrapper:platformwrapper.py:958 install_agent called with params
agent_wheel: None
agent_dir: volttron-platform-driver
DEBUG volttrontesting.platformwrapper:platformwrapper.py:958 install_agent called with params
agent_wheel: None
agent_dir: volttron-platform-driver
ERROR volttrontesting.platformwrapper:commands.py:70
Error installing agent: Below Command failed with non zero exit code.
Command:['volttron-ctl', '--json', 'install', 'volttron-platform-driver', '--agent-config', '/tmp/tmp2ew1sbri/volttron_home/volttron-platform-driver_config_file', '--vip-identity', 'platform.driver']
Stdout:
b''
Stderr:
b'install: error: Identity already exists, but not forced!\n'
NoneType: None
---------------------------- Captured log teardown -----------------------------
DEBUG volttron.client.vip.zmq_connection:zmq_connection.py:115 ********************************************************************
DEBUG volttron.client.vip.zmq_connection:zmq_connection.py:116 Closing connection to ZMQ: dynamic_agent
DEBUG volttron.client.vip.zmq_connection:zmq_connection.py:117 ********************************************************************
=============================== warnings summary ===============================
../env/lib/python3.10/site-packages/pkg_resources/__init__.py:121
/home/kefei/project/dev-volttron-modular/env/lib/python3.10/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
../env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
../env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
../env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
../env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
/home/kefei/project/dev-volttron-modular/env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('sphinxcontrib')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
../env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
../env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870
/home/kefei/project/dev-volttron-modular/env/lib/python3.10/site-packages/pkg_resources/__init__.py:2870: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('zope')`.
Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
declare_namespace(pkg)
-- Docs: https://docs.pytest.org/en/stable/warnings.html
= Line Profile result for volttron-lib-dnp3-driver/tests/test_driver.py::test_install_platform_driver[volttron_instance0] =
Timer unit: 1e-09 s
Total time: 102.782 s
File: /home/kefei/project/dev-volttron-modular/volttron-testing/src/volttrontesting/platformwrapper.py
Function: install_agent at line 926
Line # Hits Time Per Hit % Time Line Contents
==============================================================
926 def install_agent(self, agent_wheel: Optional[str] = None,
927 agent_dir: Optional[str] = None,
928 config_file: Optional[Union[dict, str]] = None,
929 start: bool = True,
930 vip_identity: Optional[str] = None,
931 startup_time: int = 5,
932 force: bool = False):
933 """
934 Install and optionally start an agent on the instance.
935
936 This function allows installation from an agent wheel or an
937 agent directory (NOT BOTH). If an agent_wheel is specified then
938 it is assumed to be ready for installation (has a config file).
939 If an agent_dir is specified then a config_file file must be
940 specified or if it is not specified then it is assumed that the
941 file agent_dir/config is to be used as the configuration file. If
942 none of these exist then an assertion error will be thrown.
943
944 This function will return with a uuid of the installed agent.
945
946 :param agent_wheel:
947 :param agent_dir:
948 :param config_file:
949 :param start:
950 :param vip_identity:
951 :param startup_time:
952 How long in seconds is required for the agent to start up fully
953 :param force:
954 Should this overwrite the current or not.
955 :return:
956 """
957 1 192573.0 192573.0 0.0 with with_os_environ(self.env):
958 1 552807.0 552807.0 0.0 _log.debug(f"install_agent called with params\nagent_wheel: {agent_wheel}\nagent_dir: {agent_dir}")
959 1 1167927.0 1167927.0 0.0 self.__wait_for_control_connection_to_exit__()
960 1 432855.0 432855.0 0.0 assert self.is_running(), "Instance must be running to install agent."
961 1 327.0 327.0 0.0 assert agent_wheel or agent_dir, "Invalid agent_wheel or agent_dir."
962 1 433.0 433.0 0.0 assert isinstance(startup_time, int), "Startup time should be an integer."
963
964 1 160.0 160.0 0.0 if agent_wheel:
965 assert not agent_dir
966 assert not config_file
967 assert os.path.exists(agent_wheel)
968 wheel_file = agent_wheel
969 agent_uuid = self.__install_agent_wheel__(wheel_file, False, vip_identity)
970 assert agent_uuid
971
972 # Now if the agent_dir is specified.
973 1 415.0 415.0 0.0 temp_config = None
974 1 157.0 157.0 0.0 if agent_dir:
975 1 114.0 114.0 0.0 assert not agent_wheel
976 1 3412.0 3412.0 0.0 temp_config = os.path.join(self.volttron_home,
977 1 3596.0 3596.0 0.0 os.path.basename(agent_dir) + "_config_file")
978 1 254.0 254.0 0.0 if isinstance(config_file, dict):
979 1 2670.0 2670.0 0.0 from os.path import join, basename
980 1 1601.0 1601.0 0.0 temp_config = join(self.volttron_home,
981 1 964.0 964.0 0.0 basename(agent_dir) + "_config_file")
982 1 279070.0 279070.0 0.0 with open(temp_config, "w") as fp:
983 1 26112.0 26112.0 0.0 fp.write(jsonapi.dumps(config_file))
984 1 336.0 336.0 0.0 config_file = temp_config
985 elif not config_file:
986 if os.path.exists(os.path.join(agent_dir, "config")):
987 config_file = os.path.join(agent_dir, "config")
988 else:
989 from os.path import join, basename
990 temp_config = join(self.volttron_home,
991 basename(agent_dir) + "_config_file")
992 with open(temp_config, "w") as fp:
993 fp.write(jsonapi.dumps({}))
994 config_file = temp_config
995 elif os.path.exists(config_file):
996 pass # config_file already set!
997 else:
998 raise ValueError("Can't determine correct config file.")
999
1000 1 1493.0 1493.0 0.0 cmd = [self.vctl_exe, "--json", "install", agent_dir, "--agent-config", config_file]
1001
1002 1 141.0 141.0 0.0 if force:
1003 cmd.extend(["--force"])
1004 1 318.0 318.0 0.0 if vip_identity:
1005 1 731.0 731.0 0.0 cmd.extend(["--vip-identity", vip_identity])
1006 # vctl install with start seem to have a auth issue. For now start after install
1007 # if start:
1008 # cmd.extend(["--start"])
1009 1 8876.0 8876.0 0.0 self.logit(f"Command installation is: {cmd}")
1010 1 97778269869.0 97778269869.0 95.1 stdout = execute_command(cmd, logger=_log, env=self.env,
1011 1 73.0 73.0 0.0 err_prefix="Error installing agent")
1012 1 16475.0 16475.0 0.0 self.logit(f"RESPONSE FROM INSTALL IS: {stdout}")
1013 # Because we are no longer silencing output from the install, the
1014 # the results object is now much more verbose. Our assumption is
1015 # that the result we are looking for is the only JSON block in
1016 # the output
1017
1018 1 328318.0 328318.0 0.0 match = re.search(r'^({.*})', stdout, flags=re.M | re.S)
1019 1 19555.0 19555.0 0.0 if match:
1020 1 1237.0 1237.0 0.0 results = match.group(0)
1021 else:
1022 raise ValueError(
1023 "The results were not found in the command output")
1024 1 3450.0 3450.0 0.0 self.logit("here are the results: {}".format(results))
1025
1026 #
1027 # Response from results is expected as follows depending on
1028 # parameters, note this is a json string so parse to get dictionary
1029 # {
1030 # "started": true,
1031 # "agent_pid": 26241,
1032 # "starting": true,
1033 # "agent_uuid": "ec1fd94e-922a-491f-9878-c392b24dbe50"
1034 # }
1035 1 147.0 147.0 0.0 assert results
1036
1037 1 19962.0 19962.0 0.0 resultobj = jsonapi.loads(str(results))
1038
1039 # if start:
1040 # assert resultobj['started']
1041 1 285.0 285.0 0.0 agent_uuid = resultobj['agent_uuid']
1042
1043 1 138.0 138.0 0.0 assert resultobj
1044 1 4550.0 4550.0 0.0 self.logit(f"resultobj: {resultobj}")
1045 1 127.0 127.0 0.0 assert agent_uuid
1046 1 5000988313.0 5000988313.0 4.9 time.sleep(5)
1047 1 940.0 940.0 0.0 if start:
1048 self.logit(f"We are running {agent_uuid}")
1049 # call start after install for now. vctl install with start seem to have auth issues.
1050 self.start_agent(agent_uuid)
1051 assert self.is_agent_running(agent_uuid)
1052
1053 # remove temp config_file
1054 1 33493.0 33493.0 0.0 if temp_config and os.path.isfile(temp_config):
1055 1 66531.0 66531.0 0.0 os.remove(temp_config)
1056
1057 1 1304.0 1304.0 0.0 return agent_uuid
=========================== short test summary info ============================
FAILED ../volttron-lib-dnp3-driver/tests/test_driver.py::test_install_platform_driver[volttron_instance0]
================== 1 failed, 7 warnings in 177.89s (0:02:57) ===================
@kefeimo
Copy link
Author

kefeimo commented May 9, 2023

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment