Skip to content

Commit

Permalink
Merge pull request #652 from ibpsa/issue617_refactorService_with_hist…
Browse files Browse the repository at this point in the history
…ory2

Closes #617
  • Loading branch information
dhblum authored Nov 12, 2024
2 parents 6ceeba2 + 00add91 commit de089cb
Show file tree
Hide file tree
Showing 85 changed files with 27,778 additions and 816 deletions.
37 changes: 34 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
TESTCASE='testcase2'

APP_PATH='/home/user'
# Performance configuration
NODE_ENV=production
BOPTEST_TIMEOUT=900
BOPTEST_LOGLEVEL=INFO

# Redis configuration
BOPTEST_REDIS_HOST=redis

# Job queue configuration
BOPTEST_JOB_QUEUE_URL=http://goaws:4100/queue/local-queue1
AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxx
AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
MINIO_ROOT_USER=user
MINIO_ROOT_PASSWORD=password

# Object store (S3) related configuration
BOPTEST_INTERNAL_S3_URL=http://minio:9000
BOPTEST_PUBLIC_S3_URL=http://minio:9000
BOPTEST_S3_BUCKET=boptest
BOPTEST_REGION=us-west-1

# Provisioning and test configuration
BOPTEST_SERVER=http://web
BOPTEST_WS_SERVER=ws://web/ws

BOPTEST_DASHBOARD_SERVER=https://dashboard.boptest.net/

# Testing configuration
# These fake test accounts will be used in place of BOPTEST_DASHBOARD_SERVER accounts
BOPTEST_USE_TEST_USERS="true"
BOPTEST_TEST_USERNAME="canary"
BOPTEST_TEST_KEY="canarykey"
BOPTEST_TEST_PRIVILEGED_USERNAME="crusader"
BOPTEST_TEST_PRIVILEGED_KEY="crusaderkey"
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
dist: focal

language: python

branches:
Expand All @@ -13,20 +15,20 @@ notifications:
services:
- docker

env:
- DOCKER_COMPOSE_VERSION=1.26.0

before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
- sudo systemctl stop docker.service && sudo systemctl stop docker.socket
- curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- yes | sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- sudo apt-get update
- sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
- sudo systemctl start docker

before_script:
- export PYTHONPATH=$PYTHONPATH:$(pwd)

jobs:
include:
- script: docker compose up -d web worker provision && sleep 10 && docker compose up test --no-deps --exit-code-from test
- python: 3.9
install: pip install --upgrade pip && pip install pandas==1.2.5 numpy==1.20.2 requests==2.25.1
script: cd testing && make build_jm_image && make test_parser
Expand Down
41 changes: 0 additions & 41 deletions Dockerfile

This file was deleted.

144 changes: 94 additions & 50 deletions README.md

Large diffs are not rendered by default.

32 changes: 19 additions & 13 deletions bacnet/BopTestProxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
nextState = None
g = None

baseurl = "http://localhost:5000"
baseurl = "http://127.0.0.1:80"
boptest_measurements = None
boptest_inputs = None

Expand Down Expand Up @@ -140,7 +140,7 @@ def update_boptest_data():
"""Read the current simulation data from the API and set the object values."""
if _debug:
update_boptest_data._debug("update_boptest_data")
global objects, inputs, baseurl
global objects, inputs, baseurl, testid

# ask the web service
# We get results direct from /advance now but you could ask the simulation for historic data
Expand Down Expand Up @@ -180,11 +180,7 @@ def update_boptest_data():


#print("Advancing with signals: " + str(signals))
response = requests.post(
# "http://localhost:5000/advance", json={"oveAct_u": next_oveAct_u, "oveAct_activate": next_oveAct_activate}
'{0}/advance'.format(baseurl), json=signals

)
response = requests.post('{0}/advance/{1}'.format(baseurl,testid), json=signals)
if response.status_code != 200:
print("Error response: %r" % (response.status_code,))
return
Expand Down Expand Up @@ -228,9 +224,10 @@ def main():

parser = ConfigArgumentParser(description=__doc__)

parser.add_argument('testcase', type=str, help="Name of BOPTEST test case to deploy")
parser.add_argument('start_time', type=int, default=0, help="timestamp (in seconds) at which to start the simulation")
parser.add_argument('warmup_period', type=int, default=0, help="timestamp (in seconds) at which to start the simulation")
parser.add_argument('--baseurl', dest='baseurl', type=str, default='http://localhost:5000', help="URL for BOPTest endpoint")
parser.add_argument('--baseurl', dest='baseurl', type=str, default='http://127.0.0.1:80', help="URL for BOPTest endpoint")
# parse the command line arguments
args = parser.parse_args()
baseurl = args.baseurl
Expand All @@ -243,28 +240,31 @@ def main():
# TODO: check the results to make sure we acutally get an OK!
#
global nextState
global testid

