Merge "Add a page for release 16.1 to release notes"
diff --git a/releasenotes/notes/identity_client-635275d43abbb807.yaml b/releasenotes/notes/identity_client-635275d43abbb807.yaml
new file mode 100644
index 0000000..6f984b7
--- /dev/null
+++ b/releasenotes/notes/identity_client-635275d43abbb807.yaml
@@ -0,0 +1,5 @@
+---
+features:
+ - |
+ Enhances the v3 identity client with the ``check_token_existence``
+ endpoint, allowing users to check the existence of tokens
diff --git a/tempest/api/identity/admin/v3/test_tokens.py b/tempest/api/identity/admin/v3/test_tokens.py
index 1acc67d..5c3cd26 100644
--- a/tempest/api/identity/admin/v3/test_tokens.py
+++ b/tempest/api/identity/admin/v3/test_tokens.py
@@ -39,6 +39,7 @@
resp = self.token.auth(user_id=user['id'],
password=u_password).response
subject_token = resp['x-subject-token']
+ self.client.check_token_existence(subject_token)
# Perform GET Token
token_details = self.client.show_token(subject_token)['token']
self.assertEqual(resp['x-subject-token'], subject_token)
@@ -46,7 +47,7 @@
self.assertEqual(token_details['user']['name'], u_name)
# Perform Delete Token
self.client.delete_token(subject_token)
- self.assertRaises(lib_exc.NotFound, self.client.show_token,
+ self.assertRaises(lib_exc.NotFound, self.client.check_token_existence,
subject_token)
@decorators.idempotent_id('565fa210-1da1-4563-999b-f7b5b67cf112')
diff --git a/tempest/lib/services/identity/v3/identity_client.py b/tempest/lib/services/identity/v3/identity_client.py
index 755c14b..2512a3e 100644
--- a/tempest/lib/services/identity/v3/identity_client.py
+++ b/tempest/lib/services/identity/v3/identity_client.py
@@ -44,6 +44,13 @@
self.expected_success(204, resp.status)
return rest_client.ResponseBody(resp, body)
+ def check_token_existence(self, resp_token):
+ """Validates a token."""
+ headers = {'X-Subject-Token': resp_token}
+ resp, body = self.head("auth/tokens", headers=headers)
+ self.expected_success(200, resp.status)
+ return rest_client.ResponseBody(resp, body)
+
def list_auth_projects(self):
"""Get available project scopes."""
resp, body = self.get("auth/projects")
diff --git a/tempest/tests/lib/services/identity/v3/test_identity_client.py b/tempest/tests/lib/services/identity/v3/test_identity_client.py
index e435fe2..6572947 100644
--- a/tempest/tests/lib/services/identity/v3/test_identity_client.py
+++ b/tempest/tests/lib/services/identity/v3/test_identity_client.py
@@ -109,6 +109,14 @@
resp_token="cbc36478b0bd8e67e89",
status=204)
+ def test_check_token_existence(self):
+ self.check_service_client_function(
+ self.client.check_token_existence,
+ 'tempest.lib.common.rest_client.RestClient.head',
+ {},
+ resp_token="cbc36478b0bd8e67e89",
+ status=200)
+
def test_list_auth_projects_with_str_body(self):
self._test_list_auth_projects()
diff --git a/tools/tempest-plugin-sanity.sh b/tools/tempest-plugin-sanity.sh
new file mode 100644
index 0000000..a4f706e
--- /dev/null
+++ b/tools/tempest-plugin-sanity.sh
@@ -0,0 +1,122 @@
+#!/usr/bin/env bash
+
+# Copyright 2017 Red Hat, Inc.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+# This script is intended to check the sanity of tempest plugins against
+# tempest master.
+# What it does:
+# * Creates the virtualenv
+# * Install tempest
+# * Retrive the project lists having tempest plugin if project name is
+# given.
+# * For each project in a list, It does:
+# * Clone the Project
+# * Install the Project and also installs dependencies from
+# test-requirements.txt.
+# * Create Tempest workspace
+# * List tempest plugins
+# * List tempest plugins tests
+# * Uninstall the project and its dependencies
+# * Again Install tempest
+# * Again repeat the step from cloning project
+#
+# If one of the step fails, The script will exit with failure.
+
+if [ "$1" == "-h" ]; then
+ echo -e "This script performs the sanity of tempest plugins to find
+configuration and dependency issues with the tempest.\n
+Usage: sh ./tools/tempest-plugin-sanity.sh [Run sanity on tempest plugins]"
+ exit 0
+fi
+
+set -ex
+
+# retrieve a list of projects having tempest plugins
+PROJECT_LIST="$(python tools/generate-tempest-plugins-list.py)"
+# List of projects having tempest plugin stale or unmaintained from long time
+BLACKLIST="trio2o"
+
+# Function to clone project using zuul-cloner or from git
+function clone_project() {
+ if [ -e /usr/zuul-env/bin/zuul-cloner ]; then
+ /usr/zuul-env/bin/zuul-cloner --cache-dir /opt/git \
+ git://git.openstack.org \
+ openstack/"$1"
+
+ elif [ -e /usr/bin/git ]; then
+ /usr/bin/git clone git://git.openstack.org/openstack/"$1" \
+ openstack/"$1"
+
+ fi
+}
+
+# Create virtualenv to perform sanity operation
+SANITY_DIR=$(pwd)
+virtualenv "$SANITY_DIR"/.venv
+export TVENV="$SANITY_DIR/tools/with_venv.sh"
+cd "$SANITY_DIR"
+
+# Install tempest in a venv
+"$TVENV" pip install .
+
+# Function to install project
+function install_project() {
+ "$TVENV" pip install "$SANITY_DIR"/openstack/"$1"
+ # Check for test-requirements.txt file in a project then install it.
+ if [ -e "$SANITY_DIR"/openstack/"$1"/test-requirements.txt ]; then
+ "$TVENV" pip install -r "$SANITY_DIR"/openstack/"$1"/test-requirements.txt
+ fi
+}
+
+# Function to perform sanity checking on Tempest plugin
+function tempest_sanity() {
+ "$TVENV" tempest init "$SANITY_DIR"/tempest_sanity
+ cd "$SANITY_DIR"/tempest_sanity
+ "$TVENV" tempest list-plugins
+ "$TVENV" tempest run -l
+ # Delete tempest workspace
+ "$TVENV" tempest workspace remove --name tempest_sanity --rmdir
+ cd "$SANITY_DIR"
+}
+
+# Function to uninstall project
+function uninstall_project() {
+ "$TVENV" pip uninstall -y "$SANITY_DIR"/openstack/"$1"
+ # Check for *requirements.txt file in a project then uninstall it.
+ if [ -e "$SANITY_DIR"/openstack/"$1"/*requirements.txt ]; then
+ "$TVENV" pip uninstall -y -r "$SANITY_DIR"/openstack/"$1"/*requirements.txt
+ fi
+ # Remove the project directory after sanity run
+ rm -fr "$SANITY_DIR"/openstack/"$1"
+}
+
+# Function to run sanity check on each project
+function plugin_sanity_check() {
+ clone_project "$1" && install_project "$1" && tempest_sanity "$1" \
+ && uninstall_project "$1" && "$TVENV" pip install .
+}
+
+# Log status
+passed_plugin=''
+failed_plugin=''
+# Perform sanity on all tempest plugin projects
+for project in $PROJECT_LIST; do
+ # Remove blacklisted tempest plugins
+ if ! [[ `echo $BLACKLIST | grep -c $project ` -gt 0 ]]; then
+ plugin_sanity_check $project && passed_plugin+=", $project" || \
+ failed_plugin+=", $project"
+ fi
+done
diff --git a/tox.ini b/tox.ini
index 892f834..2120818 100644
--- a/tox.ini
+++ b/tox.ini
@@ -185,3 +185,9 @@
# separately, outside of the requirements files.
deps = bindep
commands = bindep test
+
+[testenv:plugin-sanity-check]
+# perform tempest plugin sanity
+whitelist_externals = bash
+commands =
+ bash tools/tempest-plugin-sanity.sh