Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from mfalesni/openstack-vm-error
Let us know about ERROR state during OS provisioning.
- Loading branch information
Showing
8 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.pyc | ||
.cache/ | ||
.coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
install: | ||
- "pip install -Ur requirements-test.txt" | ||
script: "py.test tests/ -v --cov mgmtsystem" | ||
after_success: | ||
- coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
MGMT_SYSTEM | ||
mgmtsystem - A simple virtualization client | ||
=========================================== | ||
|
||
[![Coverage Status](https://coveralls.io/repos/RedHatQE/mgmtsystem/badge.svg?branch=master&service=github)](https://coveralls.io/github/RedHatQE/mgmtsystem?branch=master) | ||
[![Build Status](https://travis-ci.org/RedHatQE/mgmtsystem.svg)](https://travis-ci.org/RedHatQE/mgmtsystem) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
-r ./requirements.txt | ||
|
||
pytest | ||
pytest-cov | ||
coveralls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# -*- coding: utf-8 -*- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Unit tests for Openstack client.""" | ||
import pytest | ||
|
||
from mgmtsystem import exceptions, openstack | ||
|
||
|
||
@pytest.fixture(scope="function") | ||
def provider(): | ||
os = openstack.OpenstackSystem(tenant=None, username=None, password=None, auth_url=None) | ||
return os | ||
|
||
|
||
class mkobj(object): | ||
def __init__(self, **d): | ||
self.__dict__ = d | ||
|
||
|
||
def test_vm_status_error_raises_with_fault(provider, monkeypatch): | ||
"""Check that if the Instance gets to the ERROR state, vm_status will let us know.""" | ||
def _find_instance_by_name(vm_name): | ||
return mkobj( | ||
status="ERROR", | ||
fault={"code": 500, "created": "2015-11-02T10:54:18Z", "details": "x", "message": "y"}) | ||
|
||
monkeypatch.setattr(provider, '_find_instance_by_name', _find_instance_by_name) | ||
|
||
with pytest.raises(exceptions.VMError): | ||
provider.vm_status("xyz") | ||
|
||
|
||
def test_vm_status_error_raises_without_fault(provider, monkeypatch): | ||
"""Check that if the Instance gets to the ERROR state, vm_status will let us know. | ||
With no fault field. | ||
""" | ||
def _find_instance_by_name(vm_name): | ||
return mkobj(status="ERROR") | ||
|
||
monkeypatch.setattr(provider, '_find_instance_by_name', _find_instance_by_name) | ||
|
||
with pytest.raises(exceptions.VMError): | ||
provider.vm_status("xyz") | ||
|
||
|
||
def test_vm_status_no_error(provider, monkeypatch): | ||
"""Check that if the Instance is not in error state, it works as usual.""" | ||
def _find_instance_by_name(vm_name): | ||
return mkobj(status="UP") | ||
|
||
monkeypatch.setattr(provider, '_find_instance_by_name', _find_instance_by_name) | ||
|
||
assert provider.vm_status("xyz") == "UP" |