It's simple framework of automation test for sentry hive, spark.
This project was written in bash and java.
- Allow you to run sentry, hive automated testing.
- Allow you to run sentry, spark automated testing.
- Allow you to run Single test case or All test cases.
- sentry will grant user, role and group privileges
- hive or spark will execute sql with authorized End-user
The command will run sentry hive, spark test cases. All test cases will be defined in the script. You can specify single test case or multiple test cases to run.
$ /usr/bin/time -f "Time: %U" bash sentry_dispatcher.shYou can also run it by manually.
-
grant user with super privilege.
super privilege will be granted to user mt_qa .$ source ./sentry-test/src/main/resources/sentry_super_env.sh setup SuperPrivilNOTE: Usage: sentry_super_env.sh (setup|clean|check) SuperPrivil
-
grant user with normal privilege.
You should specify the test name which need to be granted, if you need to run test case with ServerAll privilege.$ source ./sentry-test/src/main/resources/sentry_env.sh setup ServerAllNOTE: Usage: sentry_env.sh (setup|clean|check) ServerAll
-
login hive shell with super user to execute prepare sql.
To execute prepare sql, you need to login hive shell with super user (mt_qa).$ source ./sentry-test/src/main/resources/hive_env.sh proxy_user_t1 super $ /opt/meituan/hive-1.2/bin/hive --hiveconf hive.cli.errors.ignore=true -f ./sentry-test/src/test/resources/hive-sql/common-sql/prepareAll.sqlNOTE: Usage: hive_env.sh (keytab_auth|proxy_user_t1|proxy_user_t2_1|proxy_user_t2_2|proxy_user_group1|proxy_user_group2|clean_proxy_user) (super|normal|hive)"
-
login hive shell with normal user and run single test case.
You can now login hive shell with normal user and run specify test case. For example: ServerAll$ source sentry-test/src/main/resources/hive_env.sh proxy_user_t1 normal $ java -Djava.ext.dirs=./sentry-test/test-lib/ -cp ./sentry-test/target/classes:./sentry-test/target/test-classes/ org.junit.runner.JUnitCore ServerAll -
login hive shell with super user to execute post sql.
To execute post sql, you need to login hive shell with super user (mt_qa).$ source ./sentry-test/src/main/resources/hive_env.sh proxy_user_t1 super $ /opt/meituan/hive-1.2/bin/hive --hiveconf hive.cli.errors.ignore=true -f ./sentry-test/src/test/resources/hive-sql/common-sql/post.sql -
clean proxy env.
You need to clean proxy env, if you login hive with proxy approach.$ source ./sentry-test/src/main/resources/hive_env.sh clean_proxy_user hiveNOTE: login hive with
proxyapproach, we need to unset proxy env otherwise it will throw exception.
NOTE: login hive withkeytabapproach, this step is not needed. -
revoke user with super privilege.
super privilege will be revoked to user mt_qa.$ source ./sentry-test/src/main/resources/sentry_super_env.sh clean SuperPrivil -
revoke user with normal privilege.
You should specify the test name which need to be revoked, if you need to revoke test case with ServerAll privilege.$ source ./sentry-test/src/main/resources/sentry_env.sh clean ServerAll
- check sentry-test/src/test/log directory, all running logs will be generated in the directory dynamically.