Skip to content

Commit 2a1ce9a

Browse files
author
btgoodwin
committed
Adjusted old tests to match Geon's published API, added two helper scripts to generate an RF snapshot (for FEI FileReader) and the missing SigTest waveform from the old tests. Added a Docker Compose YAML for future CI usage.
1 parent dd40b99 commit 2a1ce9a

12 files changed

Lines changed: 256 additions & 42 deletions

docker-compose.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
version: "3"
2+
volumes:
3+
sdrroot:
4+
rf_snapshots:
5+
6+
services:
7+
# OmniORB services
8+
omni:
9+
image: geontech/redhawk-omniserver
10+
hostname: omni
11+
ports:
12+
- "2809:2809"
13+
- "11169:11169"
14+
15+
# Standard REDHAWK SDR Domain
16+
domain:
17+
image: geontech/redhawk-domain
18+
depends_on:
19+
- omni
20+
environment:
21+
- DOMAINNAME=REDHAWK_DEV
22+
- OMNISERVICEIP=omni
23+
volumes:
24+
- sdrroot:/var/redhawk/sdr
25+
26+
# Standard GPP
27+
gpp:
28+
image: geontech/redhawk-gpp
29+
depends_on:
30+
- domain
31+
environment:
32+
- DOMAINNAME=REDHAWK_DEV
33+
- NODENAME=GPP_Node
34+
- GPPNAME=GPP
35+
- OMNISERVICEIP=omni
36+
37+
# FEI FileReader Device runner mounted to the snapshot.
38+
fei_file_reader:
39+
image: geontech/redhawk-fei-filereader
40+
build: http://github.com/GeonTech/FEI_FileReader.git
41+
environment:
42+
- DOMAINNAME=REDHAWK_DEV
43+
- NODENAME=FEI_FR_Node
44+
- OMNISERVICEIP=omni
45+
volumes:
46+
- rf_snapshots:/var/rf_snapshots
47+
48+
# REST-Python Unit Under Test (UUT)
49+
rest:
50+
image: geontech/redhawk-webserver
51+
depends_on:
52+
- domain
53+
- gpp
54+
- fei_file_reader
55+
environment:
56+
- OMNISERVICEIP=omni
57+
ports:
58+
- "8080:8080"
59+
# 1. Mount the external rest-python
60+
# 2. Share SDRROOT with the Domain for access to standard components in sandbox
61+
# 3. Share RF_Snapshots with the FEI FileReader
62+
volumes:
63+
- ./:/opt/rest-python
64+
- sdrroot:/var/redhawk/sdr
65+
- rf_snapshots:/var/rf_snapshots
66+
command: [bash, -l, -c, /opt/rest-python/test.sh]

test.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
#
33
# This file is protected by Copyright. Please refer to the COPYRIGHT file
44
# distributed with this source distribution.
@@ -27,7 +27,16 @@ pyvenv="${SCRIPTPATH}/pyvenv"
2727

2828
source /etc/profile.d/redhawk.sh
2929

30+
# Create a simple waveform for testing
31+
SIGTEST="$(python tests/generate_sigtest_sad.py)"
32+
RF_SNAPSHOT="$(python tests/generate_rf_snapshot.py)"
33+
RF_SNAPSHOT="${RF_SNAPSHOT##*$'\n'}"
34+
3035
# Clear virtual env
3136
./setup.sh install
3237

3338
exec ${pyvenv} python ${SCRIPTPATH}/test.py $@
39+
40+
# Clean up
41+
echo "Cleaning up ${SIGTEST} and ${RF_SNAPSHOT}"
42+
rm ${SIGTEST} ${RF_SNAPSHOT}

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,6 @@
3636
from device import DeviceTests
3737
from application import ApplicationTests
3838
from component import ComponentTests
39-
from bulkio import BulkIOTests
39+
from bulkio_tests import BulkIOTests
4040
from port import PortTests
4141
from concurrent import ConcurrencyTests

tests/application.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,11 @@ def setUp(self):
3737

