Skip to content

Commit

Permalink
Merge branch 'jklarson-issue/475-agent_config_tests' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
craig8 committed Sep 26, 2020
2 parents f40dc41 + ee95bc7 commit dd588b6
Show file tree
Hide file tree
Showing 80 changed files with 3,239 additions and 3,007 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FileWatchPulblisher Agent
File Watch Publisher Agent
~~~~~~~~~~~~~~~~~~~~~~~~~~


Expand All @@ -15,16 +15,18 @@ A simple configuration for FileWatchPublisher with two files to monitor is as fo

::

[
{
"file": "/var/log/syslog",
"topic": "platform/syslog"
},
{
"file": "/home/volttron/tempfile.txt",
"topic": "temp/filepublisher"
}
]
{
"files": [
{
"file": "/var/log/syslog",
"topic": "platform/syslog"
},
{
"file": "/home/volttron/tempfile.txt",
"topic": "temp/filepublisher"
}
]
}

Using this example configuration, FileWatchPublisher will watch syslog and tempFile.txt files and
publish the changes per line on their respective topics.
500 changes: 112 additions & 388 deletions services/core/ActuatorAgent/tests/test_actuator_pubsub.py

Large diffs are not rendered by default.

149 changes: 74 additions & 75 deletions services/core/ActuatorAgent/tests/test_actuator_rpc.py

Large diffs are not rendered by default.

197 changes: 68 additions & 129 deletions services/core/ActuatorAgent/tests/test_scheduler.py

Large diffs are not rendered by default.

44 changes: 30 additions & 14 deletions services/core/CrateHistorian/tests/test_crate_historian.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,17 @@

import gevent
import pytest

from volttron.platform import get_services_core

import os
import json
try:
from crate import client
HAS_CRATE = True
except ImportError:
HAS_CRATE = False

from volttron.platform import get_services_core
from volttron.platform.messaging.health import STATUS_GOOD


crate_config = {
"schema": "testing",
Expand All @@ -73,8 +75,8 @@
u'topics'
]

# used only in one test function. And clean up should happen between
# different volttron_instance types

# used only in one test function. And clean up should happen between different volttron_instance types
@pytest.fixture()
def crate_connection1():
host = crate_config_no_schema['connection']['params']['host']
Expand All @@ -86,8 +88,7 @@ def crate_connection1():
conn.close()


# used only in one test function. And clean up should happen between
# different volttron_instance types
# used only in one test function. And clean up should happen between different volttron_instance types
@pytest.fixture()
def crate_connection2():
host = crate_config['connection']['params']['host']
Expand All @@ -100,13 +101,11 @@ def crate_connection2():
conn.close()



def clean_schema_from_database(connection, schema):
tables = retrieve_tables_from_schema(connection, schema)
cursor = connection.cursor()
for tbl in tables:
query = "DROP TABLE IF EXISTS {schema}.{table}".format(table=tbl,
schema=schema)
query = "DROP TABLE IF EXISTS {schema}.{table}".format(table=tbl, schema=schema)
cursor.execute(query)
cursor.close()

Expand All @@ -133,8 +132,7 @@ def test_creates_default_table_prefixes(volttron_instance, crate_connection1):
vi = volttron_instance
assert not retrieve_tables_from_schema(crate_connection1, "historian")

agent_uuid = vi.install_agent(agent_dir=get_services_core("CrateHistorian"),
config_file=crate_config_no_schema)
agent_uuid = vi.install_agent(agent_dir=get_services_core("CrateHistorian"), config_file=crate_config_no_schema)

gevent.sleep(2)
tables = retrieve_tables_from_schema(crate_connection1, "historian")
Expand All @@ -154,8 +152,7 @@ def test_creates_schema_prefix_tables(volttron_instance, crate_connection2):
vi = volttron_instance
assert not retrieve_tables_from_schema(crate_connection2, "testing")

agent_uuid = vi.install_agent(agent_dir=get_services_core("CrateHistorian"),
config_file=crate_config)
agent_uuid = vi.install_agent(agent_dir=get_services_core("CrateHistorian"), config_file=crate_config)
gevent.sleep(2)
tables = retrieve_tables_from_schema(crate_connection2, "testing")

Expand All @@ -166,3 +163,22 @@ def test_creates_schema_prefix_tables(volttron_instance, crate_connection2):
if agent_uuid:
vi.remove_agent(agent_uuid)


@pytest.mark.historian
def test_crate_default_config(volttron_instance):
"""
Test the default configuration file included with the agent
"""
publish_agent = volttron_instance.build_agent(identity="test_agent")
gevent.sleep(1)

config_path = os.path.join(get_services_core("CrateHistorian"), "config")
with open(config_path, "r") as config_file:
config_json = json.load(config_file)
assert isinstance(config_json, dict)
volttron_instance.install_agent(
agent_dir=get_services_core("CrateHistorian"),
config_file=config_json,
start=True,
vip_identity="health_test")
assert publish_agent.vip.rpc.call("health_test", "health.get_status").get(timeout=10).get('status') == STATUS_GOOD
2 changes: 2 additions & 0 deletions services/core/Darksky/darksky/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ def query_current_weather(self, location):
"""
darksky_response = self.get_darksky_data(
'get_current_weather', location)
if 'currently' not in darksky_response:
_log.error("Current data not found in Dark Sky response: {}".format(darksky_response))
current_response = darksky_response.pop('currently')
# Darksky required attribution
current_response["attribution"] = "Powered by Dark Sky"
Expand Down
Loading

0 comments on commit dd588b6

Please sign in to comment.