Browse Source

WIP: Unit tests -- more generalization

Joseph Henry 9 years ago
parent
commit
9a25a627bb

+ 28 - 0
docker-test/README.md

@@ -0,0 +1,28 @@
+To run unit tests:
+
+1) Place a blank network config file in this directory (e.g. "e5cd7a9e1c5311ab.conf")
+ - This will be used to inform test-specific scripts what network to use for testing (create your own, or use the given at your own risk)
+
+2) run build.sh
+ - Builds ZeroTier with Network Containers enabled
+ - Builds LWIP library
+ - Builds library harness
+ - Copies all aformentioned files into unit test directory to be used for building docker files
+
+3) run test.sh
+ - Will (for now, one at a time), execute each unit test's (test.sh)
+
+
+
+A) Each unit test's test.sh will:
+ - temporarily copy all built files into local directory
+ - build test container
+ - build monitor container
+ - remove temporary files
+ - run each container and perform test
+
+B) Results will be written to the 'zerotierone/docker-test/_result' directory
+ - Results will be a combination of raw and formatted dumps to files whose names reflect the test performed
+ - In the event of failure, 'FAIL.' will be appended to the result file's name
+  - (e.g. FAIL.my_application_1.0.2.x86_64)
+ - In the event of success, 'OK.' will be appended

+ 1 - 0
docker-test/_results/httpd_bigfile_addr.txt

@@ -0,0 +1 @@
+172.30.238.230

+ 0 - 0
docker-test/e5cd7a9e1c5311ab.conf


+ 0 - 0
docker-test/httpd/httpd_2.4.16-1.fc23.x86_64/README.md → docker-test/httpd/httpd-2.4.16-1.fc23.x86_64/README.md


+ 2 - 1
docker-test/httpd/httpd_2.4.16-1.fc23.x86_64/monitor_dockerfile → docker-test/httpd/httpd-2.4.16-1.fc23.x86_64/monitor_dockerfile

@@ -8,7 +8,8 @@ EXPOSE 9993/udp
 RUN mkdir -p /var/lib/zerotier-one/networks.d
 ADD monitor_identity.public /var/lib/zerotier-one/identity.public
 ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
-RUN touch /var/lib/zerotier-one/networks.d/e5cd7a9e1c5311ab.conf
+ADD *.conf /var/lib/zerotier-one/networks.d/
+ADD *.conf /
 ADD zerotier-one /
 ADD zerotier-cli /
 

+ 2 - 2
docker-test/httpd/httpd_2.4.16-1.fc23.x86_64/monitor_entrypoint.sh → docker-test/httpd/httpd-2.4.16-1.fc23.x86_64/monitor_entrypoint.sh

@@ -2,7 +2,7 @@
 
 # Parameters for test
 test_name=httpd_bigfile
-nwid=e5cd7a9e1c5311ab # test network
+nwid=$(ls *.conf) # test network (assume *.conf file in root directory is where we want to test)
 netcon_wait_time=45 # wait for test container to come online
 app_timeout_time=10 # app-specific timeout
 file_path=/opt/results/ # test result output file path (fs shared between host and containers)
@@ -37,7 +37,7 @@ while [ -z "$virtip4" ]; do
 done
 
 echo '*** Starting Test...'
-echo '*** Up and running at' $virtip4
+echo '*** Up and running at' $virtip4 ' on network: ' $nwid
 echo '*** Sleeping for 30s while we wait for the Network Container to come online...'
 sleep "$netcon_wait_time"s
 ncvirtip=$(<$address_file)

+ 3 - 1
docker-test/httpd/httpd_2.4.16-1.fc23.x86_64/netcon_dockerfile → docker-test/httpd/httpd-2.4.16-1.fc23.x86_64/netcon_dockerfile

@@ -21,7 +21,9 @@ RUN /usr/bin/install -c intercept /usr/bin
 RUN mkdir -p /var/lib/zerotier-one/networks.d
 ADD netcon_identity.public /var/lib/zerotier-one/identity.public
 ADD netcon_identity.secret /var/lib/zerotier-one/identity.secret
-RUN touch /var/lib/zerotier-one/networks.d/e5cd7a9e1c5311ab.conf
+ADD *.conf /var/lib/zerotier-one/networks.d/
+ADD *.conf /
+
 ADD zerotier-one /
 ADD zerotier-cli /
 

+ 2 - 2
docker-test/httpd/httpd_2.4.16-1.fc23.x86_64/netcon_entrypoint.sh → docker-test/httpd/httpd-2.4.16-1.fc23.x86_64/netcon_entrypoint.sh

@@ -2,7 +2,7 @@
 
 # Parameters for test
 test_name=httpd_bigfile
-nwid=e5cd7a9e1c5311ab # test network
+nwid=$(ls *.conf) # test network
 file_path=/opt/results/ # test result output file path (fs shared between host and containers)
 file_base="$test_name".txt # test result output file
 address_file="$file_path$test_name"_addr.txt # file shared between host and containers for sharing address (optional)
@@ -31,7 +31,7 @@ while [ -z "$virtip4" ]; do
 	virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
 done
 
-echo '*** Up and running at' $virtip4
+echo '*** Up and running at' $virtip4 ' on network: ' $nwid
 echo $virtip4 > "$address_file"
 
 # Generate large random file for transfer test

+ 2 - 1
docker-test/httpd/httpd_2.4.16-1.fc23.x86_64/test.sh → docker-test/httpd/httpd-2.4.16-1.fc23.x86_64/test.sh

@@ -3,6 +3,7 @@ testname=${PWD##*/}
 echo 'Building dockerfiles for test: ' "$testname"
 
 # Docker won't allow the inclusion of files outside of the build directory
+cp ../../*.conf .
 cp ../../zerotier-one zerotier-one
 cp ../../zerotier-cli zerotier-cli
 cp ../../intercept intercept
@@ -13,7 +14,6 @@ cp ../../netcon_identity.secret netcon_identity.secret
 cp ../../monitor_identity.public monitor_identity.public
 cp ../../monitor_identity.secret monitor_identity.secret
 
-
 docker build --tag="$testname" -f netcon_dockerfile .
 docker build --tag="$testname"_monitor -f monitor_dockerfile .
 
@@ -26,6 +26,7 @@ rm -f netcon_identity.public
 rm -f netcon_identity.secret
 rm -f monitor_identity.public
 rm -f monitor_identity.secret
+rm -f *.conf
 
 # Start netcon container to be tested
 docker run -d -it -v $PWD/../../_results:/opt/results --device=/dev/net/tun "$testname":latest

+ 2 - 1
docker-test/test.sh

@@ -1,2 +1,3 @@
 /httpd/httpd_demo/test.sh
-/httpd/throughput_httpd.2.4.6/test.sh
+/httpd/httpd-2.4.16-1.fc23.x86_64/test.sh
+