mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-21 16:39:08 -07:00
add timeout parameter and increase default timeout for nso modules (#37391)
NSO operations can take much longer than 10 seconds as they operate on real network equipment, set default timeout to 5 minutes and allow for user override.
This commit is contained in:
parent
e166946a0a
commit
458a07d5a4
4 changed files with 22 additions and 15 deletions
|
@ -331,7 +331,7 @@ class MockResponse(object):
|
|||
return self.body
|
||||
|
||||
|
||||
def mock_call(calls, url, data=None, headers=None, method=None):
|
||||
def mock_call(calls, url, timeout, data=None, headers=None, method=None):
|
||||
result = calls[0]
|
||||
del calls[0]
|
||||
|
||||
|
@ -366,7 +366,7 @@ class TestJsonRpc(unittest.TestCase):
|
|||
MockResponse('exists', {'path': '/not-exists'}, 200, '{"result": {"exists": false}}')
|
||||
]
|
||||
open_url_mock.side_effect = lambda *args, **kwargs: mock_call(calls, *args, **kwargs)
|
||||
client = nso.JsonRpc('http://localhost:8080/jsonrpc')
|
||||
client = nso.JsonRpc('http://localhost:8080/jsonrpc', 10)
|
||||
self.assertEquals(True, client.exists('/exists'))
|
||||
self.assertEquals(False, client.exists('/not-exists'))
|
||||
|
||||
|
@ -379,7 +379,7 @@ class TestJsonRpc(unittest.TestCase):
|
|||
MockResponse('exists', {'path': '/list{missing-parent}/list{child}'}, 200, '{"error":{"type":"data.not_found"}}')
|
||||
]
|
||||
open_url_mock.side_effect = lambda *args, **kwargs: mock_call(calls, *args, **kwargs)
|
||||
client = nso.JsonRpc('http://localhost:8080/jsonrpc')
|
||||
client = nso.JsonRpc('http://localhost:8080/jsonrpc', 10)
|
||||
self.assertEquals(False, client.exists('/list{missing-parent}/list{child}'))
|
||||
|
||||
self.assertEqual(0, len(calls))
|
||||
|
@ -400,7 +400,7 @@ class TestValueBuilder(unittest.TestCase):
|
|||
SCHEMA_DATA['/an:id-name-leaf'])
|
||||
schema = schema_data['data']
|
||||
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc'))
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10))
|
||||
vb.build(parent, None, 'ansible-nso:id-two', schema)
|
||||
self.assertEquals(1, len(vb.values))
|
||||
value = vb.values[0]
|
||||
|
@ -425,7 +425,7 @@ class TestValueBuilder(unittest.TestCase):
|
|||
SCHEMA_DATA['/an:id-name-values/id-name-value'])
|
||||
schema = schema_data['data']
|
||||
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc'))
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10))
|
||||
vb.build(parent, 'id-name-value', [{'name': 'ansible-nso:id-one', 'value': '1'}], schema)
|
||||
self.assertEquals(1, len(vb.values))
|
||||
value = vb.values[0]
|
||||
|
@ -450,7 +450,7 @@ class TestValueBuilder(unittest.TestCase):
|
|||
SCHEMA_DATA['/test:test'])
|
||||
schema = schema_data['data']
|
||||
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc'))
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10))
|
||||
vb.build(parent, None, [{'name': 'direct', 'direct-child': 'direct-value'},
|
||||
{'name': 'nested', 'nested-child': 'nested-value'}], schema)
|
||||
self.assertEquals(2, len(vb.values))
|
||||
|
@ -480,7 +480,7 @@ class TestValueBuilder(unittest.TestCase):
|
|||
SCHEMA_DATA['/test:test'])
|
||||
schema = schema_data['data']
|
||||
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc'))
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10))
|
||||
vb.build(parent, None, {'device-list': ['one', 'two']}, schema)
|
||||
self.assertEquals(1, len(vb.values))
|
||||
value = vb.values[0]
|
||||
|
@ -503,7 +503,7 @@ class TestValueBuilder(unittest.TestCase):
|
|||
SCHEMA_DATA['/test:test'])
|
||||
schema = schema_data['data']
|
||||
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc'))
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10))
|
||||
vb.build(parent, None, {'device-list': ['one', 'two']}, schema)
|
||||
self.assertEquals(3, len(vb.values))
|
||||
value = vb.values[0]
|
||||
|
@ -537,7 +537,7 @@ class TestValueBuilder(unittest.TestCase):
|
|||
'c': '3',
|
||||
}
|
||||
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc'))
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10))
|
||||
vb.build(parent, None, values, schema)
|
||||
self.assertEquals(3, len(vb.values))
|
||||
value = vb.values[0]
|
||||
|
@ -570,7 +570,7 @@ class TestValueBuilder(unittest.TestCase):
|
|||
'b': '2'
|
||||
}
|
||||
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc'))
|
||||
vb = nso.ValueBuilder(nso.JsonRpc('http://localhost:8080/jsonrpc', 10))
|
||||
vb.build(parent, None, values, schema)
|
||||
self.assertEquals(2, len(vb.values))
|
||||
value = vb.values[0]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue