mk-docker-opts_tests.sh 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/bash
  2. set -e
  3. echo "### Dry run with input & output files set"
  4. echo "$ ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt"
  5. ! read -d '' EXPECTED <<EOF
  6. DOCKER_OPT_BIP="--bip=10.1.74.1/24"
  7. DOCKER_OPT_IPMASQ="--ip-masq=true"
  8. DOCKER_OPT_MTU="--mtu=1472"
  9. DOCKER_OPTS=" --bip=10.1.74.1/24 --ip-masq=true --mtu=1472"
  10. EOF
  11. ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt
  12. diff -B -b here.txt <(echo -e "${EXPECTED}")
  13. echo
  14. echo "### Individual vars only (Note DOCKER_OPTS= is missing)"
  15. echo "$ ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -i"
  16. ! read -d '' EXPECTED <<EOF
  17. DOCKER_OPT_BIP="--bip=10.1.74.1/24"
  18. DOCKER_OPT_IPMASQ="--ip-masq=true"
  19. DOCKER_OPT_MTU="--mtu=1472"
  20. EOF
  21. ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -i
  22. diff -B -b here.txt <(echo -e "${EXPECTED}")
  23. echo
  24. echo "### Combined vars only (Note DOCKER_OPT_* vars are missing)"
  25. echo "$ ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -c"
  26. ! read -d '' EXPECTED <<EOF
  27. DOCKER_OPTS=" --bip=10.1.74.1/24 --ip-masq=true --mtu=1472"
  28. EOF
  29. ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -c
  30. diff -B -b here.txt <(echo -e "${EXPECTED}")
  31. echo
  32. echo "### Custom key test (Note DOCKER_OPTS= is substituted by CUSTOM_KEY=)"
  33. echo "$ ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -k CUSTOM_KEY"
  34. ! read -d '' EXPECTED <<EOF
  35. DOCKER_OPT_BIP="--bip=10.1.74.1/24"
  36. DOCKER_OPT_IPMASQ="--ip-masq=true"
  37. DOCKER_OPT_MTU="--mtu=1472"
  38. CUSTOM_KEY=" --bip=10.1.74.1/24 --ip-masq=true --mtu=1472"
  39. EOF
  40. ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -k CUSTOM_KEY
  41. diff -B -b here.txt <(echo -e "${EXPECTED}")
  42. echo
  43. echo "### Ip-masq stripping test (Note DOCKER_OPT_IPMASQ and --ip-masq=true are missing)"
  44. echo "$ ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -m"
  45. ! read -d '' EXPECTED <<EOF
  46. DOCKER_OPT_BIP="--bip=10.1.74.1/24"
  47. DOCKER_OPT_MTU="--mtu=1472"
  48. DOCKER_OPTS=" --bip=10.1.74.1/24 --mtu=1472"
  49. EOF
  50. ./mk-docker-opts.sh -f ./sample_subnet.env -d here.txt -m
  51. diff -B -b here.txt <(echo -e "${EXPECTED}")