Files
drydock/tests/integration/postgres/test_api_bootaction_status.py
Scott Hussey ae87cd1714 Update image and chart mgmt
NOTE: This has become a monolithic commit to get gate
      settings/scripts in place for CI

- Add Makefile with UCP standard entrypoints
- Move Dockerfile into images/drydock per UCP standards
- Add values.yaml entries for uWSGI threads and workers
- Add environment variables to chart Deployment manifest
  for uWSGI thread and workers
- Add threads and workers specification to uWSGI commandline
  in entrypoint
- Test that the Drydock API is responding
- Test that the Drydock API rejects noauth requests
- Fix Makefile utility script to work behind a proxy

Correct task success voting

Some tasks were incorrectly considered partial_success even when
no failure occurred.

- Network configuration erroneously marked messages as errors
- Update result propagation logic to only use the latest retry

The deploy_nodes task ended as incomplete due to a missing
subtask assignment

Also added a node check step to prepare_nodes so that nodes that
are already under provisioner control (MaaS) are not IPMI-rebooted.

Tangential changes:
- added config item to for leadership claim interval
- added some debug logging to bootaction_report task
- fix tasks list API endpoint to generate valid JSON

Improve task concurrency

When tasks are started with a scope of multiple nodes,
split the main task so each node is managed independently
to de-link the progression of nodes.

- Split the prepare_nodes task
- Begin reducing cyclomatic complexity to allow for
  better unit testing
- Improved tox testing to include coverage by default
- Include postgresql integration tests in coverage

Closes #73

Change-Id: I600c2a4db74dd42e809bc3ee499fb945ebdf31f6
2017-12-15 15:33:14 -06:00

125 lines
4.2 KiB
Python

# Copyright 2017 AT&T Intellectual Property. All other 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.
"""Generic testing for the orchestrator."""
from falcon import testing
import pytest
import os
import json
import ulid2
import falcon
import drydock_provisioner.objects.fields as hd_fields
from drydock_provisioner.control.api import start_api
class TestClass(object):
def test_bootaction_detail(self, falcontest, seed_bootaction_status):
"""Test that the API allows boot action detail messages."""
url = "/api/v1.0/bootactions/%s" % seed_bootaction_status['action_id']
hdr = {
'X-Bootaction-Key': "%s" % seed_bootaction_status['identity_key'],
'Content-Type': 'application/json',
}
body = {
'details': [
{
'message': 'Test message.',
'error': True,
},
]
}
result = falcontest.simulate_post(
url, headers=hdr, body=json.dumps(body))
assert result.status == falcon.HTTP_200
def test_bootaction_status(self, falcontest, seed_bootaction_status):
"""Test that the API allows boot action status updates."""
url = "/api/v1.0/bootactions/%s" % seed_bootaction_status['action_id']
hdr = {
'X-Bootaction-Key': "%s" % seed_bootaction_status['identity_key'],
'Content-Type': 'application/json',
}
body = {
'status': 'Success',
'details': [
{
'message': 'Test message.',
'error': True,
},
]
}
result = falcontest.simulate_post(
url, headers=hdr, body=json.dumps(body))
assert result.status == falcon.HTTP_200
result = falcontest.simulate_post(
url, headers=hdr, body=json.dumps(body))
assert result.status == falcon.HTTP_409
def test_bootaction_schema(self, falcontest, seed_bootaction_status):
"""Test that the API allows boot action status updates."""
url = "/api/v1.0/bootactions/%s" % seed_bootaction_status['action_id']
hdr = {
'X-Bootaction-Key': "%s" % seed_bootaction_status['identity_key'],
'Content-Type': 'application/json',
}
body = {
'foo': 'Success',
}
result = falcontest.simulate_post(
url, headers=hdr, body=json.dumps(body))
assert result.status == falcon.HTTP_400
@pytest.fixture()
def seed_bootaction_status(self, blank_state, yaml_orchestrator,
input_files):
"""Add a task and boot action to the database for testing."""
input_file = input_files.join("fullsite.yaml")
design_ref = "file://%s" % input_file
test_task = yaml_orchestrator.create_task(
action=hd_fields.OrchestratorAction.Noop, design_ref=design_ref)
id_key = os.urandom(32)
action_id = ulid2.generate_binary_ulid()
blank_state.post_boot_action('compute01',
test_task.get_id(), id_key, action_id,
'helloworld')
ba = dict(
nodename='compute01',
task_id=test_task.get_id(),
identity_key=id_key.hex(),
action_id=ulid2.encode_ulid_base32(action_id))
return ba
@pytest.fixture()
def falcontest(self, drydock_state, yaml_ingester, yaml_orchestrator):
"""Create a test harness for the the Falcon API framework."""
return testing.TestClient(
start_api(
state_manager=drydock_state,
ingester=yaml_ingester,
orchestrator=yaml_orchestrator))