diff options
author | 2019-02-12 23:05:01 -0500 | |
---|---|---|
committer | 2019-02-16 19:08:17 -0500 | |
commit | c55160eec8cc40405eaa7030c0317e07c5667acc (patch) | |
tree | 122971191665eb89fbcef950e92a8fb4e1dfb66b /ms/blueprintsprocessor/functions/netconf-executor/src/test | |
parent | 739533d36d66d76ce73a438ccacdfd3c5e7e4b1d (diff) |
Rework netconf-executor
- rework connection logic
- rework rpc service
- rework netconf session handling
- rework netconf device communicator
- rework python netconf bindings
- rework python netconf client
- add python script showcasing netconf functions
Change-Id: Ibb9bf811e7d96e993aa866371d56c172de83be2c
Issue-ID: CCSDK-790:x
Signed-off-by: Alexis de Talhouët <adetalhouet89@gmail.com>
Diffstat (limited to 'ms/blueprintsprocessor/functions/netconf-executor/src/test')
4 files changed, 33 insertions, 36 deletions
diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt index d6f737fdd..7b31610c2 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/ComponentNetconfExecutorTest.kt @@ -35,8 +35,7 @@ import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [NetconfExecutorConfiguration::class, BlueprintJythonService::class, - PythonExecutorProperty::class]) +@ContextConfiguration(classes = [BlueprintJythonService::class, PythonExecutorProperty::class, ComponentNetconfExecutor::class, JsonParserService::class]) @TestPropertySource(properties = ["blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_netconf,./../../../../components/scripts/python/ccsdk_blueprints", "blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_netconf"]) @@ -50,10 +49,10 @@ class ComponentNetconfExecutorTest { fun testComponentNetconfExecutor() { val executionServiceInput = JacksonUtils.readValueFromClassPathFile("requests/sample-activate-request.json", - ExecutionServiceInput::class.java)!! + ExecutionServiceInput::class.java)!! val bluePrintRuntimeService = BluePrintMetadataUtils.getBluePrintRuntime("1234", - "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") val executionContext = bluePrintRuntimeService.getExecutionContext() @@ -63,7 +62,7 @@ class ComponentNetconfExecutorTest { val stepMetaData: MutableMap<String, JsonNode> = hashMapOf() stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_NODE_TEMPLATE, "activate-netconf") - stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "NetconfExecutorComponent") + stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_INTERFACE, "ComponentNetconfExecutor") stepMetaData.putJsonElement(BluePrintConstants.PROPERTY_CURRENT_OPERATION, "process") // Set Step Inputs in Blueprint Runtime Service bluePrintRuntimeService.put("activate-netconf-step-inputs", stepMetaData.asJsonNode()) diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt index 4ee48bc82..045725c79 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/NetconfSessionImplTest.kt @@ -18,10 +18,10 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor import org.junit.After import org.junit.Assert import org.junit.Before +import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.api.DeviceInfo +import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfRpcServiceImpl import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.core.NetconfSessionImpl -import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.interfaces.DeviceInfo -import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfDeviceSimulator - +import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.mocks.NetconfDeviceSimulator class NetconfSessionImplTest { @@ -31,11 +31,11 @@ class NetconfSessionImplTest { @Before fun before() { deviceInfo = DeviceInfo().apply { - name = "name" - pass = "password" + username = "username" + password = "password" ipAddress = "localhost" port = 2224 - connectTimeoutSec = 10 + connectTimeout = 10 } device = NetconfDeviceSimulator(deviceInfo!!.port) @@ -49,7 +49,7 @@ class NetconfSessionImplTest { @Throws(Exception::class) fun testNetconfSession() { - val netconfSession = NetconfSessionImpl(deviceInfo!!) + val netconfSession = NetconfSessionImpl(deviceInfo!!, NetconfRpcServiceImpl(DeviceInfo())) Assert.assertNotNull(netconfSession.getSessionId()) Assert.assertEquals("localhost:2224", netconfSession.getDeviceInfo().toString()) diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/mocks/NetconfDeviceSimulator.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/mocks/NetconfDeviceSimulator.kt index 6471df3e6..a2a3946db 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/mocks/NetconfDeviceSimulator.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/mocks/NetconfDeviceSimulator.kt @@ -13,16 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils +package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.mocks import org.apache.sshd.common.NamedFactory import org.apache.sshd.server.Command -import java.util.ArrayList -import org.apache.sshd.server.auth.UserAuthNoneFactory -import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider import org.apache.sshd.server.SshServer import org.apache.sshd.server.auth.UserAuth +import org.apache.sshd.server.auth.UserAuthNoneFactory +import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider +import org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils.NetconfSubsystemFactory +import java.util.* class NetconfDeviceSimulator(private val port: Int) { diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt index 08a2e686a..20b04fb5b 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/netconf/executor/utils/RpcMessageUtilsTest.kt @@ -16,11 +16,9 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.netconf.executor.utils import org.junit.Assert +import org.junit.Assert.assertTrue import org.junit.Test -import org.junit.Assert.* -import org.springframework.beans.factory.annotation.Autowired - class RpcMessageUtilsTest { @Test @@ -34,9 +32,9 @@ class RpcMessageUtilsTest { val configType = "candidate" val filterContent = "Test-Filter-Content" - val result = RpcMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } @@ -53,9 +51,9 @@ class RpcMessageUtilsTest { val configType = "candidate" val filterContent = "Test-Filter-Content" - val result = RpcMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.getConfig(messageId, configType, filterContent).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } @@ -68,9 +66,9 @@ class RpcMessageUtilsTest { val messageId = "Test-Message-ID" val configType = "candidate" - val result = RpcMessageUtils.validate(messageId, configType).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.validate(messageId, configType).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } @@ -81,11 +79,10 @@ class RpcMessageUtilsTest { + "<commit></commit></rpc>") val messageId = "Test-Message-ID" - val message = "Test-Message" - val result = RpcMessageUtils.commit(messageId, message).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.commit(messageId).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } @@ -99,9 +96,9 @@ class RpcMessageUtilsTest { val messageId = "Test-Message-ID" val configType = "candidate" - val result = RpcMessageUtils.unlock(messageId, configType).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.unlock(messageId, configType).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } @@ -114,9 +111,9 @@ class RpcMessageUtilsTest { val messageId = "Test-Message-ID" val netconfTargetConfig = "candidate" - val result = RpcMessageUtils.deleteConfig(messageId, netconfTargetConfig).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.deleteConfig(messageId, netconfTargetConfig).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } @@ -128,9 +125,9 @@ class RpcMessageUtilsTest { val messageId = "Test-Message-ID" - val result = RpcMessageUtils.discardChanges(messageId).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.discardChanges(messageId).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } @@ -142,9 +139,9 @@ class RpcMessageUtilsTest { val messageId = "Test-Message-ID" val configType = "candidate" - val result = RpcMessageUtils.lock(messageId, configType).replace("[\n\r\t]".toRegex(), "") + val result = NetconfMessageUtils.lock(messageId, configType).replace("[\n\r\t]".toRegex(), "") - assertTrue(RpcMessageUtils.validateRPCXML(result)) + assertTrue(NetconfMessageUtils.validateRPCXML(result)) Assert.assertEquals(checkString, result) } |