Improve 'run_on_remote' for more general use

Bug #1489165 reported by Maksym Strukov
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Fuel for OpenStack
Fix Released
Medium
Maksym Strukov

Bug Description

https://github.com/stackforge/fuel-qa/blob/cf8342940b4c6d3e701aedb654412a0cdd04dd16/fuelweb_test/helpers/utils.py#L317

There are few problems in run_on_remote method:
Now, to use it as "checker" for commands with expected exitcode!=0 I need to wrap call to try-catch, because exception raised every time ec!=0.

Propose is to add parameter for suppressing exceptions (just logging)
Propose is to add expected_EC parameter to show what ec I waiting for.

This changes also will reduce the number of duplicate code in asserts when we need to log not only error message but all data from command execution (stdout/stderr/ec/expected_ec)

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

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

Changed in fuel:
assignee: Fuel QA Team (fuel-qa) → Maksym Strukov (unbelll)
status: New → In Progress
Maksym Strukov (unbelll)
Changed in fuel:
milestone: none → 7.0
Changed in fuel:
milestone: 7.0 → 8.0
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-qa (master)

Reviewed: https://review.openstack.org/217396
Committed: https://git.openstack.org/cgit/stackforge/fuel-qa/commit/?id=32b6bc8cea5c595aa92e2c2c825762b53c49e191
Submitter: Jenkins
Branch: master

commit 32b6bc8cea5c595aa92e2c2c825762b53c49e191
Author: Maksym Strukov <email address hidden>
Date: Wed Aug 26 23:59:36 2015 +0300

    Improve 'run_on_remote' for more general use

    To use method in cases when ec is expected to be not zero and reduce
    duplicated code in asserts messages new parameters in 'run_on_remote'
    method proposed with following logic:
    * 'assert_ec_equal' with default '[0]'. Error message will be logged only
    when exit_code != assert_ec_equal. Can pass xrange(1,8) or [1, 4, 5]
    * 'raise_on_assert' with default 'True'. Exception now can be
    surpressed when exit_code != assert_ec_equal if 'raiseOnAssert' is 'False'

    Also:
    * 'run_on_remote_get_results' return dict with:
      'command',
      'host',
      'stdout',
      'stdout_str',
      'stdout_len',
      'stdout_json', if jsonify=true
      'stderr',
      'stderr_str',
      'stderr_len',
      'exit_code', instead of just stdout string
    * 'run_on_remote' wrapper leaved for compatibility

    Change-Id: I32a9d743929d01857a88844976074df719d9880a
    Closes-Bug: #1489165

Changed in fuel:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to fuel-qa (stable/7.0)

Fix proposed to branch: stable/7.0
Review: https://review.openstack.org/224499

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to fuel-qa (stable/7.0)

Reviewed: https://review.openstack.org/224499
Committed: https://git.openstack.org/cgit/stackforge/fuel-qa/commit/?id=d27d5627ea821ccd486120d033795d6f0c1ffe1a
Submitter: Jenkins
Branch: stable/7.0

commit d27d5627ea821ccd486120d033795d6f0c1ffe1a
Author: Maksym Strukov <email address hidden>
Date: Wed Aug 26 23:59:36 2015 +0300

    [stable/7.0]Improve 'run_on_remote' for more general use

    Author: Maksym Strukov
    To use method in cases when ec is expected to be not zero and reduce
    duplicated code in asserts messages new parameters in 'run_on_remote'
    method proposed with following logic:
    * 'assert_ec_equal' with default '[0]'. Error message will be logged only
    when exit_code != assert_ec_equal. Can pass xrange(1,8) or [1, 4, 5]
    * 'raise_on_assert' with default 'True'. Exception now can be
    surpressed when exit_code != assert_ec_equal if 'raiseOnAssert' is 'False'

    Also:
    * 'run_on_remote_get_results' return dict with:
      'command',
      'host',
      'stdout',
      'stdout_str',
      'stdout_len',
      'stdout_json', if jsonify=true
      'stderr',
      'stderr_str',
      'stderr_len',
      'exit_code', instead of just stdout string
    * 'run_on_remote' wrapper leaved for compatibility

    Change-Id: I32a9d743929d01857a88844976074df719d9880a
    Closes-Bug: #1489165
    (cherry picked from commit 32b6bc8cea5c595aa92e2c2c825762b53c49e191)

Maksym Strukov (unbelll)
Changed in fuel:
status: Fix Committed → Fix Released
Dmitry Pyzhov (dpyzhov)
tags: added: area-qa
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.