From 68db80d9f386dcc41033ee11b13090e06ec175aa Mon Sep 17 00:00:00 2001 From: jkehrli Date: Sat, 9 May 2020 00:28:52 +0200 Subject: [PATCH] Moving forward with setup shell tests --- .../gluster/inContainerSetupGluster.sh | 5 +- services_setup/gluster/setup.sh | 53 +++++----- services_setup/grafana/setup.sh | 22 ++--- services_setup/ntp/inContainerSetupNtp.sh | 6 +- services_setup/ntp/setup.sh | 20 ++-- .../shell/setup/AbstractSetupShellTest.java | 7 +- .../eskimo/shell/setup/GlusterSetupTest.java | 96 +++++++++++++++++++ .../eskimo/shell/setup/GrafanaSetupTest.java | 89 +++++++++++++++++ .../eskimo/shell/setup/NtpSetupTest.java | 92 ++++++++++++++++++ .../GrafanaSetupShellTest/testFile.conf | 17 ++++ .../testFile.conf.result | 16 ++++ .../resources/NtpSetupShellTest/testFile.conf | 8 ++ .../NtpSetupShellTest/testFile.conf.result | 5 + 13 files changed, 383 insertions(+), 53 deletions(-) create mode 100644 src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GlusterSetupTest.java create mode 100644 src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GrafanaSetupTest.java create mode 100644 src/test/javashelltests/ch/niceideas/eskimo/shell/setup/NtpSetupTest.java create mode 100644 src/test/resources/GrafanaSetupShellTest/testFile.conf create mode 100644 src/test/resources/GrafanaSetupShellTest/testFile.conf.result create mode 100644 src/test/resources/NtpSetupShellTest/testFile.conf create mode 100644 src/test/resources/NtpSetupShellTest/testFile.conf.result diff --git a/services_setup/gluster/inContainerSetupGluster.sh b/services_setup/gluster/inContainerSetupGluster.sh index 5ae21d86..cc491e4b 100644 --- a/services_setup/gluster/inContainerSetupGluster.sh +++ b/services_setup/gluster/inContainerSetupGluster.sh @@ -36,9 +36,10 @@ set -e -SELF_IP_ADDRESS=$1 +. /etc/eskimo_topology.sh + if [[ $SELF_IP_ADDRESS == "" ]]; then - echo " - No self ip address passed in argument" + echo " - Didn't find Self IP Address in eskimo_topology.sh" exit -2 fi diff --git a/services_setup/gluster/setup.sh b/services_setup/gluster/setup.sh index 2f0e6328..47f84a31 100755 --- a/services_setup/gluster/setup.sh +++ b/services_setup/gluster/setup.sh @@ -57,7 +57,7 @@ if [[ $SELF_IP_ADDRESS == "" ]]; then fi # reinitializing log -sudo rm -f /tmp/gluster_install_log +sudo rm -f gluster_install_log echo " - Creating required folders" @@ -73,7 +73,7 @@ sudo mkdir -p /var/lib/gluster echo " - Building container gluster" -build_container gluster gluster /tmp/gluster_install_log +build_container gluster gluster gluster_install_log # create and start container echo " - Running docker container" @@ -82,13 +82,14 @@ docker run \ -v $PWD/../common:/common \ --network host \ --privileged=true \ - -v /var/lib/gluster:/var/lib/gluster\ - -v /var/log/gluster:/var/log/gluster\ - -v /var/run/gluster:/var/run/gluster\ + -v /var/lib/gluster:/var/lib/gluster \ + -v /var/log/gluster:/var/log/gluster \ + -v /var/run/gluster:/var/run/gluster \ + --mount type=bind,source=/etc/eskimo_topology.sh,target=/etc/eskimo_topology.sh \ -d --name gluster \ -i \ - -t eskimo:gluster bash >> /tmp/gluster_install_log 2>&1 -fail_if_error $? "/tmp/gluster_install_log" -2 + -t eskimo:gluster bash >> gluster_install_log 2>&1 +fail_if_error $? "gluster_install_log" -2 # connect to container #docker exec -it gluster bash @@ -97,9 +98,9 @@ echo " - Gluster Remote Server Scripts" for i in `find ./command_server`; do if [[ -f $SCRIPT_DIR/$i ]]; then filename=`basename $i` - docker cp $SCRIPT_DIR/$i gluster:/usr/local/sbin/$filename >> /tmp/gluster_install_log 2>&1 - docker exec gluster chmod 755 /usr/local/sbin/$filename >> /tmp/gluster_install_log 2>&1 - fail_if_error $? /tmp/gluster_install_log -30 + docker cp $SCRIPT_DIR/$i gluster:/usr/local/sbin/$filename >> gluster_install_log 2>&1 + docker exec gluster chmod 755 /usr/local/sbin/$filename >> gluster_install_log 2>&1 + fail_if_error $? gluster_install_log -30 fi done @@ -107,17 +108,17 @@ echo " - Gluster in container helpers" for i in `find ./gluster_container_helpers`; do if [[ -f $SCRIPT_DIR/$i ]]; then filename=`basename $i` - docker cp $SCRIPT_DIR/$i gluster:/usr/local/sbin/$filename >> /tmp/gluster_install_log 2>&1 - docker exec gluster chmod 755 /usr/local/sbin/$filename >> /tmp/gluster_install_log 2>&1 - fail_if_error $? /tmp/gluster_install_log -30 + docker cp $SCRIPT_DIR/$i gluster:/usr/local/sbin/$filename >> gluster_install_log 2>&1 + docker exec gluster chmod 755 /usr/local/sbin/$filename >> gluster_install_log 2>&1 + fail_if_error $? gluster_install_log -30 fi done echo " - Configuring gluster container" -docker exec gluster bash /scripts/inContainerSetupGluster.sh $SELF_IP_ADDRESS | tee -a /tmp/gluster_install_log 2>&1 -if [[ `tail -n 1 /tmp/gluster_install_log` != " - In container config SUCCESS" ]]; then +docker exec gluster bash /scripts/inContainerSetupGluster.sh | tee -a gluster_install_log 2>&1 +if [[ `tail -n 1 gluster_install_log` != " - In container config SUCCESS" ]]; then echo " - In container setup script ended up in error" - cat /tmp/gluster_install_log + cat gluster_install_log exit -100 fi @@ -125,23 +126,23 @@ fi #docker exec -it gluster TODO echo " - Copying Service Start Script" -docker cp $SCRIPT_DIR/inContainerStartService.sh gluster:/usr/local/sbin/inContainerStartService.sh >> /tmp/gluster_install_log 2>&1 -fail_if_error $? /tmp/gluster_install_log -20 +docker cp $SCRIPT_DIR/inContainerStartService.sh gluster:/usr/local/sbin/inContainerStartService.sh >> gluster_install_log 2>&1 +fail_if_error $? gluster_install_log -20 -docker exec --user root gluster bash -c "chmod 755 /usr/local/sbin/inContainerStartService.sh" >> /tmp/gluster_install_log 2>&1 -fail_if_error $? /tmp/gluster_install_log -21 +docker exec --user root gluster bash -c "chmod 755 /usr/local/sbin/inContainerStartService.sh" >> gluster_install_log 2>&1 +fail_if_error $? gluster_install_log -21 echo " - Copying settingsInjector.sh Script" -docker cp $SCRIPT_DIR/settingsInjector.sh gluster:/usr/local/sbin/settingsInjector.sh >> /tmp/gluster_install_log 2>&1 -fail_if_error $? /tmp/gluster_install_log -23 +docker cp $SCRIPT_DIR/settingsInjector.sh gluster:/usr/local/sbin/settingsInjector.sh >> gluster_install_log 2>&1 +fail_if_error $? gluster_install_log -23 -docker exec --user root gluster bash -c "chmod 755 /usr/local/sbin/settingsInjector.sh" >> /tmp/gluster_install_log 2>&1 -fail_if_error $? /tmp/gluster_install_log -24 +docker exec --user root gluster bash -c "chmod 755 /usr/local/sbin/settingsInjector.sh" >> gluster_install_log 2>&1 +fail_if_error $? gluster_install_log -24 echo " - Committing changes to local template and exiting container gluster" -commit_container gluster /tmp/gluster_install_log +commit_container gluster gluster_install_log echo " - Copying gluster command line programs docker wrappers to /usr/local/bin" @@ -158,7 +159,7 @@ sudo chmod 755 /usr/local/sbin/startGlusterServiceContainer.sh #echo " - Installing and checking systemd service file" -install_and_check_service_file gluster /tmp/gluster_install_log +install_and_check_service_file gluster gluster_install_log diff --git a/services_setup/grafana/setup.sh b/services_setup/grafana/setup.sh index 699b34cb..d54a025a 100755 --- a/services_setup/grafana/setup.sh +++ b/services_setup/grafana/setup.sh @@ -47,13 +47,13 @@ loadTopology # reinitializing log -sudo rm -f /tmp/grafana_install_log +sudo rm -f grafana_install_log echo " - Building container grafana" -build_container grafana grafana /tmp/grafana_install_log +build_container grafana grafana grafana_install_log echo " - Creating grafana user (if not exist)" -grafana_user_id=`id -u grafana 2>> /tmp/grafana_install_log` +grafana_user_id=`id -u grafana 2>> grafana_install_log` if [[ $grafana_user_id == "" ]]; then echo "User grafana should have been added by eskimo-base-system setup script" exit -4 @@ -69,17 +69,17 @@ docker run \ -v $SCRIPT_DIR/provisioning:/eskimo/provisioning \ -d --name grafana \ -i \ - -t eskimo:grafana bash >> /tmp/grafana_install_log 2>&1 -fail_if_error $? "/tmp/grafana_install_log" -2 + -t eskimo:grafana bash >> grafana_install_log 2>&1 +fail_if_error $? "grafana_install_log" -2 # connect to container #docker exec -it grafana bash echo " - Configuring grafana container" -docker exec grafana bash /scripts/inContainerSetupGrafana.sh $grafana_user_id $CONTEXT_PATH | tee -a /tmp/grafana_install_log 2>&1 -if [[ `tail -n 1 /tmp/grafana_install_log` != " - In container config SUCCESS" ]]; then +docker exec grafana bash /scripts/inContainerSetupGrafana.sh $grafana_user_id $CONTEXT_PATH | tee -a grafana_install_log 2>&1 +if [[ `tail -n 1 grafana_install_log` != " - In container config SUCCESS" ]]; then echo " - In container setup script ended up in error" - cat /tmp/grafana_install_log + cat grafana_install_log exit -100 fi @@ -87,12 +87,12 @@ fi #docker exec -it grafana TODO echo " - Handling topology and setting injection" -handle_topology_settings grafana /tmp/grafana_install_log +handle_topology_settings grafana grafana_install_log echo " - Committing changes to local template and exiting container grafana" -commit_container grafana /tmp/grafana_install_log +commit_container grafana grafana_install_log echo " - Starting marathon deployment" -deploy_marathon grafana /tmp/grafana_install_log +deploy_marathon grafana grafana_install_log diff --git a/services_setup/ntp/inContainerSetupNtp.sh b/services_setup/ntp/inContainerSetupNtp.sh index d81424de..6cab8855 100644 --- a/services_setup/ntp/inContainerSetupNtp.sh +++ b/services_setup/ntp/inContainerSetupNtp.sh @@ -51,11 +51,11 @@ sudo update-rc.d rsync remove echo " - Enabling and starting cron" sudo update-rc.d cron enable -/etc/init.d/cron start >> /tmp/ntp-setup-log +sudo bash -c "/etc/init.d/cron start >> /tmp/ntp-setup-log" echo " - Configuring logging" -echo -e "\nlogfile /var/log/ntp/ntp.log" >> /etc/ntp.conf -echo -e "logconfig =syncevents +peerevents +sysevents +allclock" >> /etc/ntp.conf +bash -c "echo -e \"\nlogfile /var/log/ntp/ntp.log\" >> /etc/ntp.conf" +bash -c "echo -e \"logconfig =syncevents +peerevents +sysevents +allclock\" >> /etc/ntp.conf" echo " - Making sure ntp has access to /var/lib/ntp" touch /var/lib/ntp/ntp.drift.TEMP diff --git a/services_setup/ntp/setup.sh b/services_setup/ntp/setup.sh index a9b3f6cc..7281d490 100755 --- a/services_setup/ntp/setup.sh +++ b/services_setup/ntp/setup.sh @@ -47,10 +47,10 @@ loadTopology # reinitializing log -sudo rm -f /tmp/ntp_install_log +sudo rm -f ntp_install_log echo " - Building container ntp" -build_container ntp ntp /tmp/ntp_install_log +build_container ntp ntp ntp_install_log echo " - Creating shared lib" sudo mkdir -p /var/lib/ntp/ @@ -72,17 +72,17 @@ docker run \ --cap-add SYS_TIME\ -d --name ntp \ -i \ - -t eskimo:ntp bash >> /tmp/ntp_install_log 2>&1 -fail_if_error $? "/tmp/ntp_install_log" -2 + -t eskimo:ntp bash >> ntp_install_log 2>&1 +fail_if_error $? "ntp_install_log" -2 # connect to container #docker exec -it ntp bash echo " - Configuring ntp container" -docker exec ntp bash /scripts/inContainerSetupNtp.sh | tee -a /tmp/ntp_install_log 2>&1 -if [[ `tail -n 1 /tmp/ntp_install_log` != " - In container config SUCCESS" ]]; then +docker exec ntp bash /scripts/inContainerSetupNtp.sh | tee -a ntp_install_log 2>&1 +if [[ `tail -n 1 ntp_install_log` != " - In container config SUCCESS" ]]; then echo " - In container setup script ended up in error" - cat /tmp/ntp_install_log + cat ntp_install_log exit -100 fi @@ -90,10 +90,10 @@ fi #docker exec -it ntp TODO echo " - Handling topology and setting injection" -handle_topology_settings ntp /tmp/ntp_install_log +handle_topology_settings ntp ntp_install_log echo " - Committing changes to local template and exiting container ntp" -commit_container ntp /tmp/ntp_install_log +commit_container ntp ntp_install_log echo " - Installing and checking systemd service file" -install_and_check_service_file ntp /tmp/ntp_install_log +install_and_check_service_file ntp ntp_install_log diff --git a/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/AbstractSetupShellTest.java b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/AbstractSetupShellTest.java index f525c469..688fed8a 100644 --- a/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/AbstractSetupShellTest.java +++ b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/AbstractSetupShellTest.java @@ -82,7 +82,7 @@ protected final String setupJail(String serviceName) throws Exception { private void enhanceScripts(String jailPath) throws FileException { - for (String scriptToExecute: getScriptsToExecute()) { + for (String scriptToExecute: getScriptsToEnhance()) { String scriptContent = FileUtils.readFile(new File(jailPath + "/" + scriptToExecute)); if (StringUtils.isNotBlank(scriptContent)) { @@ -276,6 +276,10 @@ protected String getTemplateName() { protected abstract String[] getScriptsToExecute(); + protected String[] getScriptsToEnhance() { + return getScriptsToExecute(); + } + protected final String executeScripts(String jailPath) throws ProcessHelper.ProcessHelperException { StringBuilder resultBuilder = new StringBuilder(); for (String scriptToExecute: getScriptsToExecute()) { @@ -306,6 +310,7 @@ String createJail() throws Exception { createLoggingExecutable("bash", tempFile.getAbsolutePath()); createLoggingExecutable("systemctl", tempFile.getAbsolutePath()); createLoggingExecutable("echo", tempFile.getAbsolutePath()); + createLoggingExecutable("touch", tempFile.getAbsolutePath()); createDummyExecutable("id", tempFile.getAbsolutePath()); createDummyExecutable("docker", tempFile.getAbsolutePath()); diff --git a/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GlusterSetupTest.java b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GlusterSetupTest.java new file mode 100644 index 00000000..82eeaf4f --- /dev/null +++ b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GlusterSetupTest.java @@ -0,0 +1,96 @@ +package ch.niceideas.eskimo.shell.setup; + +import ch.niceideas.common.utils.ResourceUtils; +import ch.niceideas.common.utils.StreamUtils; +import ch.niceideas.common.utils.StringUtils; +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +public class GlusterSetupTest extends AbstractSetupShellTest { + + private static final Logger logger = Logger.getLogger(GlusterSetupTest.class); + + protected static String jailPath = null; + + private static boolean initialized = false; + + @Before + public void setUp() throws Exception { + if (!initialized) { + jailPath = setupJail(getServiceName()); + initialized = true; + } + } + + @Override + protected String getJailPath() { + return jailPath; + } + + @Override + protected String getServiceName() { + return "gluster"; + } + + @Override + protected void copyScripts(String jailPath) throws IOException { + // setup.sh is automatic + copyFile(jailPath, "common.sh"); + copyFile(jailPath, "inContainerSetupGluster.sh"); + copyFile(jailPath, "inContainerStartService.sh"); + } + + @Override + protected String[] getScriptsToExecute() { + return new String[] { + "setup.sh", + "inContainerSetupGluster.sh" + }; + } + + @Test + public void testSystemDInstallation() throws Exception { + assertSystemDInstallation(); + } + + @Test + public void testSystemDockerManipulations() throws Exception { + assertSystemDServiceDockerCommands(); + } + + @Test + public void testConfigurationFileUpdate() throws Exception { + + String sudoLogs = StreamUtils.getAsString(ResourceUtils.getResourceAsStream(jailPath + "/.log_sudo")); + if (StringUtils.isNotBlank(sudoLogs)) { + + //System.err.println (sudoLogs); + + assertTrue(sudoLogs.contains("" + + "bash -c echo \"volume management\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" type mgmt/glusterd\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option working-directory /var/lib/gluster/working_directory\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option transport-type socket,rdma\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option transport.socket.keepalive-time 10\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option transport.socket.keepalive-interval 2\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option transport.socket.read-fail-log off\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option ping-timeout 0\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option event-threads 1\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option transport.rdma.bind-address 192.168.10.11\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option transport.socket.bind-address 192.168.10.11\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \" option transport.tcp.bind-address 192.168.10.11\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \"# option transport.address-family inet6\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \"# option base-port 49152\" >> /var/lib/gluster/glusterfs.VOLUME_FILE\n" + + "bash -c echo \"end-volume\" >> /var/lib/gluster/glusterfs.VOLUME_FILE")); + + } else { + fail ("Expected to find bash logs in .log_bash"); + } + } +} diff --git a/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GrafanaSetupTest.java b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GrafanaSetupTest.java new file mode 100644 index 00000000..9bba8bd9 --- /dev/null +++ b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/GrafanaSetupTest.java @@ -0,0 +1,89 @@ +package ch.niceideas.eskimo.shell.setup; + +import ch.niceideas.common.utils.FileException; +import ch.niceideas.common.utils.FileUtils; +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; + +import java.io.File; +import java.io.IOException; + +public class GrafanaSetupTest extends AbstractSetupShellTest { + + private static final Logger logger = Logger.getLogger(GrafanaSetupTest.class); + + protected static String jailPath = null; + + private static boolean initialized = false; + + @Before + public void setUp() throws Exception { + if (!initialized) { + jailPath = setupJail(getServiceName()); + initialized = true; + } + } + + @Override + protected String getJailPath() { + return jailPath; + } + + @Override + protected String getServiceName() { + return "grafana"; + } + + @Override + protected void copyScripts(String jailPath) throws IOException { + // setup.sh is automatic + copyFile(jailPath, "common.sh"); + copyFile(jailPath, "inContainerSetupGrafana.sh"); + copyFile(jailPath, "inContainerInjectTopology.sh"); + + // create a wrapper passing arguments to inContainerSetupGrafana.sh + try { + FileUtils.writeFile(new File(jailPath + "/inContainerSetupGrafanaWrapper.sh"), "" + + "#!/bin/bash\n" + + "\n" + + "/bin/bash " + jailPath + "/inContainerSetupGrafana.sh 3304\n"); + } catch (FileException e) { + throw new IOException(e); + } + } + + @Override + protected String[] getScriptsToExecute() { + return new String[] { + "setup.sh", + "inContainerSetupGrafanaWrapper.sh", + "inContainerInjectTopology.sh" + }; + } + + @Override + protected String[] getScriptsToEnhance() { + return new String[] { + "setup.sh", + "inContainerSetupGrafana.sh", + "inContainerInjectTopology.sh" + }; + } + + @Test + public void testMarathonInstallation() throws Exception { + assertMarathonCommands(); + } + + @Test + public void testSystemDockerManipulations() throws Exception { + assertMarathonServiceDockerCommands(); + + } + + @Test + public void testConfigurationFileUpdate() throws Exception { + assertTestConfFileUpdate(); + } +} diff --git a/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/NtpSetupTest.java b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/NtpSetupTest.java new file mode 100644 index 00000000..4e1fdf3d --- /dev/null +++ b/src/test/javashelltests/ch/niceideas/eskimo/shell/setup/NtpSetupTest.java @@ -0,0 +1,92 @@ +package ch.niceideas.eskimo.shell.setup; + +import ch.niceideas.common.utils.ResourceUtils; +import ch.niceideas.common.utils.StreamUtils; +import ch.niceideas.common.utils.StringUtils; +import org.apache.log4j.Logger; +import org.junit.Before; +import org.junit.Test; + +import java.io.IOException; + +import static junit.framework.TestCase.assertTrue; +import static junit.framework.TestCase.fail; + +public class NtpSetupTest extends AbstractSetupShellTest { + + private static final Logger logger = Logger.getLogger(NtpSetupTest.class); + + protected static String jailPath = null; + + private static boolean initialized = false; + + @Before + public void setUp() throws Exception { + if (!initialized) { + jailPath = setupJail(getServiceName()); + initialized = true; + } + } + + @Override + protected String getJailPath() { + return jailPath; + } + + @Override + protected String getServiceName() { + return "ntp"; + } + + @Override + protected void copyScripts(String jailPath) throws IOException { + // setup.sh is automatic + copyFile(jailPath, "common.sh"); + copyFile(jailPath, "inContainerSetupNtp.sh"); + copyFile(jailPath, "inContainerStartService.sh"); + copyFile(jailPath, "inContainerInjectTopology.sh"); + } + + @Override + protected String[] getScriptsToExecute() { + return new String[] { + "setup.sh", + "inContainerSetupNtp.sh", + "inContainerInjectTopology.sh" + }; + } + + @Test + public void testSystemDInstallation() throws Exception { + assertSystemDInstallation(); + } + + @Test + public void testSystemDockerManipulations() throws Exception { + assertSystemDServiceDockerCommands(); + } + + @Test + public void testConfigurationFileUpdate() throws Exception { + + assertTestConfFileUpdate(); + + String bashLogs = StreamUtils.getAsString(ResourceUtils.getResourceAsStream(jailPath + "/.log_bash")); + if (StringUtils.isNotBlank(bashLogs)) { + + System.err.println (bashLogs); + + /* + bash -c "echo -e \"\nlogfile /var/log/ntp/ntp.log\" >> /etc/ntp.conf" +bash -c "echo -e \"logconfig =syncevents +peerevents +sysevents +allclock\" >> /etc/ntp.conf" + */ + + assertTrue(bashLogs.contains("" + + "-c echo -e \"\\nlogfile /var/log/ntp/ntp.log\" >> /etc/ntp.conf\n" + + "-c echo -e \"logconfig =syncevents +peerevents +sysevents +allclock\" >> /etc/ntp.conf")); + + } else { + fail ("Expected to find bash logs in .log_bash"); + } + } +} diff --git a/src/test/resources/GrafanaSetupShellTest/testFile.conf b/src/test/resources/GrafanaSetupShellTest/testFile.conf new file mode 100644 index 00000000..61a4877e --- /dev/null +++ b/src/test/resources/GrafanaSetupShellTest/testFile.conf @@ -0,0 +1,17 @@ + +allow_embedding = false + +admin_user = admin + +admin_password = admin + +reporting_enabled = true + +default_theme = dark + +# enable anonymous access +enabled = false + +root_url = %(protocol)s://%(domain)s:%(http_port)s/ + +serve_from_sub_path = false diff --git a/src/test/resources/GrafanaSetupShellTest/testFile.conf.result b/src/test/resources/GrafanaSetupShellTest/testFile.conf.result new file mode 100644 index 00000000..57841205 --- /dev/null +++ b/src/test/resources/GrafanaSetupShellTest/testFile.conf.result @@ -0,0 +1,16 @@ +allow_embedding = true + +admin_user = eskimo + +admin_password = eskimo + +reporting_enabled = false + +default_theme = light + +# enable anonymous access +enabled = true + +root_url = /grafana/ + +serve_from_sub_path = true \ No newline at end of file diff --git a/src/test/resources/NtpSetupShellTest/testFile.conf b/src/test/resources/NtpSetupShellTest/testFile.conf new file mode 100644 index 00000000..df21eaba --- /dev/null +++ b/src/test/resources/NtpSetupShellTest/testFile.conf @@ -0,0 +1,8 @@ + +pool 0.debian.pool.ntp.org iburst + +pool 1.debian.pool.ntp.org iburst + +pool 2.debian.pool.ntp.org iburst + +pool 3.debian.pool.ntp.org iburst \ No newline at end of file diff --git a/src/test/resources/NtpSetupShellTest/testFile.conf.result b/src/test/resources/NtpSetupShellTest/testFile.conf.result new file mode 100644 index 00000000..3d4df76d --- /dev/null +++ b/src/test/resources/NtpSetupShellTest/testFile.conf.result @@ -0,0 +1,5 @@ +pool ntp1.hetzner.de iburst + +pool ntp2.hetzner.com iburst + +pool ntp3.hetzner.net iburst \ No newline at end of file