Skip to content

Commit de089cb

Browse files
authored
Merge pull request #652 from ibpsa/issue617_refactorService_with_history2
Closes #617
2 parents 6ceeba2 + 00add91 commit de089cb

File tree

85 files changed

+27778
-816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+27778
-816
lines changed

.env

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1-
TESTCASE='testcase2'
2-
3-
APP_PATH='/home/user'
1+
# Performance configuration
2+
NODE_ENV=production
3+
BOPTEST_TIMEOUT=900
4+
BOPTEST_LOGLEVEL=INFO
5+
6+
# Redis configuration
7+
BOPTEST_REDIS_HOST=redis
8+
9+
# Job queue configuration
10+
BOPTEST_JOB_QUEUE_URL=http://goaws:4100/queue/local-queue1
11+
AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxxxxxx
12+
AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
13+
MINIO_ROOT_USER=user
14+
MINIO_ROOT_PASSWORD=password
15+
16+
# Object store (S3) related configuration
17+
BOPTEST_INTERNAL_S3_URL=http://minio:9000
18+
BOPTEST_PUBLIC_S3_URL=http://minio:9000
19+
BOPTEST_S3_BUCKET=boptest
20+
BOPTEST_REGION=us-west-1
21+
22+
# Provisioning and test configuration
23+
BOPTEST_SERVER=http://web
24+
BOPTEST_WS_SERVER=ws://web/ws
25+
26+
BOPTEST_DASHBOARD_SERVER=https://dashboard.boptest.net/
27+
28+
# Testing configuration
29+
# These fake test accounts will be used in place of BOPTEST_DASHBOARD_SERVER accounts
30+
BOPTEST_USE_TEST_USERS="true"
31+
BOPTEST_TEST_USERNAME="canary"
32+
BOPTEST_TEST_KEY="canarykey"
33+
BOPTEST_TEST_PRIVILEGED_USERNAME="crusader"
34+
BOPTEST_TEST_PRIVILEGED_KEY="crusaderkey"

.travis.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
dist: focal
2+
13
language: python
24

35
branches:
@@ -13,20 +15,20 @@ notifications:
1315
services:
1416
- docker
1517

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

2526
before_script:
2627
- export PYTHONPATH=$PYTHONPATH:$(pwd)
2728

2829
jobs:
2930
include:
31+
- script: docker compose up -d web worker provision && sleep 10 && docker compose up test --no-deps --exit-code-from test
3032
- python: 3.9
3133
install: pip install --upgrade pip && pip install pandas==1.2.5 numpy==1.20.2 requests==2.25.1
3234
script: cd testing && make build_jm_image && make test_parser

Dockerfile

Lines changed: 0 additions & 41 deletions
This file was deleted.

README.md

Lines changed: 94 additions & 50 deletions
Large diffs are not rendered by default.

bacnet/BopTestProxy.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
nextState = None
5151
g = None
5252

53-
baseurl = "http://localhost:5000"
53+
baseurl = "http://127.0.0.1:80"
5454
boptest_measurements = None
5555
boptest_inputs = None
5656

@@ -140,7 +140,7 @@ def update_boptest_data():
140140
"""Read the current simulation data from the API and set the object values."""
141141
if _debug:
142142
update_boptest_data._debug("update_boptest_data")
143-
global objects, inputs, baseurl
143+
global objects, inputs, baseurl, testid
144144

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

181181

182182
#print("Advancing with signals: " + str(signals))
183-
response = requests.post(
184-
# "http://localhost:5000/advance", json={"oveAct_u": next_oveAct_u, "oveAct_activate": next_oveAct_activate}
185-
'{0}/advance'.format(baseurl), json=signals
186-
187-
)
183+
response = requests.post('{0}/advance/{1}'.format(baseurl,testid), json=signals)
188184
if response.status_code != 200:
189185
print("Error response: %r" % (response.status_code,))
190186
return
@@ -228,9 +224,10 @@ def main():
228224

229225
parser = ConfigArgumentParser(description=__doc__)
230226

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

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

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

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

258257
# make a device object
259258
this_device = LocalDeviceObject(ini=args.ini)
259+
print(args.ini)
260260
if _debug:
261261
_log.debug(" - this_device: %r", this_device)
262262

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

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

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

277277
run()
278278

279+
# shutdown test case when done
280+
res = requests.put("{0}/stop/{1}".format(baseurl, testid))
281+
if res.status_code == 200:
282+
_log.debug('Done shutting down test case.')
283+
else:
284+
_log.debug('Error shutting down test case.')
279285
if _debug:
280286
_log.debug("fini")
281287

bacnet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The BACnet objects are configured based on a .ttl file for each test case locate
2424

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

27-
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.
27+
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.
2828

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

bacnet/create_ttl.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
# -*- coding: utf-8 -*-
22
"""
33
Creates ttl file for creation of Brick objects.
4-
Deploy a test case and then use this file to read the available input
5-
and measurement points and create the ttl file accordingly.
4+
5+
To run this script:
6+
1. Deploy BOPTEST as described in README.md at root of repository
7+
2. Set 'test_case_name' parameter to test case that needs bacnet .ttl
8+
(i.e. bestest_air)
9+
3. Run script
10+
4. ''<test_case_name>.ttl'' file will be generated with inputs and measurement
11+
bacnet points
612
713
"""
814

915
import requests
1016

1117
# Set url for BOPTEST test case
12-
baseurl = 'http://localhost:5000'
18+
baseurl = 'http://127.0.0.1:80'
1319

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

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

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

45+
# Stop test case
46+
requests.put('{0}/stop/{1}'.format(baseurl, testid))
47+
3848
# Write the bacnet objects for each point in the file
3949
with open(test_case_name+'.ttl', 'a') as f:
4050
obj_id = 1

0 commit comments

Comments
 (0)