1
0

hadoop_subcommands.bats 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. load hadoop-functions_test_helper
  16. # the loading of shell profiles are tested elseswhere
  17. # this only tests the specific subcommand parts
  18. subcommandsetup () {
  19. export HADOOP_LIBEXEC_DIR="${TMP}/libexec"
  20. export HADOOP_CONF_DIR="${TMP}/conf"
  21. mkdir -p "${HADOOP_LIBEXEC_DIR}"
  22. echo ". \"${BATS_TEST_DIRNAME}/../../main/bin/hadoop-functions.sh\"" > "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
  23. cat <<-'TOKEN' >> "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
  24. hadoop_subcommand_sub () {
  25. echo "unittest"
  26. exit 0
  27. }
  28. hadoop_subcommand_conftest ()
  29. {
  30. echo conftest
  31. exit 0
  32. }
  33. hadoop_subcommand_envcheck ()
  34. {
  35. echo ${HADOOP_SHELL_EXECNAME}
  36. exit 0
  37. }
  38. hadoop_subcommand_multi ()
  39. {
  40. echo $2
  41. exit 0
  42. }
  43. TOKEN
  44. chmod a+rx "${HADOOP_LIBEXEC_DIR}/hadoop-config.sh"
  45. }
  46. @test "hadoop_subcommand (addition)" {
  47. subcommandsetup
  48. run "${BATS_TEST_DIRNAME}/../../main/bin/hadoop" sub
  49. echo ">${output}<"
  50. [ "${output}" = unittest ]
  51. }
  52. @test "hadoop_subcommand (substitute)" {
  53. subcommandsetup
  54. run "${BATS_TEST_DIRNAME}/../../main/bin/hadoop" conftest
  55. echo ">${output}<"
  56. [ "${output}" = conftest ]
  57. }
  58. @test "hadoop_subcommand (envcheck)" {
  59. subcommandsetup
  60. run "${BATS_TEST_DIRNAME}/../../main/bin/hadoop" envcheck
  61. [ "${output}" = hadoop ]
  62. }
  63. @test "hadoop_subcommand (multiparams)" {
  64. subcommandsetup
  65. run "${BATS_TEST_DIRNAME}/../../main/bin/hadoop" multi 1 2
  66. [ "${output}" = 2 ]
  67. }