3838
def tearDown(self):
3939
# kill SigTest waveforms
40-
url = '/domains/'+Default.DOMAIN_NAME
41-
json, resp = self._json_request(url, 200)
42-
if 'applications' not in json:
43-
json['applications'] = []
44-
for a in json['applications']:
45-
if a['name'].startswith('SigTest'):
46-
self._json_request(
47-
'/domains/'+Default.DOMAIN_NAME+'/applications/'+a['id'],
48-
200,
49-
'DELETE'
50-
)
40+
dom = self.redhawk._get_domain(Default.DOMAIN_NAME)
41+
apps = dom.find_app()
42+
for app in apps:
43+
if app.name.startswith(Default.WAVEFORM):
44+
app.releaseObject()
5145
super(ApplicationTests, self).tearDown();
5246

5347
@tornado.gen.coroutine
@@ -125,11 +119,12 @@ def test_info(self):
125119
self.assertAttr(json, 'id', wf_id)
126120

127121
self.assertList(json, 'properties')
128-
# TODO: self.assertProperties(json['properties'])
122+
self.assertProperties(json['properties'])
129123

130124
@tornado.testing.gen_test
131125
def test_detect_new_applications(self):
132-
yield [ self.detect_new_applications() for x in xrange(10) ]
126+
# yield [ self.detect_new_applications() for x in xrange(10) ]
127+
yield self.detect_new_applications()
133128

134129
@tornado.gen.coroutine
135130
def detect_new_applications(self):
@@ -138,31 +133,29 @@ def detect_new_applications(self):
138133

139134
# start a new app
140135
id = yield self.redhawk.launch_application(Default.DOMAIN_NAME, Default.WAVEFORM)
141-
142-
# yield self._async_sleep(.5)
143-
136+
self._async_sleep(1)
137+
144138
# ensure it exists in the application
145139
url, apps2 = yield self._get_applications()
146140
if id not in (a['id'] for a in apps2):
147141
self.fail("Expecting %s in domain %s" % (id, Default.DOMAIN_NAME))
148-
# if (len(apps)+1 != len(apps2)):
149-
# self.fail("Expecting one additional app %s %s" % (apps, apps2))
142+
if (len(apps)+1 != len(apps2)):
143+
self.fail("Expecting one additional app %s %s" % (apps, apps2))
150144

151145
# now release it
152146
yield self.redhawk.release_application(Default.DOMAIN_NAME, id)
147+
self._async_sleep(1)
153148

154149
# ensure it is missing in the application list
155150
url, apps3 = yield self._get_applications()
156151
if id in (a['id'] for a in apps3):
157152
self.fail("Not Expecting %s in domain %s" % (id, Default.DOMAIN_NAME))
158-
# if (len(apps) != len(apps3)):
159-
# self.fail("Expecting same number of apps %s %s" % (apps, apps3))
153+
if (len(apps) != len(apps3)):
154+
self.fail("Expecting same number of apps %s %s" % (apps, apps3))
160155

161156

162157
@tornado.testing.gen_test
163158
def test_not_found(self):
164159
url = '/domains/%s/applications/adskfhsdhfasdhjfhsd' %Default.DOMAIN_NAME
165160
json, resp = yield self._async_json_request(url, 404)
166-
167-
self._resource_not_found(json)
168161

tests/base.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,26 @@ def assertIdList(self, data, name):
146146

147147
def assertProperties(self, data):
148148
self.assertTrue(isinstance(data, list))
149+
MODES = ['readwrite', 'writeonly', 'readonly']
150+
SCA_TYPES = ['simple', 'simpleSeq', 'struct', 'structSeq']
149151
for prop in data:
150-
self.assertList(prop, 'kinds')
152+
# CORBA and SCA Properties have these 4 fields for certain.
153+
self.assertTrue('id' in prop)
151154
self.assertTrue('name' in prop)
152-
self.assertTrue('value' in prop)
153155
self.assertTrue('scaType' in prop)
154-
self.assertTrue('mode' in prop)
155-
self.assertTrue('type' in prop)
156-
self.assertTrue('id' in prop)
156+
self.assertTrue(prop['scaType'] in SCA_TYPES)
157+
self.assertTrue('value' in prop)
158+
if prop['scaType'] != 'simple':
159+
self.assertList(prop, 'value')
160+
if prop['scaType'] in ['struct', 'structSeq']:
161+
self.assertProperties(prop['value'])
162+
163+
# SCA Properties can be identified from CORBA ones since the former have 'kinds', among other things.
164+
if 'kinds' in prop:
165+
if prop['scaType'] in ['simple', 'simpleSeq']:
166+
self.assertTrue('type' in prop)
167+
self.assertTrue('mode' in prop)
168+
self.assertTrue(prop['mode'] in MODES)
157169

