Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

question about execution on the group testcases #158

Open
liPaozi opened this issue Dec 29, 2014 · 3 comments
Open

question about execution on the group testcases #158

liPaozi opened this issue Dec 29, 2014 · 3 comments

Comments

@liPaozi
Copy link

liPaozi commented Dec 29, 2014

Hi all
When I want to choose some cases from multiple testcases directory ,what should I add before the the case subclass ,then the framwork will run the flag cases.

example about my case:
class ceth_ping_test(base_tests.BaseTest):
"""
Type:TEST_CASE
Test ceth ping function
Simply verify by output of ping
"""
def runTest(self):
logging.info("Running " + str(self))
case_name = self.class.name

    response_ping = ping_func()

    vm_check_flag = check_vm_crash_function()
    if vm_check_flag != 0 and vm_check_flag != 4 :
       crash_flag = vm_crash_info_aggregation(case_name,vm_check_flag,phy_node_dir='/usr/vm_crash')
       self.assertEqual(crash_flag,0, "[ERROR]VM crash.VM_crash clollection failed.")
       mesg_recovery = vm_recovery()
       self.assertEqual(mesg_recovery,0, "[ERROR]VM crash.VM recovery failed.")

    self.assertEqual(vm_check_flag, 4, "[ERROR]VM crash. VM crash info is in the dir /usr/vm_crash/%s" %(case_name))

    self.assertEqual(response_ping, "1", "[ERROR]The ping Operation from the SRC node to the DST node!")

also whether there will be another could solve the problem I could get the some cases as my sanity cases?I have found the involved code lines as following:
file/testutils.py:
def nonstandard(cls):
"""
Testcase decorator that marks the test as being non-standard.
These tests are not automatically added to the "standard" group.
"""
cls._nonstandard = True
return cls

def disabled(cls):
"""
Testcase decorator that marks the test as being disabled.
These tests are not automatically added to the "standard" group or
their module's group.
"""
cls._disabled = True
return cls

def group(name):
"""
Testcase decorator that adds the test to a group.
"""
def fn(cls):
if not hasattr(cls, "_groups"):
cls._groups = []
cls._groups.append(name)
return cls
return fn

in the oft function load_test_module:
if tests:
for (testname, test) in tests.items():
# Set default annotation values
if not hasattr(test, "_groups"):
test._groups = []
if not hasattr(test, "_nonstandard"):
test._nonstandard = False
if not hasattr(test, "_disabled"):
test._disabled = False

                # Put test in its module's test group
                if not test._disabled:
                    test._groups.append(modname)

                # Put test in the standard test group
                if not test._disabled and not test._nonstandard:
                    test._groups.append("standard")
                    test._groups.append("all") # backwards compatibility

            result[modname] = (mod, tests)

Thanks
Yiting.Li

@capveg
Copy link

capveg commented Dec 29, 2014

Apologies, but I don't think I understand your email. Are you trying to
get your test cases run by default?

  • Rob
    .

On Mon, Dec 29, 2014 at 5:11 AM, liPaozi [email protected] wrote:

Hi all
When I want to choose some cases from multiple testcases directory ,what
should I add before the the case subclass ,then the framwork will run the
flag cases.

example about my case:
class ceth_ping_test(base_tests.BaseTest):
"""
Type:TEST_CASE
Test ceth ping function
Simply verify by output of ping
"""
def runTest(self):
logging.info("Running " + str(self))
case_name = self.class.name

response_ping = ping_func()

vm_check_flag = check_vm_crash_function()
if vm_check_flag != 0 and vm_check_flag != 4 :
   crash_flag = vm_crash_info_aggregation(case_name,vm_check_flag,phy_node_dir='/usr/vm_crash')
   self.assertEqual(crash_flag,0, "[ERROR]VM crash.VM_crash clollection failed.")
   mesg_recovery = vm_recovery()
   self.assertEqual(mesg_recovery,0, "[ERROR]VM crash.VM recovery failed.")

self.assertEqual(vm_check_flag, 4, "[ERROR]VM crash. VM crash info is in the dir /usr/vm_crash/%s" %(case_name))

self.assertEqual(response_ping, "1", "[ERROR]The ping Operation from the SRC node to the DST node!")

also whether there will be another could solve the problem I could get the
some cases as my sanity cases?I have found the involved code lines as
following:
file/testutils.py:
def nonstandard(cls):
"""
Testcase decorator that marks the test as being non-standard.
These tests are not automatically added to the "standard" group.
"""
cls._nonstandard = True
return cls

def disabled(cls):
"""
Testcase decorator that marks the test as being disabled.
These tests are not automatically added to the "standard" group or
their module's group.
"""
cls._disabled = True
return cls

def group(name):
"""
Testcase decorator that adds the test to a group.
"""
def fn(cls):
if not hasattr(cls, "_groups"):
cls._groups = []
cls._groups.append(name)
return cls
return fn

in the oft function load_test_module:
if tests:
for (testname, test) in tests.items():

Set default annotation values

if not hasattr(test, "_groups"):
test._groups = []
if not hasattr(test, "_nonstandard"):
test._nonstandard = False
if not hasattr(test, "_disabled"):
test._disabled = False

            # Put test in its module's test group
            if not test._disabled:
                test._groups.append(modname)

            # Put test in the standard test group
            if not test._disabled and not test._nonstandard:
                test._groups.append("standard")
                test._groups.append("all") # backwards compatibility

        result[modname] = (mod, tests)

Thanks
Yiting.Li


Reply to this email directly or view it on GitHub
#158.

@liPaozi
Copy link
Author

liPaozi commented Dec 30, 2014

Hi Rob!

I was using the oft ,and I do not know whether the oft supports to run some special cases from my default cases file as my sanity cases automatically,I found the test group featrue in the main function of the file ./oft, How Can I configure on the special cases class?so I can run the designated cases

@liPaozi
Copy link
Author

liPaozi commented Dec 30, 2014

runnig the designated cases,not all cases in the cases file *.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants