Skip to content

Commit

Permalink
fixing katello-cli tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lzap committed Aug 8, 2011
1 parent 09ea882 commit b7d33f1
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 72 deletions.
6 changes: 4 additions & 2 deletions cli/src/katello/client/core/utils.py
Expand Up @@ -456,13 +456,15 @@ def run_async_task_with_status(taskStatus, progressBar):
while len(filter(lambda t: t['state'] not in ('finished', 'error', 'timed out', 'canceled'), task)) > 0:
time.sleep(1)
task = [status_api.status(t['uuid']) for t in task]
overalProgress = sum([progress(t['progress']['size_left'], t['progress']['size_total']) for t in task]) / len(task)
total = t['progress']['size_total'] if t['progress'].has_key('size_total') else 999999999999
overalProgress = sum([progress(t['progress']['size_left'], total) for t in task]) / len(task)
progressBar.updateProgress(overalProgress)
else:
while task['state'] not in ('finished', 'error', 'timed out', 'canceled'):
time.sleep(1)
task = status_api.status(task['uuid'])
progressBar.updateProgress(progress(task['progress']['size_left'], task['progress']['size_total']))
total = task['progress']['size_total'] if task['progress'].has_key('size_total') else 999999999999
progressBar.updateProgress(progress(task['progress']['size_left'], total))

progressBar.done()
return task
Expand Down
2 changes: 2 additions & 0 deletions scripts/test/cli_tests/05_provider_sync.sh
@@ -0,0 +1,2 @@
# testing provider sync
test "provider sync" provider synchronize --name="$YUM_PROVIDER" --org="$FIRST_ORG"
8 changes: 8 additions & 0 deletions scripts/test/cli_tests/10_repo.sh
@@ -0,0 +1,8 @@
#testing repositories
test "repo list by org and env" repo list --org="$FIRST_ORG" --environment="$TEST_ENV"
test "repo list by org only" repo list --org="$FIRST_ORG"
test "repo list by org and product" repo list --org="$FIRST_ORG" --product="$FEWUPS_PRODUCT"
REPO_NAME=`$CMD repo list --org="$FIRST_ORG" | grep $FEWUPS_REPO | awk '{print $2}'`
REPO_ID=`$CMD repo list --org="$FIRST_ORG" | grep $FEWUPS_REPO | awk '{print $1}'`
test "repo status for $REPO_ID" repo status --id="$REPO_ID"
test "repo synchronize for $REPO_ID" repo synchronize --id="$REPO_ID"
6 changes: 2 additions & 4 deletions scripts/test/cli_tests/_base_cleanup.sh
@@ -1,14 +1,12 @@
#!/bin/bash


#clear
#test "repo delete" repo delete # <-- not implemented yet
#test "product delete" product delete # <-- not implemented yet
skip_test "repo delete" "not yet implemented" repo delete --product="$FEWUPS_PRODUCT" --org="$FIRST_ORG" --name="$FEWUPS_REPO"
skip_test "product delete" "not yet implemented" product delete --provider="$YUM_PROVIDER" --org="$FIRST_ORG" --name="$FEWUPS_PRODUCT"
test "provider delete" provider delete --name="$YUM_PROVIDER" --org="$FIRST_ORG"
test "environment delete" environment delete --name="$TEST_ENV" --org="$FIRST_ORG"
test "environment delete" environment delete --name="$TEST_ENV_3" --org="$FIRST_ORG"
test "org delete" org delete --name="$TEST_ORG"
test "user delete" user delete --username="$TEST_USER"

summarize

59 changes: 12 additions & 47 deletions scripts/test/cli_tests/_base_setup.sh
@@ -1,59 +1,24 @@
#!/bin/bash


#testing ping
test "ping" ping

#testing user
TEST_USER="user_$RAND"
test "user create" user create --username=$TEST_USER --password=password
test "user update" user update --username=$TEST_USER --password=password
test "user list" user list
test "user info" user info --username=$TEST_USER

#testing organization
# DEFAULT GLOBAL VARIABLES
FIRST_ORG=ACME_Corporation
TEST_USER="user_$RAND"
TEST_ORG="org_$RAND"
test "org create" org create --name=$TEST_ORG --description="org description"
test "org update" org update --name=$TEST_ORG --description="org description 2"
test "org list" org list
test "org info" org info --name=$TEST_ORG

#testing environments
TEST_ENV="env_$RAND"
TEST_ENV_2="env_2_$RAND"
TEST_ENV_3="env_3_$RAND"
test "environment create" environment create --org="$FIRST_ORG" --name="$TEST_ENV" --prior="Locker"
test "environment create" environment create --org="$FIRST_ORG" --name="$TEST_ENV_2" --prior="$TEST_ENV"
test "environment update" environment update --org="$FIRST_ORG" --name="$TEST_ENV_2" --new_name="$TEST_ENV_3"
test "environment list" environment list --org="$FIRST_ORG"
test "environment info" environment info --org="$FIRST_ORG" --name="$TEST_ENV"

