In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
This procedure mainly realizes the hive authority test. There are administrator user single and test user test in the system. Under the path / home/test/, write the preset conditions of the use case in the input folder, and each use case corresponds to an input file named x-y~z.q (where xyz is all numeric); put the statements that the use case needs to execute in the case folder, name it case_x.q;, write the expected results to the expect folder, and name it expect_x; execution results output to the output folder, named x-y~z.q
Execution process: kinit single user, beeline-u-f login and execute test user corresponding role recovery and authorization statements in the input file; kinit test user, beeline-u-f to execute the test statement in the case folder and save the execution results to the output folder; according to whether there is a file in the expect and the test is a forward or reverse test, compare it with the output content, get the test pass or fail results, and count the test results.
The program can automatically test the permissions of hive, but each use case corresponds to an input file, a case file, an expect file and an output file, which is too complicated and difficult to use. The next article is an optimized version of python.
#! / bin/bash#by cvv54 # rename existed log.txt# if [- f "/ home/test/log/log.txt"] Then # mv / home/test/log/log.txt / home/test/log/ `date "+% Y-%m-%d~%H-%M-%S" `# fi # To create log file date > > / home/test/log/ `date "+% Y-%m-%d~%H-%M-%S" `log= `ls / home/test/log/-rt | tail-1` pass=0; fail=0; block=0 # To traversal files in input folderfor i in / home/test/input/*.q do # To login system with user single to grant proper privileges to user test # $i here is name of input file,it looks like this: / path/to/file/x-y~z.q # (x:case number;y:item number;z:can be 1 or 2 means Positive testing or Negative Testing End with. Q: sql file) kdestroy kinit-kt / etc/security/keytabs/single.keytab single beeline-u "jdbc:hive2://gateway.xxx.xxx:10000/ Principal=single "- f $I & > / home/test/log/$log#$ {var%%-*} # the command removes the last'- 'character from the right of the variable var and its contents on the right, and returns the left side of the last' /'(excluding that character) from the right. # ${var##*/} # the purpose of this command is to remove the last'/ 'character of the variable var from the left and its contents on the left, and return the content to the right of the last' /'(excluding the character) from the left. # To drop path Only filename left jungle ${iatrophics /} # only for debug echo "juniors j" # To get last number in filename to distinguish Positive testing from Negative Testing karma ${only for debug echo "kryptonk" # get case number masks ${j% Mustang *} # only for debug echo "massifs" # To login system with user test to execute query statement # filename in folder case looks like this: case_x.q (x Is varable) # filename in folder output will be named like output_x-y~z.q (it is not a sql file...) Kdestroy kinit-kt / etc/security/keytabs/test.keytab test beeline-u "jdbc:hive2://gateway.xxx.xxx:10000/;principal=single"-f / home/test/case/case_$m.q & > > / home/test/output/output_$j # To check results # filename in folder expect looks like this: expect_x (x is varable) if [$k = "1.Q"]; then if [- f "/ home/test/expect/expect_$m"] Then eval $(/ bin/grep ok / home/test/expect/expect_$m) eval $(/ bin/grep nok / home/test/expect/expect_$m) if [- n "`grep-w $ok / home/test/output/output_$ j`"] Then echo "$I pass" > > / home/test/log/result.txt ((pass++)) elif [- n "`grep-w $nok / home/test/output/output_$ j`"] Then echo "$I failed" > > / home/test/log/result.txt ((fail++)) else echo "$I block" > > / home/test/log/result.txt ((block++)) fi elif [- n "`grep-w" seconds "/ home/test/output/output_$ j`"] Then echo "$I pass" > > / home/test/log/result.txt ((pass++)) elif [- n "`grep-w" FAILED: SemanticException No valid privileges "/ home/test/output/output_$ j`"] Then echo "$I failed" > > / home/test/log/result.txt ((fail++)) else echo "$I block" > > / home/test/log/result.txt ((block++)) fi else if [- f "/ home/test/expect/expect_$m"] Then eval $(/ bin/grep ok / home/test/expect/expect_$m) eval $(/ bin/grep nok / home/test/expect/expect_$m) if [- n "`grep-w $nok / home/test/output/output_$ j`"] Then echo "$I pass" > > / home/test/log/result.txt ((pass++)) elif [- n "`grep-w $ok / home/test/output/output_$ j`"] Then echo "$I failed" > > / home/test/log/result.txt ((fail++)) else echo "$I block" > > / home/test/log/result.txt ((block++)) fi elif [- n "`grep-w" seconds "/ home/test/output/output_$ j`"] Then echo "$I failed" > > / home/test/log/result.txt ((fail++)) elif [- n "`grep-w" FAILED: SemanticException No valid privileges "/ home/test/output/output_$ j`"] Then echo "$I pass" > > / home/test/log/result.txt ((pass++)) else echo "$I block" > > / home/test/log/result.txt ((block++)) fi fi doneecho `date` > / home/test/log/result.txtecho "$pass passed" > > / home/test/log/result.txtecho "$fail failed" > > / home/test/ Log/result.txtecho "$block blocked" > > / home/test/log/result.txt#rename log.txt with current timecat / home/test/log/result.txt > > / home/test/log/$logrm-f / home/test/log/result.txt
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.