158170

159171

tests/component.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def test_info(self):
7777
def test_not_found(self):
7878
json, resp = self._json_request('%s/components/ggsdfgfdg' % self.base_url, 404)
7979

80-
self._resource_not_found(json)
81-
8280
def test_properties(self):
8381
comp_id = self.components[0]['id']
8482
json, resp = self._json_request('%s/components/%s' % (self.base_url, comp_id), 200)

tests/defaults.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,20 @@ class Default(object):
2828

2929
WAVEFORM = 'SigTest'
3030

31-
COMPONENT = 'SigGen'
31+
COMPONENT = 'rh.SigGen'
3232
COMPONENT_PROPERTY = 'frequency'
3333
COMPONENT_PROPERTY_VALUE = 1000
3434
COMPONENT_PROPERTY_CHANGE = 2000
35+
COMPONENT_USES_PORT = 'dataShort_out'
3536

3637
RESOURCE_NOT_FOUND_ERR = 'ResourceNotFound'
3738
RESOURCE_NOT_FOUND_MSG_REGEX = re.compile(r"^Unable to find .[^']* '.[^']*'$")
39+
40+
FEI_DEVICE = 'FEI_FileReader'
41+
FEI_ALLOC_ID = 'test_allocation'
42+
FEI_ALLOC_CF = 101700000
43+
FEI_ALLOC_SR = 512000
44+
FEI_ALLOC_BW = None
45+
FEI_ALLOC_TYPE = 'I'
46+
FEI_ALLOC_R = True
47+

tests/device.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,9 @@ def test_info(self):
8181

8282
self.assertTrue('started' in json)
8383
self.assertTrue('properties' in json)
84+
self.assertProperties(json['properties'])
8485
self.assertTrue('ports' in json)
8586

8687
def test_info_not_found(self):
8788
url, devices = self._get_dev_list()
8889
json, resp = self._json_request(url+"/devices/sdkafsdfhklasdfhkajl", 404)
89-
90-
self._resource_not_found(json)

tests/devicemanager.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,4 @@ def test_info(self):
7373
self.assertTrue('devices' in body)
7474

7575
def test_info_not_found(self):
76-
global DOMAIN_NAME
7776
body, resp = self._json_request("/domains/"+Default.DOMAIN_NAME+"/deviceManagers/sdkafsdfhklasdfhkajl", 404)
78-
79-
self._resource_not_found(body)

tests/domain.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,14 @@ def test_info(self):
4040
self.assertTrue('name' in body)
4141
self.assertEquals(body['name'], Default.DOMAIN_NAME)
4242

43-
self.assertTrue('applications' in body)
44-
self.assertTrue('deviceManagers' in body)
45-
self.assertTrue('properties' in body)
4643
self.assertTrue('id' in body)
44+
self.assertTrue('properties' in body)
45+
self.assertProperties(body['properties'])
46+
self.assertIdList(body, 'applications')
47+
self.assertIdList(body, 'deviceManagers')
48+
self.assertList(body, 'eventChannels')
49+
self.assertList(body, 'allocations')
50+
self.assertTrue('fs' in body)
4751

4852
def test_info_not_found(self):
4953
body, resp = self._json_request("/domains/ldskfadjklfsdjkfasdl", 404)
50-
print body
51-
self._resource_not_found(body)

0 commit comments

Comments
 (0)