69 lines
5.6 KiB
Plaintext
69 lines
5.6 KiB
Plaintext
*** Settings ***
|
||
Library Collections
|
||
Library RequestsLibrary
|
||
Library String
|
||
Resource ../../../03-Variable/Bifangapivariable.txt
|
||
Resource ForTwoKeywords.robot
|
||
|
||
*** Keywords ***
|
||
ProxyPinning
|
||
# dashboard界面 Proxy Pinning计数 bifang和bigData对比
|
||
[Documentation]
|
||
... 描述:ProxyPinning
|
||
... 参数:starttime(必传,开始时间紧)
|
||
... timeGranularity(必传,时间粒度 )
|
||
... limit(必传,限制条数)
|
||
... endtime(必传,结束时间)
|
||
[Arguments] ${starttime} ${endtime} ${timeGranularity} ${limit}
|
||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&timeGranularity=${timeGranularity}&limit=${limit}
|
||
${url1} Set Variable report/policyevent/hit/pinning
|
||
${bfResponse} TrafficBFRequest ${url1} ${data}
|
||
${notPinningNum} Set Variable ${bfResponse['data']['notPinningNum']}
|
||
${maybePinningNum} Set Variable ${bfResponse['data']['maybePinningNum']}
|
||
${pinningNum} Set Variable ${bfResponse['data']['pinningNum']}
|
||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||
${sql} Set Variable (select \ sum(hits) as hits, 'not_pinning_num' as type from security_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' and pinningst=0) \ union all \ (select \ sum(hits) as hits, 'pinning_num' as type from security_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' and pinningst=1) \ union all \ (select \ sum(hits) as hits, 'maybe_pinning_num' as type from security_event_hits_log \ where __time >= '${startTime}' and __time < '${endTime}' and pinningst=2)
|
||
${remoteResponse} Get Request bdapi ?query=${sql}
|
||
${response} to json ${remoteResponse.content}
|
||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||
Should Be Equal As Strings ${response['status']} 200
|
||
@{list} Set Variable ${response['data']}
|
||
FOR ${element} IN @{list}
|
||
log ${element}
|
||
Run Keyword If '${element['type']}'=='not_pinning_num' Should Be Equal ${element['hits']} ${notPinningNum}
|
||
... ELSE IF '${element['type']}'=='pinning_num' Should Be Equal ${element['hits']} ${pinningNum}
|
||
... ELSE IF '${element['type']}'=='maybe_pinning_num' Should Be Equal ${element['hits']} ${maybePinningNum}
|
||
END
|
||
|
||
ProxyPinningTrend
|
||
# dashboard界面 Proxy Pinning计数趋势 bifang和bigData对比
|
||
[Documentation]
|
||
... 描述:ProxyPinning-trend
|
||
... 参数:starttime(必传,开始时间紧)
|
||
... timeGranularity(必传,时间粒度 )
|
||
... limit(必传,限制条数)
|
||
... endtime(必传,结束时间)
|
||
[Arguments] ${starttime} ${endtime} ${timeGranularity} ${limit}
|
||
${data} Set Variable startTime=${startTime}&endTime=${endTime}&timeGranularity=${timeGranularity}&limit=${limit}
|
||
${url1} Set Variable report/policyevent/hit/pinning
|
||
${bfResponse} trafficBFRequest ${url1} ${data}
|
||
@{notPinningTrendList} Set Variable ${bfResponse['data']['notPinningTrendList']}
|
||
@{maybePinningTrendList} Set Variable ${bfResponse['data']['maybePinningTrendList']}
|
||
@{pinningTrendList} Set Variable ${bfResponse['data']['pinningTrendList']}
|
||
Create Session bdapi http://${bigDataIP}:${bigDataPort}
|
||
${sql} Set Variable (select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, 'not_pinning_num' as type, sum(hits) as hits from security_event_hits_log where __time >= '${startTime}' and __time < '${endTime}' and pinningst=0 group by DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') limit ${limit}) union all (select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') \ as stat_time, 'pinning_num' as type, sum(hits) as hits from security_event_hits_log where \ __time >= '${startTime}' and __time < '${endTime}' and pinningst=1 \ group by DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') \ limit ${limit}) union all (select DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') as stat_time, 'maybe_pinning_num' as type, sum(hits) as hits from security_event_hits_log where \ __time >= '${startTime}' and __time < '${endTime}' and pinningst=2 \ \ group by DATE_FORMAT(FROM_UNIXTIME(FLOOR(UNIX_TIMESTAMP(__time)/${timeGranularity})*${timeGranularity}),'%Y-%m-%d %H:%i:%s') limit ${limit})
|
||
${remoteResponse} Get Request bdapi ?query=${sql}
|
||
${response} to json ${remoteResponse.content}
|
||
Should Be Equal As Strings ${remoteResponse.status_code} 200
|
||
Should Be Equal As Strings ${response['status']} 200
|
||
@{list} Set Variable ${response['data']}
|
||
${type1} Set Variable not_pinning_num
|
||
Run Keyword If ${notPinningTrendList}!=[] and ${list}!=[] ForToProxyPinningTrend ${notPinningTrendList} ${type1} ${list}
|
||
${type2} Set Variable maybe_pinning_num
|
||
Run Keyword If ${maybePinningTrendList}!=[] and ${list}!=[] ForToProxyPinningTrend ${maybePinningTrendList} ${type2} ${list}
|
||
${type3} Set Variable pinning_num
|
||
Run Keyword If ${pinningTrendList}!=[] and ${list}!=[] ForToProxyPinningTrend ${pinningTrendList} ${type3} ${list}
|
||
|
||
|
||
|