python实现hive自动化测试

本文介绍了一个使用Python进行Hive权限自动化测试的程序。通过kinit切换用户,利用beeline执行权限变更和测试语句,并根据预期结果进行判断,统计测试结果。测试配置存储在XML文件中。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本程序主要实现hive权限测试。系统中有管理员用户single和测试用户test。在路径/home/test/下,将用例和预期结果写在xml文件中。

        执 行过程:kinit single用户,beeline -u -e登录并执行对test用户对应角色回收和赋予权限的语句;kinit test用户,beeline -u -e去执行测试语句并保存执行结果到tmp文件中;在tmp文件中查找预期关键字,得出该测试pass还是fail的结果,统计测试结果。

#!/usr/bin/python
#coding:utf-8
#by cvv54

import sys
import os
import re

try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET

try:
    tree = ET.parse("/home/test/case/usecase.xml")
    #root = ET.fromstring(country_string)
    root = tree.getroot()
except Exception,e:
    print "Error:cannot parse file:usecase.xml."
    sys.exit(1)
print root.tag,"---",root.attrib
for child in root:
    print child.tag,"---",child.attrib

passed=0
failed=0    

for case in root.findall('case'):
    pre = case.find('pre').text
    perform =
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值