RedHatQE / teflo

Teflo is a standalone orchestration software that controls the flow of a set of testing scenarios, allowing users to provision machines, deploy software, execute tests against them and manage generated artifacts and report results.
https://teflo.readthedocs.io/en/latest/
GNU General Public License v3.0
14 stars 16 forks source link

Using teflo > 1.2.0 causes an exception when using vars-data #101

Closed Dannyb48 closed 3 years ago

Dannyb48 commented 3 years ago

As of 1.2.1 whenever we run the following command:

teflo run -s tests/teflo_sdf/osp_dev_stack_deploy.yml --workspace ./ --vars-data playbooks/group_vars/autobot.yml --vars-data playbooks/group_vars/dev.yml --task provision --labels ceph --labels ceph_vols

We see the following error:

Teflo Framework v1.2.1
Copyright (C) 2021, Red Hat, Inc.
--------------------------------------------------
Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/bin/teflo", line 8, in <module>
    sys.exit(teflo())
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/teflo/cli.py", line 240, in run
    scenario_stream = validate_cli_scenario_option(ctx, scenario, cbn.config, vars_data)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/teflo/helpers.py", line 1643, in validate_cli_scenario_option
    scenario_stream = validate_render_scenario(scenario, config, vars_data)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/teflo/helpers.py", line 1479, in validate_render_scenario
    temp_data.update({item[0]: preprocyaml(item[1], temp_data)})
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/teflo/helpers.py", line 1428, in preprocyaml
    return preprocyaml_str(input, temp_data)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/teflo/helpers.py", line 1415, in preprocyaml_str
    return replace_brackets(input, temp_data)
  File "/var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/lib/python3.6/site-packages/teflo/helpers.py", line 1403, in replace_brackets
    ret = input.replace(input[replace_start:replace_end], temp_data[key], 1)
TypeError: replace() argument 2 must be str, not list
ERROR: InvocationError for command /var/lib/jenkins/workspace/PSI-CZero-OSPQE-Test-Job/scenario/C0/.tox/teflo/bin/teflo run -s tests/teflo_sdf/osp_dev_stack_deploy.yml --workspace ./ --vars-data playbooks/group_vars/autobot.yml --vars-data playbooks/group_vars/dev.yml --task provision --labels ceph --labels ceph_vols (exited with code 1)

In order to work around this we need to rollback and pin teflo to 1.2.0. I think this has to do with the recent changes for PR #76

rujutashinde commented 3 years ago

I will look at this one

rujutashinde commented 3 years ago

The issue arises when we are trying to recursively replace the variables in the variable file, and the value to be replaced is a list instead of a string e.g. below the devices is resolved as a list [/dev/vdc] , string.replace operation does not like the replacement value to be a list. A string is expected

 devices:
  - /dev/vdc
disk_wipe_disks: "{{ devices }}" 
Dannyb48 commented 3 years ago

@rujutashinde Good Catch! Yeah so I assume that utility should probably take into account check whether the type is, str, list, and dicts

dno-github commented 3 years ago

Jira ticket CCITCARBON-349 has been created for this issue. Url : https://projects.engineering.redhat.com/browse/CCITCARBON-349