#testing provider
YUM_PROVIDER="yum_provider_$RAND"
FEWUPS_REPO="http://lzap.fedorapeople.org/fakerepos/"
FEWUPS_REPO_2="http://lzap.fedorapeople.org/fakerepos/2/"
test "provider create" provider create --name="$YUM_PROVIDER" --org="$FIRST_ORG" --type=yum --url="$FEWUPS_REPO" --description="prov description"
test "provider update" provider update --name="$YUM_PROVIDER" --org="$FIRST_ORG" --url="$FEWUPS_REPO_2" --description="prov description 2"
test "provider list" provider list --org="$FIRST_ORG"
test "provider info" provider info --name="$YUM_PROVIDER" --org="$FIRST_ORG"

#testing products
FEWUPS_REPO_URL="http://lzap.fedorapeople.org/fakerepos/"
FEWUPS_PRODUCT="fewups_product_$RAND"
test "product create" product create --provider="$YUM_PROVIDER" --org="$FIRST_ORG" --name="$FEWUPS_PRODUCT" --url="$FEWUPS_REPO"
test "product list by org and env" product list --org="$FIRST_ORG" --environment="$TEST_ENV" --provider="$YUM_PROVIDER"
test "product list by org only" product list --org="$FIRST_ORG"
test "product list by org and provider" product list --org="$FIRST_ORG" --provider="$YUM_PROVIDER"

#testing repositories
REPO="repo_$RAND"
test "repo create" repo create --product="$FEWUPS_PRODUCT" --org="$FIRST_ORG" --name="$REPO" --url="$FEWUPS_REPO" --assumeyes
test "repo list by org and env" repo list --org="$FIRST_ORG" --environment="$TEST_ENV"
test "repo list by org only" repo list --org="$FIRST_ORG"
test "repo list by org and product" repo list --org="$FIRST_ORG" --product="$FEWUPS_PRODUCT"
REPO_NAME=`$CMD repo list --org="$FIRST_ORG" | grep $REPO | grep -i name | awk '{print $2}'`
REPO_ID=`$CMD repo list --org="$FIRST_ORG" | grep $REPO | grep -i id | awk '{print $2}'`
test "repo status" repo status --id="$REPO_ID"
test "repo synchronize" repo synchronize --id="$REPO_ID"

FEWUPS_REPO="repo_$RAND"

# BASIC RESOURCES (reused in tests)
test "user create" user create --username=$TEST_USER --password=password
test "org create" org create --name=$TEST_ORG --description="org description"
test "environment create" environment create --org="$FIRST_ORG" --name="$TEST_ENV" --prior="Locker"
test "environment create" environment create --org="$FIRST_ORG" --name="$TEST_ENV_3" --prior="$TEST_ENV"
test "provider create" provider create --name="$YUM_PROVIDER" --org="$FIRST_ORG" --type=yum --url="$FEWUPS_REPO_URL" --description="prov description"
test "product create" product create --provider="$YUM_PROVIDER" --org="$FIRST_ORG" --name="$FEWUPS_PRODUCT" --url="$FEWUPS_REPO_URL"
test "repo create" repo create --product="$FEWUPS_PRODUCT" --org="$FIRST_ORG" --name="$FEWUPS_REPO" --url="$FEWUPS_REPO_URL" --assumeyes
7 changes: 7 additions & 0 deletions scripts/test/cli_tests/env.sh
@@ -0,0 +1,7 @@
ENV="tstenv_$RAND"
ENV2="tstenv2_$RAND"
test "environment create" environment create --org="$FIRST_ORG" --name="$ENV" --prior="Locker"
test "environment update" environment update --org="$FIRST_ORG" --name="$ENV" --new_name="$ENV2"
test "environment list" environment list --org="$FIRST_ORG"
test "environment info" environment info --org="$FIRST_ORG" --name="$ENV2"
test "environment delete" environment delete --org="$FIRST_ORG" --name="$ENV2"
3 changes: 3 additions & 0 deletions scripts/test/cli_tests/org.sh
@@ -0,0 +1,3 @@
test "org update" org update --name=$TEST_ORG --description="org description 2"
test "org list" org list
test "org info" org info --name=$TEST_ORG
4 changes: 4 additions & 0 deletions scripts/test/cli_tests/product.sh
@@ -0,0 +1,4 @@
#testing products
test "product list by org and env" product list --org="$FIRST_ORG" --environment="$TEST_ENV" --provider="$YUM_PROVIDER"
test "product list by org only" product list --org="$FIRST_ORG"
test "product list by org and provider" product list --org="$FIRST_ORG" --provider="$YUM_PROVIDER"
18 changes: 4 additions & 14 deletions scripts/test/cli_tests/provider.sh
@@ -1,16 +1,6 @@
#!/bin/bash

