Skip to content

Commit d26363e

Browse files
author
David Linko
committed
Merge remote-tracking branch 'origin/main' into 38-anms_fun_bld_007-edds-ari-selection-on-build-tab
2 parents 2315ee3 + b85767a commit d26363e

25 files changed

+943
-50
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ ION_MGR_PORT=8089
5353
HTTP_PORT:80
5454
SOCKDIR=/var/tmp/nm
5555

56-
ADM_PATH=deps/dtnma-ace/tests/adms
56+
ADM_PATH=deps/dtnma-adms

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
[submodule "deps/dtnma-camp"]
1010
path = deps/dtnma-camp
1111
url = https://github.com/JHUAPL-DTNMA/dtnma-camp.git
12+
[submodule "deps/dtnma-adms"]
13+
path = deps/dtnma-adms
14+
url = https://github.com/JHUAPL-DTNMA/dtnma-adms.git

anms-core/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ COPY anms ${APP_WORK_DIR}/anms
3939
RUN ${PIP} install ${APP_WORK_DIR}
4040

4141
RUN mkdir -p /usr/local/share/ace && \
42-
cp -R /usr/src/dtnma-ace/tests/adms /usr/local/share/ace/adms
42+
cp -R /usr/src/dtnma-adms /usr/local/share/ace/adms
4343
COPY anms/agent_parameter.json /usr/local/share/anms/agent_parameter.json
4444

4545
RUN setcap cap_net_raw=ep /usr/bin/ping

anms-core/anms/routes/ARIs/reports.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,10 @@ async def report_def_by_id(agent_id: str):
8181
if(res):
8282
ari_val = await transcoder.transcoder_put_cbor_await("ari:0x"+res.entries.hex())
8383
ari_val = ari_val['data']
84-
85-
86-
addition = {'exec_set': ari_val,'correlator_nonce':correlator_nonce}
87-
84+
addition = {'exec_set': ari_val,'correlator_nonce':correlator_nonce}
8885
if addition not in final_res:
8986
final_res.append(addition)
87+
9088
return final_res
9189

9290

anms-core/anms/routes/adms/adm_compare.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ def compare_adms(self, old_adm: ace.models.AdmModule, new_adm: ace.models.AdmMod
4949
['const', ace.models.Const, self.compare_const],
5050
['ctrl', ace.models.Ctrl, self.compare_ctrl],
5151
['edd', ace.models.Edd, self.compare_edd],
52-
['mac', ace.models.Mac, self.compare_mac],
5352
['oper', ace.models.Oper, self.compare_oper],
54-
['rptt', ace.models.Rptt, self.compare_rptt],
55-
['tblt', ace.models.Tblt, self.compare_tblt],
5653
['var', ace.models.Var, self.compare_var],
5754
]
5855

@@ -105,32 +102,21 @@ def _compare_tnl(self, old_obj, new_obj, attrname):
105102

106103
def compare_const(self, old_obj, new_obj):
107104
self._compare_attr(old_obj, new_obj, 'enum')
108-
self._compare_attr(old_obj, new_obj, 'type')
105+
self._compare_attr(old_obj, new_obj, 'typeobj')
109106

110107
def compare_ctrl(self, old_obj, new_obj):
111108
self._compare_attr(old_obj, new_obj, 'enum')
112109

113110
def compare_edd(self, old_obj, new_obj):
114111
self._compare_attr(old_obj, new_obj, 'enum')
115-
self._compare_attr(old_obj, new_obj, 'type')
112+
self._compare_attr(old_obj, new_obj, 'typeobj')
116113

117-
def compare_mac(self, old_obj, new_obj):
118-
self._compare_attr(old_obj, new_obj, 'enum')
119-
# The action doesn't affect the manager
120114

121115
def compare_oper(self, old_obj, new_obj):
122116
self._compare_attr(old_obj, new_obj, 'enum')
123117
# The result_type and in_type don't affect the manager
124118

125-
def compare_rptt(self, old_obj, new_obj):
126-
self._compare_attr(old_obj, new_obj, 'enum')
127-
self._compare_ac(old_obj, new_obj, 'definition')
128-
129-
def compare_tblt(self, old_obj, new_obj):
130-
self._compare_attr(old_obj, new_obj, 'enum')
131-
self._compare_tnl(old_obj, new_obj, 'columns')
132-
133119
def compare_var(self, old_obj, new_obj):
134120
self._compare_attr(old_obj, new_obj, 'enum')
135-
self._compare_attr(old_obj, new_obj, 'type')
121+
self._compare_attr(old_obj, new_obj, 'typeobj')
136122
# The initializer doesn't affect the manager

anms-core/anms/routes/network_manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ async def nm_register_agent(addr: Data):
7373
url = nm_url + "/agents"
7474
logger.info('POST to nm manager %s with addr %s' % (url, addr.data))
7575
try:
76-
request = requests.post(url=url, data=addr.data, headers={'Content-Type: text/plain'} )
77-
except Exception:
76+
request = requests.post(url=url, data=addr.data, headers={'Content-Type': 'text/plain'} )
77+
except Exception as e:
78+
logger.info(e)
7879
return status.HTTP_500_INTERNAL_SERVER_ERROR
80+
7981
return request.status_code
8082

8183