res = requests.put('{0}/initialize'.format(baseurl), json={'start_time':args.start_time, 'warmup_period':args.warmup_period} ).json()
testid = requests.post("{0}/testcases/{1}/select".format(baseurl, args.testcase)).json()["testid"]
res = requests.put('{0}/initialize/{1}'.format(baseurl,testid), json={'start_time':args.start_time, 'warmup_period':args.warmup_period} ).json()
nextState = res

global boptest_measurements, boptest_inputs
boptest_measurements = requests.get(baseurl + "/measurements").json()
boptest_inputs = requests.get(baseurl+"/inputs").json()
boptest_measurements = requests.get('{0}/measurements/{1}'.format(baseurl,testid)).json()
boptest_inputs = requests.get('{0}/inputs/{1}'.format(baseurl,testid)).json()

# We advance the simulation by 5 seconds at each call to /advance, and APPINTERVAL is also 5 seconds, so the simulationo
# moves in sync with wallclock time. To see things happen faster, set this time greater than 5 seconds
res = requests.put('{0}/step'.format(baseurl), json={'step':5})
res = requests.put('{0}/step/{1}'.format(baseurl,testid), json={'step':5})

# make a device object
this_device = LocalDeviceObject(ini=args.ini)
print(args.ini)
if _debug:
_log.debug(" - this_device: %r", this_device)

# make a sample application
this_application = ReadPropertyMultipleApplication(this_device, args.ini.address)

# create the objects and add them to the application
test_case_name = requests.get('{0}/name'.format(baseurl)).json()['payload']['name']
test_case_name = requests.get('{0}/name/{1}'.format(baseurl,testid)).json()['payload']['name']
file_name = '../testcases/{0}/models/bacnet.ttl'.format(test_case_name)
create_objects(this_application, file_name)

Expand All @@ -276,6 +276,12 @@ def main():

run()

# shutdown test case when done
res = requests.put("{0}/stop/{1}".format(baseurl, testid))
if res.status_code == 200:
_log.debug('Done shutting down test case.')
else:
_log.debug('Error shutting down test case.')
if _debug:
_log.debug("fini")

Expand Down
2 changes: 1 addition & 1 deletion bacnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The BACnet objects are configured based on a .ttl file for each test case locate

2. Configure ``BACpypes.ini``, particularly the address to define where the BACnet device will sit on the network.

3. In a new terminal, run ``$ python BopTestProxy.py 0 0`` to deploy the BACnet device and objects for the test case and initialize the test case with start time of 0 and warmup period of 0.
3. In a new terminal, run ``$ python BopTestProxy.py bestest_air 0 0`` to deploy the BACnet device and objects for the test case ``bestest_air`` (or choose another) and initialize it with start time of 0 and warmup period of 0.

4. Use a BACnet application to locate the device and objects on the network and communicate with them.

Expand Down
24 changes: 17 additions & 7 deletions bacnet/create_ttl.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
# -*- coding: utf-8 -*-
"""
Creates ttl file for creation of Brick objects.
Deploy a test case and then use this file to read the available input
and measurement points and create the ttl file accordingly.
To run this script:
1. Deploy BOPTEST as described in README.md at root of repository
2. Set 'test_case_name' parameter to test case that needs bacnet .ttl
(i.e. bestest_air)
3. Run script
4. ''<test_case_name>.ttl'' file will be generated with inputs and measurement
bacnet points
"""

import requests

# Set url for BOPTEST test case
baseurl = 'http://localhost:5000'
baseurl = 'http://127.0.0.1:80'

# Get the test case name
test_case_name = requests.get('{0}/name'.format(baseurl)).json()['payload']['name']
# Instatiate test case
test_case_name = 'bestest_air'
testid = requests.post("{0}/testcases/{1}/select".format(baseurl, test_case_name)).json()["testid"]

# Write the file prefix
prefix = '@prefix bldg: <urn:example#> .\n\
Expand All @@ -31,10 +38,13 @@
f.write(prefix)

# Get all the points and their metadata from BOPTEST test case
measurement_points = requests.get('{0}/measurements'.format(baseurl)).json()['payload']
input_points = requests.get('{0}/inputs'.format(baseurl)).json()['payload']
measurement_points = requests.get('{0}/measurements/{1}'.format(baseurl,testid)).json()['payload']
input_points = requests.get('{0}/inputs/{1}'.format(baseurl,testid)).json()['payload']
points = measurement_points | input_points

# Stop test case
requests.put('{0}/stop/{1}'.format(baseurl, testid))

# Write the bacnet objects for each point in the file
with open(test_case_name+'.ttl', 'a') as f:
obj_id = 1
Expand Down
Loading

0 comments on commit de089cb

Please sign in to comment.