Skip to content

Commit

Permalink
Merge pull request #47 from skanthed/functional-node-list-test
Browse files Browse the repository at this point in the history
Functional test for node list
  • Loading branch information
tzumainn authored Mar 3, 2023
2 parents 9d5ea74 + 411d27f commit 238feb4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
7 changes: 7 additions & 0 deletions esileapclient/tests/functional/utils/esi_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ def offer_claim(client, offer_uuid, parse=True, fail_ok=False, **kwargs):
fail_ok=fail_ok)


def node_list(client, parse=True, fail_ok=False, **kwargs):
valid_flags = ('long')
return _execute(client, cmd='node list', valid_flags=valid_flags,
kwargs=kwargs, args=(), parse=parse,
fail_ok=fail_ok)


def lease_create(client, node_uuid, lessee, parse=True, fail_ok=False,
**kwargs):
valid_flags = ('resource_type', 'start_time', 'end_time',
Expand Down
39 changes: 39 additions & 0 deletions esileapclient/tests/functional/v1/test_basic.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest
import unittest
import os
from tempest.lib.exceptions import CommandFailed
from tempest.lib.common.utils import data_utils

Expand Down Expand Up @@ -213,6 +215,43 @@ def test_lease_show_offer_deleted(self):
details = esi.lease_show(self.clients['child-lessee'], lease['uuid'])
self.assertEqual(details['status'], 'deleted')

@unittest.skipIf(list(map(lambda x: os.getenv('OS_FUNCTIONAL_NODE_%s' % x),
['NAME', 'UUID'])) == [None, None],
'Neither env variable OS_FUNCTIONAL_NODE_UUID \
nor OS_FUNCTIONAL_NODE_NAME is set')
def test_node_list_long(self):
""" Tests functionality "esi node list" using node_uuid or node name.
checks node_uuid or node_name is present in node list or not.
Test steps:
1) Set either of the environment variables using
export OS_FUNCTIONAL_NODE_UUID=node_uuid or
export OS_FUNCTIONAL_NODE_NAME=node_name
2) Checks that the output of "node list" contains
the node uuid or node name it's tested with. """
node_uuid = os.getenv('OS_FUNCTIONAL_NODE_UUID')
node_name = os.getenv('OS_FUNCTIONAL_NODE_NAME')
listings = esi.node_list(self.clients['admin'], long=True)
self.assertNotEqual(listings, [])
if node_uuid is not None:
self.assertIn(node_uuid, [x['UUID'] for x in listings])
if node_name is not None:
self.assertIn(node_name, [x['Name'] for x in listings])

@unittest.skipIf('OS_FUNCTIONAL_NODE_NAME' not in os.environ.keys(),
'Environment variable OS_FUNCTIONAL_NODE_NAME not set')
def test_node_list_basic(self):
""" Tests basic functionality of "esi node list" when default behavior
is invoked. Checks if node_name is present in node list.
Test steps:
1) Set the environment variable using
export OS_FUNCTIONAL_NODE_IDENT_NAME=node_name
2) Checks that the output of "node list" contains
the node name it's tested with. """
node_name = os.getenv('OS_FUNCTIONAL_NODE_IDENT_NAME')
listings = esi.node_list(self.clients['admin'])
self.assertNotEqual(listings, [])
self.assertIn(node_name, [x['Name'] for x in listings])

@pytest.mark.negative
def test_offer_show_invalid_id(self):
""" Tests that "esi offer show" properly handles being passed an
Expand Down

0 comments on commit 238feb4

Please sign in to comment.