anms-core/pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ dependencies = [
3131
"email-validator ~=1.3",
3232
"fastapi ~=0.86.0",
3333
"fastapi-pagination ~=0.9.1",
34-
"grpcio ~=1.50.0",
35-
"grpcio-tools ~=1.50.0",
3634
"gunicorn ~=23.0.0",
3735
"httpx ~=0.24.0",
3836
"itsdangerous ~=2.1.2",

anms-core/test/anms/routes/adms/test_adm.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
from anms.shared.config_utils import ConfigBuilder
3333
from anms.shared.opensearch_logger import OpenSearchLogger
3434
from unittest.mock import (patch, MagicMock, AsyncMock, PropertyMock)
35-
from anms.components.schemas.adm import NamespaceViewSchema
35+
from anms.components.schemas.adm import DataModelSchema
3636

3737
from fastapi import File, UploadFile, Request
3838

@@ -57,18 +57,19 @@ def __init__(self):
5757

5858
class TestAdm:
5959
@pytest.mark.anyio
60-
@patch('anms.routes.adms.adm.NamespaceView', new_callable=AsyncMock)
61-
async def test_getall(self, mock_namespace_view):
60+
@patch('anms.routes.adms.adm.DataModel', new_callable=AsyncMock)
61+
async def test_getall(self, mock_datamodel_view):
6262
'''
6363
This only test the flow of the getall function.
6464
The actual execution is not tested due to no access to database
6565
'''
66+
6667
#This mock the getall method of Adm that is used inside the getall function
6768
mock_result = [
68-
NamespaceViewSchema(enumeration=1, data_model_name="amp",
69-
name_string="amp/agent", version_name="v3.1", use_des="view result")
69+
DataModelSchema(data_model_id=0, enumeration=1, name="dtnma-agent",
70+
version_name="v3.1", namespace_type='adm', use_des="Updated for latest ADM document.")
7071
]
71-
mock_namespace_view.getall.return_value = mock_result
72+
mock_datamodel_view.getall.return_value = mock_result
7273
res = await getall()
7374
'''
7475
Ideally, the res is a JSONResponse object. Yet, fastapi
@@ -78,7 +79,7 @@ async def test_getall(self, mock_namespace_view):
7879
assert res == mock_result
7980

8081
@pytest.mark.anyio
81-
@patch('anms.routes.adms.adm.NamespaceView', new_callable=AsyncMock)
82+
@patch('anms.routes.adms.adm.DataModel', new_callable=AsyncMock)
8283
async def test_getall_empty(self, mock_adm):
8384
'''
8485
This test the result when there is no data or the function is failed

anms-core/test/anms/routes/adms/test_adm_compare.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ def _load_adm(self, filename):
5252

5353
def test_equal(self):
5454
comp = AdmCompare(self._admset)
55-
adm1 = self._load_adm('test_adm_reference.json')
56-
adm2 = self._load_adm('test_adm_reference.json')
55+
self._load_adm('ietf-amm.yang')
56+
adm1 = self._load_adm('example-adm-minimal.yang')
57+
adm2 = self._load_adm('example-adm-minimal.yang')
5758
assert comp.compare_adms(adm1, adm2)
5859
assert [] == comp.get_errors()
5960

@@ -66,15 +67,17 @@ def compare_error(self, errorA, errorB):
6667

6768
def test_different(self):
6869
comp = AdmCompare(self._admset)
69-
adm1 = self._load_adm('test_adm_reference.json')
70-
adm2 = self._load_adm('test_adm_modified.json')
70+
self._load_adm('ietf-amm.yang')
71+
adm1 = self._load_adm('example-adm-minimal.yang')
72+
adm2 = self._load_adm('example-adm-minimal-modified.yang')
7173
assert not comp.compare_adms(adm1, adm2)
7274
expect_errors = [
7375
{'obj_type': 'Edd',
7476
'name': 'edd1',
75-
'issue':'changed type value from INT to REAL32'
77+
'issue': "changed typeobj value from TypeUse(type_text='/ARITYPE/int', type_ari=LiteralARI(value=<StructType.INT: 4>, type_id=<StructType.ARITYPE: 16>), base=None, units=None, constraints=[]) to TypeUse(type_text='/ARITYPE/real32', type_ari=LiteralARI(value=<StructType.REAL32: 8>, type_id=<StructType.ARITYPE: 16>), base=None, units=None, constraints=[])"
7678
}
7779
]
80+
7881
for actual_error in comp.get_errors():
7982
has_equivalent_error = False
8083
for expect_error in expect_errors:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module example-adm-minimal {
2+
namespace "ari://example/adm-minimal/";
3+
prefix test;
4+
5+
import ietf-amm {
6+
prefix amm;
7+
}
8+
9+
organization "example" {
10+
amm:enum 65535;
11+
}
12+
revision 2023-10-31 {
13+
description
14+
"Initial test";
15+
}
16+
amm:enum 0;
17+
18+
amm:edd edd1 {
19+
amm:enum 1;
20+
description
21+
"EDD test_int";
22+
amm:type /ARITYPE/real32;
23+
}
24+
amm:ctrl test1 {
25+
amm:enum 1;
26+
description
27+
"This control resets all Agent ADM statistics reported in the Agent ADM report.";
28+
amm:parameter id {
29+
description "one";
30+
amm:type "//ietf/amm/TYPEDEF/any";
31+
}
32+
amm:parameter def {
33+
description "two";
34+
amm:type "//ietf/amm/TYPEDEF/expr";
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)