Skip to content

Commit

Permalink
Ranger REST API SmokeTests with ROBOT Framework
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek Kumar committed Nov 22, 2024
1 parent f06d0e7 commit 3790cc1
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 8 deletions.
42 changes: 34 additions & 8 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
distribution: 'temurin'
cache: maven
- name: build (8)
run: mvn -T 8 clean install --no-transfer-progress -B -V
run: mvn -T 8 clean install -DskipTests --no-transfer-progress -B -V
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
Expand All @@ -66,11 +66,10 @@ jobs:
with:
name: target-11
path: target/*

docker-build:
needs:
- build-8
- build-11
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -134,7 +133,8 @@ jobs:
-f docker-compose.ranger-hive.yml \
-f docker-compose.ranger-knox.yml \
-f docker-compose.ranger-ozone.yml up -d
- name: Check status of containers and remove them
- name: Check status of containers
run: |
sleep 60
containers=(ranger ranger-zk ranger-solr ranger-postgres ranger-usersync ranger-tagsync ranger-kms ranger-hadoop ranger-hbase ranger-kafka ranger-hive ranger-knox ozone-om ozone-scm ozone-datanode);
Expand All @@ -150,8 +150,34 @@ jobs:
if [[ $flag == true ]]; then
echo "All required containers are up and running";
docker stop $(docker ps -q) && docker rm $(docker ps -aq);
else
docker stop $(docker ps -q) && docker rm $(docker ps -aq);
exit 1;
fi
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'

# Install Robot Framework and dependencies
- name: Install Robot Framework
run: |
python -m pip install --upgrade pip
python --version
pip install robotframework
pip install robotframework-requests
robot --version || true
- name: Run Ranger REST API SmokeTests
run: |
cd dev-support/smoketests/ranger/apis
mkdir -p output
robot --outputdir output --loglevel DEBUG session_management.robot policy_management.robot user_management.robot
- name: Upload Robot Framework Artifacts
uses: actions/upload-artifact@v4
with:
name: Robot-Framework-Artifacts
path: output/

- name: Remove Containers
run: |
docker stop $(docker ps -q) && docker rm $(docker ps -aq);
54 changes: 54 additions & 0 deletions dev-support/smoketests/ranger/apis/policy_management.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
*** Settings ***
Library Collections
Resource resources.robot
Suite Setup Initialize Ranger Session (HTTP)

*** Variables ***
${POLICY_NAME} hbase-archive
${HDFS_SVC_NAME} dev_hdfs
${HIVE_SVC_NAME} dev_hive
${HIVE_POLICY} test policy
${QPARAMS} servicename=dev_hive&policyname=test policy
@{TEST_DB} test_db
@{TEST_TABLE} test_tbl
@{TEST_COL} *
&{ACCESS_CR} type=create isAllowed=${true}
&{ACCESS_AL} type=alter isAllowed=${true}
&{ACCESS_DR} type=drop isAllowed=${true}
@{ACCESSES} ${ACCESS_CR} ${ACCESS_AL}
@{D_ACCESSES} ${ACCESS_DR}
@{USERS} admin

*** Test Cases ***
Get All Policies
${response}= GET On Session ranger /service/public/v2/api/policy
Should Be Equal As Numbers ${response.status_code} 200
Log ${response.json()}


Create New Hive Policy
${database} Create Dictionary values=${TEST_DB} isExcludes=${false} isRecursive=${false}
${table} Create Dictionary values=${TEST_TABLE} isExcludes=${false} isRecursive=${false}
${column} Create Dictionary values=${TEST_COL} isExcludes=${false} isRecursive=${false}

${resources} Create Dictionary database=${database} table=${table} column=${column}

${policy_item} Create Dictionary delegateAdmin=${false} users=${USERS} accesses=${ACCESSES}
${deny_policy_item} Create Dictionary delegateAdmin=${false} users=${USERS} accesses=${D_ACCESSES}

${policy_items} Create List ${policy_item}
${deny_policy_items} Create List ${deny_policy_item}
${payload} Create Dictionary service=${HIVE_SVC_NAME} isEnabled=${true} isDenyAllElse=${false} name=test policy resources=${resources} policyItems=${policy_items} denyPolicyItems=${deny_policy_items}

# Log and Verify Payload
Log ${payload}

${response}= POST On Session ranger /service/public/v2/api/policy json=${payload}
Should Be Equal As Numbers ${response.status_code} 200
Log ${response.json()}


Delete Hive Policy
${response}= DELETE On Session ranger /service/public/v2/api/policy params=${QPARAMS}
Should Be Equal As Numbers ${response.status_code} 204

12 changes: 12 additions & 0 deletions dev-support/smoketests/ranger/apis/resources.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*** Settings ***
Library RequestsLibrary

*** Variables ***
${RANGER_HOST} localhost
${PORT} 6080
@{CREDS} admin rangerR0cks!

*** Keywords ***
Initialize Ranger Session (HTTP)
Create Session ranger http://${RANGER_HOST}:${PORT} auth=${CREDS}

8 changes: 8 additions & 0 deletions dev-support/smoketests/ranger/apis/session_management.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*** Settings ***
Resource resources.robot

*** Test Cases ***
Create Ranger Session
[Documentation] Establish a session with Ranger Admin
Initialize Ranger Session (HTTP)

12 changes: 12 additions & 0 deletions dev-support/smoketests/ranger/apis/user_management.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*** Settings ***
Resource resources.robot
Suite Setup Initialize Ranger Session (HTTP)

*** Variables ***

*** Test Cases ***
Get All Users
${response}= GET On Session ranger /service/xusers/users
Should Be Equal As Numbers ${response.status_code} 200
Log ${response.json()}

0 comments on commit 3790cc1

Please sign in to comment.