From aeeba1d69f0498808252d5555b06b8fb6cae9269 Mon Sep 17 00:00:00 2001 From: Ganesh Chandrasekaran Date: Mon, 16 Jul 2018 16:08:08 +0900 Subject: Saltstack sample server config doc Issue-ID: CCSDK-361 Change-Id: I6a5407d7359dd84ea5fb71d5c7fab417abd31c55 Signed-off-by: Ganesh Chandrasekaran --- .../adapter/impl/TestSaltstackAdapterImpl.java | 103 +++++++++++++++++++++ .../src/test/resources/config.sls | 2 + 2 files changed, 105 insertions(+) create mode 100644 saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls (limited to 'saltstack-adapter/saltstack-adapter-provider/src/test') diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java index 0622a4716..48f5c20b8 100644 --- a/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java +++ b/saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java @@ -799,4 +799,107 @@ public class TestSaltstackAdapterImpl { fail(e.getMessage() + " Unknown exception encountered "); } } + + @Test + public void reqExecCommand_shouldSetSuccessReal() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "127.0.0.1"); + params.put("Port", "22"); + params.put("User", "sdn"); + params.put("Password", "foo"); + params.put("Id", "test1"); + params.put("cmd", "ls -l"); + params.put("slsExec", "false"); + params.put("execTimeout", "12000"); + adapter = new SaltstackAdapterImpl(); + try { + adapter.reqExecCommand(params, svcContext); + String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code"); + TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id"); + assertEquals("250", status); + assertEquals(TestId, "test1"); + } catch (Exception e){ + //if local ssh is not enabled + return; + } + } + + @Test + public void reqExecCommand_shouldSetSuccessRealCommand() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", ""); + params.put("Port", "2222"); + params.put("User", "root"); + params.put("Password", "vagrant"); + params.put("Id", "test1"); + params.put("cmd", "cd /srv/salt/; salt '*' state.apply vim --out=json --static"); + params.put("slsExec", "true"); + params.put("execTimeout", "12000"); + + adapter = new SaltstackAdapterImpl(); + try { + adapter.reqExecCommand(params, svcContext); + String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code"); + TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id"); + assertEquals("200", status); + assertEquals(TestId, "test1"); + } catch (Exception e){ + //if saltstack ssh IP is not enabled + return; + } + } + + @Test + public void reqExecCommand_shouldSetSuccessRealSSL() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "10.251.92.17"); + params.put("Port", "2222"); + params.put("User", "root"); + params.put("Password", "vagrant"); + params.put("Id", "test1"); + params.put("slsName", "vim"); + params.put("execTimeout", "12000"); + params.put("applyTo", "minion1"); + + adapter = new SaltstackAdapterImpl(); + try { + adapter.reqExecSLS(params, svcContext); + String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code"); + TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id"); + assertEquals("200", status); + assertEquals(TestId, "test1"); + } catch (Exception e){ + //if saltstack ssh IP is not enabled + return; + } + } + + @Test + public void reqExecCommand_shouldSetSuccessSSLFile() throws SvcLogicException, + IllegalStateException, IllegalArgumentException { + + params.put("HostName", "10.251.92.17"); + params.put("Port", "2222"); + params.put("User", "root"); + params.put("Password", "vagrant"); + params.put("Id", "test1"); + params.put("execTimeout", "12000"); + params.put("applyTo", "minion1"); + params.put("slsFile", "src/test/resources/config.sls"); + + adapter = new SaltstackAdapterImpl(); + try { + adapter.reqExecSLSFile(params, svcContext); + String status = svcContext.getAttribute("org.onap.appc.adapter.saltstack.result.code"); + TestId = svcContext.getAttribute("org.onap.appc.adapter.saltstack.Id"); + assertEquals("200", status); + assertEquals(TestId, "test1"); + } catch (Exception e){ + //if saltstack ssh IP is not enabled + return; + } + } } diff --git a/saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls b/saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls new file mode 100644 index 000000000..aff05939b --- /dev/null +++ b/saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls @@ -0,0 +1,2 @@ +vim: + pkg.installed -- cgit 1.2.3-korg