tempest/api/orchestration/base.py: load_template() used a restrict path

Bug #1300597 reported by Qiu Hua Qiao
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tempest
Fix Released
Undecided
Qiu Hua Qiao

Bug Description

    def load_template(cls, name, ext='yaml'):
        loc = ["tempest", "api", "orchestration",
               "stacks", "templates", "%s.%s" % (name, ext)]
        fullpath = os.path.join(*loc)

        with open(fullpath, "r") as f:
            content = f.read()
            return content

The method restrict the template file in folder 'tempest/api/orchestration/stacks/templates/'
But if we run tempests in other path(like /root/), the case will failed with this error:
[Errno 2] No such file or directory: 'tempest/api/orchestration/stacks/templates/nova_keypair.json'

Stacktrace

Traceback (most recent call last):
  File "/usr/lib/python2.6/site-packages/nose/suite.py", line 208, in run
    self.setUp()
  File "/usr/lib/python2.6/site-packages/nose/suite.py", line 291, in setUp
    self.setupContext(ancestor)
  File "/usr/lib/python2.6/site-packages/nose/suite.py", line 314, in setupContext
    try_run(context, names)
  File "/usr/lib/python2.6/site-packages/nose/util.py", line 469, in try_run
    return func()
  File "/tmp/tempest/tempest/tempest/api/orchestration/stacks/test_nova_keypair_resources.py", line 32, in setUpClass
    template = cls.load_template('nova_keypair', ext=cls._tpl_type)
  File "/tmp/tempest/tempest/tempest/api/orchestration/base.py", line 110, in load_template
    with open(fullpath, "r") as f:
IOError: [Errno 2] No such file or directory: 'tempest/api/orchestration/stacks/templates/nova_keypair.json'

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tempest (master)

Fix proposed to branch: master
Review: https://review.openstack.org/84363

Changed in tempest:
assignee: nobody → Qiu Hua Qiao (qhqiao)
status: New → In Progress
Revision history for this message
Openstack Gerrit (openstack-gerrit) wrote : Fix merged to tempest (master)

Reviewed: https://review.openstack.org/84363
Committed: https://git.openstack.org/cgit/openstack/tempest/commit/?id=f636877b556ae3159a33d135a4c5674bfec0970a
Submitter: Jenkins
Branch: master

commit f636877b556ae3159a33d135a4c5674bfec0970a
Author: Qiu Hua Qiao <email address hidden>
Date: Tue Apr 1 01:12:39 2014 -0500

    Change to use absolute path in load_template()

    If we execute the tempest in other path other than the root path of
    tempest, the case will failed because can't find the template files.

    Change-Id: Ic585546270b2c6d7a42d3128d752217d8d4e3860
    Closes-bug: 1300597

Changed in tempest:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.