DIR="$( cd "$( dirname "$0" )" && pwd )"

# testing provider sync
test "provider sync" provider synchronize --name="$YUM_PROVIDER" --org="$FIRST_ORG"

# importing manifest from our testing export
#testing organization
IMPORT_ORG="Import_Org_$RAND"
IMPORT_PROV="Import_Prov_$RAND"
test "org create" org create --name=$IMPORT_ORG
test "provider create" provider create --org="$IMPORT_ORG" --name="$IMPORT_PROV" --type=redhat --url="https://example.com/path/"
test "provider import_manifest" provider import_manifest --org="$IMPORT_ORG" --name="$IMPORT_PROV" --file=$DIR/export-manifest.zip
test "provider delete" provider delete --org="$IMPORT_ORG" --name="$IMPORT_PROV"
test "org delete" org delete --name=$IMPORT_ORG
#testing provider
test "provider update" provider update --name="$YUM_PROVIDER" --org="$FIRST_ORG" --description="prov description blah 2"
test "provider list" provider list --org="$FIRST_ORG"
test "provider info" provider info --name="$YUM_PROVIDER" --org="$FIRST_ORG"
12 changes: 12 additions & 0 deletions scripts/test/cli_tests/provider_import.sh
@@ -0,0 +1,12 @@
#!/bin/bash

DIR="$( cd "$( dirname "$0" )" && pwd )"

# importing manifest from our testing export
IMPORT_ORG="Import_Org_$RAND"
IMPORT_PROV="Import_Prov_$RAND"
test "org create" org create --name=$IMPORT_ORG
test "provider create" provider create --org="$IMPORT_ORG" --name="$IMPORT_PROV" --type=redhat --url="https://example.com/path/"
test "provider import_manifest" provider import_manifest --org="$IMPORT_ORG" --name="$IMPORT_PROV" --file=$DIR/export-manifest.zip
test "provider delete" provider delete --org="$IMPORT_ORG" --name="$IMPORT_PROV"
test "org delete" org delete --name=$IMPORT_ORG
2 changes: 1 addition & 1 deletion scripts/test/cli_tests/rhsm.sh
@@ -1,7 +1,7 @@
#!/bin/bash

# testing registration from rhsm
(which subscription-manager >/dev/null && \
(which subscription-manager 2>/dev/null && \
test_own_cmd "rhsm registration" sudo subscription-manager register --username=$USER --password=$PASSWORD \
--org=$FIRST_ORG --environment=$TEST_ENV_3 --name=$HOSTNAME --force) || \
skip_test "rhsm registration" "subscription-manager command not found"
1 change: 0 additions & 1 deletion scripts/test/cli_tests/system.sh
@@ -1,6 +1,5 @@
#!/bin/bash


# testing systems
SYSTEM_NAME_ADMIN="admin_system_$RAND"
SYSTEM_NAME_ADMIN_2=$SYSTEM_NAME_ADMIN"_2"
Expand Down
4 changes: 4 additions & 0 deletions scripts/test/cli_tests/user.sh
@@ -0,0 +1,4 @@
#testing user
test "user update" user update --username=$TEST_USER --password=password
test "user list" user list
test "user info" user info --username=$TEST_USER
8 changes: 5 additions & 3 deletions scripts/test/katello-cli-simple-test.sh
Expand Up @@ -23,7 +23,7 @@ txtgrn=$(tput setaf 2) # Green
txtyel=$(tput setaf 3) # Yellow
txtrst=$(tput sgr0) # Text reset

all_tests=`ls $script_dir/cli_tests/ | grep -v _.* | sed -s 's/.sh//g'`
all_tests=`ls $script_dir/cli_tests/ | grep -v '^_.*' | sed -s 's/^[0-9]*_//g' | sed -s 's/.sh//g'`
required_tests=""

PRINT_ALL=0
Expand Down Expand Up @@ -66,7 +66,7 @@ done
if [ $TEST_ALL -eq 1 ]; then
required_tests=$all_tests
fi
echo $required_tests
#echo $required_tests

function skip_test() {
printf "%-40s" "$1"
Expand Down Expand Up @@ -149,7 +149,9 @@ function valid_id() {

. $script_dir/cli_tests/_base_setup.sh
for t in $required_tests; do
. $script_dir/cli_tests/$t.sh
echo "Test suite $t"
[ -f $script_dir/cli_tests/[0-9]*$t.sh ] && . $script_dir/cli_tests/[0-9]*$t.sh
[ -f $script_dir/cli_tests/$t.sh ] && . $script_dir/cli_tests/*$t.sh
done

. $script_dir/cli_tests/_base_cleanup.sh
Expand Down

0 comments on commit b7d33f1

Please sign in to comment.