Adding docker support for writing replication ITs

Change-Id: If7948a25f39e1c155ce96502572c1eef122f04bf
Reviewed-on: https://asterix-gerrit.ics.uci.edu/1644
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
BAD: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Michael Blow <mblow@apache.org>
diff --git a/asterixdb/asterix-installer/pom.xml b/asterixdb/asterix-installer/pom.xml
index e1fac3a..6afc703 100644
--- a/asterixdb/asterix-installer/pom.xml
+++ b/asterixdb/asterix-installer/pom.xml
@@ -300,6 +300,8 @@
             <exclude>src/test/resources/clusterts/id_rsa</exclude>
             <exclude>src/test/resources/clusterts/id_rsa.pub</exclude>
             <exclude>src/test/resources/clusterts/known_hosts</exclude>
+            <exclude>src/test/resources/docker/id_rsa</exclude>
+            <exclude>src/test/resources/docker/id_rsa.pub</exclude>
             <exclude>src/test/resources/transactionts/results/query_after_restart/big_object_20M/big_object_20M.1.adm.template</exclude>
             <exclude>src/test/resources/integrationts/restart/tweets.json</exclude> <!-- https://issues.apache.org/jira/browse/ASTERIXDB-1850 -->
           </excludes>
diff --git a/asterixdb/asterix-installer/src/test/resources/docker/Dockerfile b/asterixdb/asterix-installer/src/test/resources/docker/Dockerfile
new file mode 100644
index 0000000..1b0193c
--- /dev/null
+++ b/asterixdb/asterix-installer/src/test/resources/docker/Dockerfile
@@ -0,0 +1,54 @@
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+FROM centos
+MAINTAINER AsterixDB Team
+
+RUN echo 'LANG="en_US.UTF-8"' > /etc/sysconfig/i18n ;echo 'ZONE="America/Los_Angeles"' > /etc/sysconfig/clock ;cp -a /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
+RUN echo "include_only=.us" >> /etc/yum/pluginconf.d/fastestmirror.conf
+RUN yum -y update
+RUN yum install -y unzip java-1.8.0-openjdk openssh-server openssh-clients python-setuptools wget curl net-tools
+
+RUN sshd-keygen
+RUN sed -i "s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
+
+RUN useradd asterix -G wheel -s /bin/bash -m
+RUN echo 'asterix:asterix' | chpasswd
+RUN echo '%wheel ALL=(ALL) ALL' >> /etc/sudoers
+RUN echo 'Host *' >> /etc/ssh/ssh_config
+RUN echo '    StrictHostKeyChecking no' >> /etc/ssh/ssh_config
+
+CMD ["/usr/sbin/sshd", "-D"]
+
+RUN mkdir /asterixdb
+RUN mkdir /asterixdb/asterix
+RUN mkdir /asterixdb/data
+COPY asterix-installer*.zip .
+RUN unzip asterix-installer*.zip -d /asterixdb/asterix-installer/
+COPY id_rsa /root/.ssh/id_rsa
+COPY id_rsa.pub /root/.ssh/id_rsa.pub
+COPY cluster-config.xml /asterixdb/
+
+RUN cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
+RUN chmod 600 /root/.ssh/id_rsa*
+RUN chmod 700 /root/.ssh/authorized_keys
+
+ENV JAVA_HOME /usr/lib/jvm/jre-1.8.0
+ENV JAVA_OPTS -Xmx2048m
+
+EXPOSE 19001 19002 8888 19003 50031 15001
diff --git a/asterixdb/asterix-installer/src/test/resources/docker/cluster-config.xml b/asterixdb/asterix-installer/src/test/resources/docker/cluster-config.xml
new file mode 100644
index 0000000..4d5d0bd
--- /dev/null
+++ b/asterixdb/asterix-installer/src/test/resources/docker/cluster-config.xml
@@ -0,0 +1,76 @@
+<!--
+ ! Licensed to the Apache Software Foundation (ASF) under one
+ ! or more contributor license agreements.  See the NOTICE file
+ ! distributed with this work for additional information
+ ! regarding copyright ownership.  The ASF licenses this file
+ ! to you under the Apache License, Version 2.0 (the
+ ! "License"); you may not use this file except in compliance
+ ! with the License.  You may obtain a copy of the License at
+ !
+ !   http://www.apache.org/licenses/LICENSE-2.0
+ !
+ ! Unless required by applicable law or agreed to in writing,
+ ! software distributed under the License is distributed on an
+ ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ! KIND, either express or implied.  See the License for the
+ ! specific language governing permissions and limitations
+ ! under the License.
+ !-->
+<cluster xmlns="cluster">
+
+  <name>asterix</name>
+
+  <username>root</username>
+
+  <working_dir>
+    <dir>/asterixdb/asterix/managix-working</dir>
+    <NFS>false</NFS>
+  </working_dir>
+
+  <log_dir>/asterixdb/data/logs/</log_dir>
+  <txn_log_dir>/asterixdb/data/tx_logs</txn_log_dir>
+  <iodevices>/asterixdb/data/p1,/asterixdb/data/p2</iodevices>
+
+  <store>storage</store>
+
+  <java_home>/usr/lib/jvm/jre-1.8.0</java_home>
+  <metadata_node>nc1</metadata_node>
+
+  <high_availability>
+    <enabled>true</enabled>
+    <data_replication>
+      <strategy>chained_declustering</strategy>
+      <replication_port>2016</replication_port>
+      <replication_time_out>30</replication_time_out>
+      <replication_factor>2</replication_factor>
+    </data_replication>
+    <fault_tolerance>
+       <strategy>auto</strategy>
+    </fault_tolerance>
+  </high_availability>
+
+  <master_node>
+    <id>cc</id>
+    <client_ip>172.20.0.2</client_ip>
+    <cluster_ip>172.20.0.2</cluster_ip>
+    <client_port>1098</client_port>
+    <cluster_port>1099</cluster_port>
+    <http_port>8888</http_port>
+  </master_node>
+  <node>
+    <id>nc1</id>
+    <cluster_ip>172.20.0.3</cluster_ip>
+  </node>
+  <node>
+    <id>nc2</id>
+    <cluster_ip>172.20.0.4</cluster_ip>
+  </node>
+  <node>
+    <id>nc3</id>
+    <cluster_ip>172.20.0.5</cluster_ip>
+  </node>
+  <node>
+    <id>nc4</id>
+    <cluster_ip>172.20.0.6</cluster_ip>
+  </node>
+</cluster>
diff --git a/asterixdb/asterix-installer/src/test/resources/docker/docker-compose.yml b/asterixdb/asterix-installer/src/test/resources/docker/docker-compose.yml
new file mode 100644
index 0000000..224b0a9
--- /dev/null
+++ b/asterixdb/asterix-installer/src/test/resources/docker/docker-compose.yml
@@ -0,0 +1,116 @@
+#/*
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+version: "3.1"
+
+services:
+  cc:
+    image: asterix-test
+    container_name: cc
+    stdin_open: true
+    tty: true
+    volumes:
+        - ./asterix:/asterix
+    deploy:
+      resources:
+        limits:
+          memory: 1024M
+    networks:
+      asterix_net:
+        ipv4_address: 172.20.0.2
+    ports:
+      - "19001:19001"
+
+  nc1:
+    image: asterix-test
+    container_name: nc1
+    stdin_open: true
+    tty: true
+    volumes:
+        - ./asterix:/asterix
+    deploy:
+      resources:
+        limits:
+          memory: 2560M
+    networks:
+      asterix_net:
+        ipv4_address: 172.20.0.3
+    ports:
+      - "6001:15001"
+
+  nc2:
+    image: asterix-test
+    container_name: nc2
+    stdin_open: true
+    tty: true
+    volumes:
+      - ./asterix:/asterix
+    deploy:
+      resources:
+        limits:
+          memory: 2560M
+    networks:
+      asterix_net:
+        ipv4_address: 172.20.0.4
+    ports:
+      - "6002:15001"
+
+  nc3:
+    image: asterix-test
+    container_name: nc3
+    stdin_open: true
+    tty: true
+    volumes:
+      - ./asterix:/asterix
+    deploy:
+      resources:
+        limits:
+          memory: 2560M
+    networks:
+      asterix_net:
+        ipv4_address: 172.20.0.5
+    ports:
+        - "6003:15001"
+
+  nc4:
+    image: asterix-test
+    container_name: nc4
+    stdin_open: true
+    tty: true
+    volumes:
+      - ./asterix:/asterix
+    deploy:
+      resources:
+        limits:
+          memory: 2560M
+    networks:
+      asterix_net:
+        ipv4_address: 172.20.0.6
+    ports:
+        - "6004:15001"
+
+
+networks:
+  asterix_net:
+    driver: bridge
+    driver_opts:
+      com.docker.network.enable_ipv6: "false"
+    ipam:
+      driver: default
+      config:
+      - subnet: 172.20.0.0/24
diff --git a/asterixdb/asterix-installer/src/test/resources/docker/id_rsa b/asterixdb/asterix-installer/src/test/resources/docker/id_rsa
new file mode 100644
index 0000000..7d6a083
--- /dev/null
+++ b/asterixdb/asterix-installer/src/test/resources/docker/id_rsa
@@ -0,0 +1,27 @@
+-----BEGIN RSA PRIVATE KEY-----
+MIIEogIBAAKCAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzI
+w+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoP
+kcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2
+hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NO
+Td0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcW
+yLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQIBIwKCAQEA4iqWPJXtzZA68mKd
+ELs4jJsdyky+ewdZeNds5tjcnHU5zUYE25K+ffJED9qUWICcLZDc81TGWjHyAqD1
+Bw7XpgUwFgeUJwUlzQurAv+/ySnxiwuaGJfhFM1CaQHzfXphgVml+fZ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+NE5OgEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
+-----END RSA PRIVATE KEY-----
diff --git a/asterixdb/asterix-installer/src/test/resources/docker/id_rsa.pub b/asterixdb/asterix-installer/src/test/resources/docker/id_rsa.pub
new file mode 100644
index 0000000..f762934
--- /dev/null
+++ b/asterixdb/asterix-installer/src/test/resources/docker/id_rsa.pub
@@ -0,0 +1 @@
+ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==