Update help docs for actions in Shipyard Client
- Adds the information related to the test_site action. - Reformats, slightly, the output from 'shipyard help actions' - Adds tests that use an externalized list of actions to keep the help documentation in alignment with the actions supported in the API. Change-Id: I2efd473da0dbf6c8cbadfc9fae575c303996c43b
This commit is contained in:
parent
f1c193a232
commit
fe87c64f97
@ -23,6 +23,7 @@ from falcon import testing
|
||||
from oslo_config import cfg
|
||||
import pytest
|
||||
import responses
|
||||
import yaml
|
||||
|
||||
from shipyard_airflow.common.notes.notes import NotesManager
|
||||
from shipyard_airflow.common.notes.notes_helper import NotesHelper
|
||||
@ -48,6 +49,23 @@ CONF = cfg.CONF
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _get_actions_list():
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
a_path = dir_path.split('src/bin')[0] + "src/bin/supported_actions.yaml"
|
||||
with open(a_path, 'r') as stream:
|
||||
try:
|
||||
action_list = yaml.safe_load(stream)['actions']
|
||||
if not action_list:
|
||||
raise FileNotFoundError("Action list is empty")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("This test requires that the file at '{}' is a valid yaml "
|
||||
"file containing a list of action names at a key of "
|
||||
"'actions'".format(a_path))
|
||||
assert False
|
||||
return action_list
|
||||
|
||||
|
||||
def get_token():
|
||||
"""Stub method to use for NotesHelper/NotesManager"""
|
||||
return "token"
|
||||
@ -238,6 +256,19 @@ def conf_fixture(request):
|
||||
context = ShipyardRequestContext()
|
||||
|
||||
|
||||
def test_actions_all_in_list():
|
||||
"""Test that all actions are in alignment with supported list
|
||||
Compares the action mappings structure with the externalized list of
|
||||
supported actions, allowing for better alignment with the client
|
||||
"""
|
||||
mappings = actions_api._action_mappings()
|
||||
actions = _get_actions_list()
|
||||
for action in actions:
|
||||
assert action in mappings
|
||||
for action in mappings.keys():
|
||||
assert action in actions
|
||||
|
||||
|
||||
@mock.patch.object(ShipyardPolicy, 'authorize', return_value=True)
|
||||
@mock.patch.object(
|
||||
ActionsResource,
|
||||
|
@ -32,23 +32,34 @@ For information of the following topics, run shipyard help <topic>
|
||||
|
||||
def actions():
|
||||
return '''ACTIONS
|
||||
The workflow actions that may be invoked using Shipyard
|
||||
Workflow actions that may be invoked using Shipyard.
|
||||
|
||||
deploy_site: Triggers the initial deployment of a site using the latest
|
||||
committed configuration documents.
|
||||
deploy_site
|
||||
Triggers the initial deployment of a site using the latest committed
|
||||
configdocs.
|
||||
|
||||
update_site: Triggers the update to a deployment of a site, using the latest
|
||||
committed configuration documents.
|
||||
update_site
|
||||
Triggers the update to a deployment of a site, using the latest committed
|
||||
configdocs.
|
||||
|
||||
update_software: Starts an update that only exercises the software portion of
|
||||
the committed configuration documents.
|
||||
update_software
|
||||
Starts an update that only exercises the software portion of the committed
|
||||
configdocs.
|
||||
|
||||
redeploy_server: Using parameters to indicate which server(s), triggers a
|
||||
redeployment of servers to the last committed design and
|
||||
secrets.
|
||||
redeploy_server
|
||||
Using the --param="target_nodes=node1,node2" parameter to target server(s),
|
||||
triggers a redeployment of servers using the last committed configdocs.
|
||||
|
||||
relabel_nodes: Using parameters to indicate which server(s), updates the
|
||||
labels for those servers.
|
||||
relabel_nodes
|
||||
Using the --param="target_nodes=node1,node2" parameter to target server(s),
|
||||
updates the Kubernetes node labels for the nodes on those servers.
|
||||
|
||||
test_site
|
||||
Triggers the Helm tests for the site, using parameters to control the
|
||||
tests:
|
||||
--param="cleanup=true" to delete the test pods immediately after execution
|
||||
--param="release=release-name" to target a specific Helm release instead of
|
||||
all releases (the default if this parameter is not specified).
|
||||
'''
|
||||
|
||||
|
||||
|
@ -11,11 +11,29 @@
|
||||
# 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.
|
||||
import os
|
||||
|
||||
from click.testing import CliRunner
|
||||
import yaml
|
||||
|
||||
from shipyard_client.cli.help.commands import help
|
||||
|
||||
def _get_actions_list():
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
a_path = dir_path.split('src/bin')[0] + "src/bin/supported_actions.yaml"
|
||||
with open(a_path, 'r') as stream:
|
||||
try:
|
||||
action_list = yaml.safe_load(stream)['actions']
|
||||
if not action_list:
|
||||
raise FileNotFoundError("Action list is empty")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("This test requires that the file at '{}' is a valid yaml "
|
||||
"file containing a list of action names at a key of "
|
||||
"'actions'".format(a_path))
|
||||
assert False
|
||||
return action_list
|
||||
|
||||
|
||||
def test_help():
|
||||
"""test help with all options"""
|
||||
@ -27,6 +45,10 @@ def test_help():
|
||||
topic = 'actions'
|
||||
result = runner.invoke(help, [topic])
|
||||
assert 'ACTIONS' in result.output
|
||||
actions = _get_actions_list()
|
||||
for action in actions:
|
||||
# Assert that actions each have headers
|
||||
assert "\n{}\n".format(action) in result.output
|
||||
|
||||
topic = 'configdocs'
|
||||
result = runner.invoke(help, [topic])
|
||||
|
14
src/bin/supported_actions.yaml
Normal file
14
src/bin/supported_actions.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
# This file contains a list of supported actions that exists outside the
|
||||
# scope of both the client and API. This is tested in both the client and
|
||||
# the API to ensure that the actions in the API match the actions supported
|
||||
# in the help of the client. Because of this, it becomes another place that
|
||||
# has to be updated, but since it's tied to tests, the reminders to fix it
|
||||
# should be outweighed by the benefit.
|
||||
actions:
|
||||
- deploy_site
|
||||
- update_site
|
||||
- update_software
|
||||
- redeploy_server
|
||||
- relabel_nodes
|
||||
- test_site
|
||||
...
|
Loading…
Reference in New Issue
Block a user