summaryrefslogtreecommitdiffstats
path: root/saltstack-adapter/saltstack-adapter-provider/src/test
diff options
context:
space:
mode:
authorGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-16 16:08:08 +0900
committerGanesh Chandrasekaran <ganesh.c@samsung.com>2018-07-16 16:24:56 +0900
commitaeeba1d69f0498808252d5555b06b8fb6cae9269 (patch)
treee2fedca5c0231237d6d5c853b8e9aa81dde5d313 /saltstack-adapter/saltstack-adapter-provider/src/test
parent3323c0829fa0492a5c7b3544a83cc24412c9934c (diff)
Saltstack sample server config doc
Issue-ID: CCSDK-361 Change-Id: I6a5407d7359dd84ea5fb71d5c7fab417abd31c55 Signed-off-by: Ganesh Chandrasekaran <ganesh.c@samsung.com>
Diffstat (limited to 'saltstack-adapter/saltstack-adapter-provider/src/test')
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/java/org/onap/ccsdk/adapter/impl/TestSaltstackAdapterImpl.java103
-rw-r--r--saltstack-adapter/saltstack-adapter-provider/src/test/resources/config.sls2
2 files changed, 105 insertions, 0 deletions
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", "<IP>");
+ 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