def test_can_get_version(setup_platform, vc_agent): # split vc_agent into it's respective parts. vc, vcp_identity = vc_agent import subprocess, os script = "scripts/get_versions.py" python = "python" args = [python, script] response = subprocess.check_output(args=[python, script], cwd=get_volttron_root(), universal_newlines=True) expected_version = None for line in response.split("\n"): agent, version = line.strip().split(',') if "VolttronCentralPlatform" in agent: expected_version = version break # Note this is using vcp because it has the version info not the # vcp_identity version = vc.vip.rpc.call( VOLTTRON_CENTRAL_PLATFORM, 'agent.version').get(timeout=STANDARD_GET_TIMEOUT) # version = setup_platform.call('agent.version', timeout=2) assert version is not None assert version == expected_version
def test_can_get_version(setup_platform, vc_agent): # split vc_agent into it's respective parts. vc, vcp_identity = vc_agent import subprocess, os script = "scripts/get_versions.py" python = "python" args = [python, script] response = subprocess.check_output(args=[python, script], cwd=get_volttron_root()) expected_version = None for line in response.split("\n"): agent, version = line.strip().split(',') if "VolttronCentralPlatform" in agent: expected_version = version break # Note this is using vcp because it has the version info not the # vcp_identity version = vc.vip.rpc.call(VOLTTRON_CENTRAL_PLATFORM, 'agent.version').get(timeout=STANDARD_GET_TIMEOUT) # version = setup_platform.call('agent.version', timeout=2) assert version is not None assert version == expected_version
def config_store(request, config_store_connection): # Always have fake.csv ready to go. # Add up fake.csv to config store config_path = os.path.join( get_volttron_root(), "scripts/scalability-testing/fake_unit_testing.csv") with open(config_path, 'r') as f: registry_config_string = f.read() config_store_connection.call("manage_store", PLATFORM_DRIVER, "fake.csv", registry_config_string, config_type="csv") def cleanup(): # Reset platform driver config store print("Wiping out store.") config_store_connection.call("manage_delete_store", PLATFORM_DRIVER) gevent.sleep(0.1) request.addfinalizer(cleanup) return config_store_connection
valueline += "%s," % output_dict[keys[k]] else: keyline += "%s" % keys[k] valueline += "%s" % output_dict[keys[k]] sys.stdout.write("%s\n%s\n" % (keyline, valueline)) if __name__ == '__main__': parser = argparse.ArgumentParser(version=__version__) parser.add_argument("-a", "--vip-address", default=get_address(), help="vip-address to connect to.") parser.add_argument("-vh", "--volttron-home", default=get_home(), help="local volttron-home for the instance.") parser.add_argument("-vr", "--volttron-root", default=get_volttron_root(), help="location of the volttron root on the filesystem.") parser.add_argument("-s", "--agent-source", required=True, help="source directory of the agent which is to be installed.") parser.add_argument("-i", "--vip-identity", default=None, help="identity of the agent to be installed (unique per instance)") parser.add_argument("-c", "--config", default=None, type=file, help="agent configuration file that will be packaged with the agent.") parser.add_argument("-wh", "--wheelhouse", default=None, help="location of agents after they have been built") parser.add_argument("-t", "--tag", default=None, help="a tag is a means of identifying an agent.") parser.add_argument("-f", "--force", action='store_true', help="agents are uninstalled by tag so force allows multiple agents to be removed at one go.") parser.add_argument("--priority", default=-1, type=int, help="priority of startup during instance startup")
def test_forward_bacnet_cov_value(volttron_instance, test_agent): """Tests the functionality of BACnet change of value forwarding in the Platform Driver and driver.py""" # Reset platform driver config store cmd = ['volttron-ctl', 'config', 'delete', PLATFORM_DRIVER, '--all'] retcode = check_call(cmd, env=volttron_instance.env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) assert retcode == 0 # Add fake device configuration fake_csv_infile = os.path.join(get_volttron_root(), 'examples/configurations/drivers/fake.csv') cmd = [ 'volttron-ctl', 'config', 'store', PLATFORM_DRIVER, 'fake.csv', fake_csv_infile, '--csv' ] retcode = check_call(cmd, env=volttron_instance.env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) assert retcode == 0 fakedriver_infile = os.path.join( get_volttron_root(), 'examples/configurations/drivers/fake.config') cmd = [ 'volttron-ctl', 'config', 'store', PLATFORM_DRIVER, "devices/fakedriver", fakedriver_infile, '--json' ] retcode = check_call(cmd, env=volttron_instance.env, stdout=subprocess.PIPE, stderr=subprocess.PIPE) assert retcode == 0 # install platform driver, start the platform driver, which starts the device platform_uuid = volttron_instance.install_agent( agent_dir=get_services_core("PlatformDriverAgent"), config_file={}, start=True) print("agent id: ", platform_uuid) # tell the platform driver to forward the value point_name = "PowerState" device_path = "fakedriver" result_dict = {"fake1": "test", "fake2": "test", "fake3": "test"} test_agent.vip.rpc.call(PLATFORM_DRIVER, 'forward_bacnet_cov_value', device_path, point_name, result_dict) # wait for the publishes to make it to the bus gevent.sleep(2) # Mock checks # Should have one "PowerState" publish for each item in the result dict # Total all publishes likely will include regular scrapes assert test_agent.cov_callback.call_count >= 3 test_count = 0 for call_arg in test_agent.cov_callback.call_args_list: if call_arg[0][5][0].get("PowerState", False): test_count += 1 assert test_count == 3
import logging import os import sys from time import sleep import threading from threading import Thread import Queue from crate import client as crate_client import pymongo from bson.objectid import ObjectId from zmq.utils import jsonapi from volttron.platform import get_volttron_root sys.path.insert(0, os.path.join(get_volttron_root(), "services/core/CrateHistorian")) from crate_historian import crate_utils from volttron.platform.agent import utils from volttron.platform.dbutils import mongoutils logging.basicConfig(level=logging.DEBUG) _log = logging.getLogger(__name__) for key in logging.Logger.manager.loggerDict: _log.debug(key) logging.getLogger('crate.client.http').setLevel(logging.INFO) logging.getLogger('urllib3.connectionpool').setLevel(logging.INFO) root = os.path.dirname(os.path.abspath(__file__))
if __name__ == '__main__': parser = argparse.ArgumentParser(version=__version__) parser.add_argument("-a", "--vip-address", default=get_address(), help="vip-address to connect to.") parser.add_argument("-vh", "--volttron-home", default=get_home(), help="local volttron-home for the instance.") parser.add_argument( "-vr", "--volttron-root", default=get_volttron_root(), help="location of the volttron root on the filesystem.") parser.add_argument( "-s", "--agent-source", required=True, help="source directory of the agent which is to be installed.") parser.add_argument( "-i", "--vip-identity", default=None, help="identity of the agent to be installed (unique per instance)") parser.add_argument( "-c", "--config", default=None,
import os import sys from time import sleep import threading from threading import Thread import Queue from crate import client as crate_client import pymongo from bson.objectid import ObjectId from zmq.utils import jsonapi from volttron.platform import get_volttron_root sys.path.insert( 0, os.path.join(get_volttron_root(), "services/core/CrateHistorian")) from crate_historian import crate_utils from volttron.platform.agent import utils from volttron.platform.dbutils import mongoutils logging.basicConfig(level=logging.DEBUG) _log = logging.getLogger(__name__) for key in logging.Logger.manager.loggerDict: _log.debug(key) logging.getLogger('crate.client.http').setLevel(logging.INFO) logging.getLogger('urllib3.connectionpool').setLevel(logging.INFO) root = os.path.dirname(os.path.abspath(__file__)) with open('{}/crate_config'.format(root), 'r') as fp:
def get_xml_path(): root = get_volttron_root() services_core = os.path.join(root, "services/core") return os.path.join(services_core, "SunspecInverter/XML_files")