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

Fix broken inspec test #2042

Closed
decentral1se opened this issue May 14, 2019 · 3 comments · Fixed by #2045
Closed

Fix broken inspec test #2042

decentral1se opened this issue May 14, 2019 · 3 comments · Fixed by #2045
Labels
critical test Improvement to quality assurance: CI/CD, testing, building

Comments

@decentral1se
Copy link
Contributor

decentral1se commented May 14, 2019

This is blocking PRs from getting reviewed properly and merged. Affected:

I cannot reproduce this locally. I ran:

$ tox -e py37-ansible27-functional -- -v -k test_command_init_role_inspec -p no:warning

Log is (not useful at all ... another case against sh?):

From https://travis-ci.com/ansible/molecule/jobs/199661714#L451.

=================================== FAILURES ===================================
________________________ test_command_init_role_inspec _________________________
temp_dir = local('/tmp/pytest-of-travis/pytest-0/test_command_init_role_inspec0/SVPPY')
    @needs_inspec
    @needs_rubocop
    def test_command_init_role_inspec(temp_dir):
        role_directory = os.path.join(temp_dir.strpath, 'test-init')
        options = {
            'role_name': 'test-init',
            'verifier_name': 'inspec',
        }
        cmd = sh.molecule.bake('init', 'role', **options)
        pytest.helpers.run_command(cmd)
        pytest.helpers.metadata_lint_update(role_directory)
    
        with change_dir_to(role_directory):
>           sh.molecule('test')
/home/travis/build/ansible/molecule/test/functional/docker/test_scenarios.py:104: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/home/travis/build/ansible/molecule/.tox/ansible27-functional/lib/python3.7/site-packages/sh.py:1427: in __call__
    return RunningCommand(cmd, call_args, stdin, stdout, stderr)
/home/travis/build/ansible/molecule/.tox/ansible27-functional/lib/python3.7/site-packages/sh.py:774: in __init__
    self.wait()
/home/travis/build/ansible/molecule/.tox/ansible27-functional/lib/python3.7/site-packages/sh.py:792: in wait
    self.handle_command_exit_code(exit_code)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = --> Validating schema /tmp/pytest-of-travis/pytest-0/test_command_init_role_inspec0/SVPPY/test-init/molecule/defa...changed=1    unreachable=0    failed=0
    
--> Pruning extra files from scenario ephemeral directory
code = 1
    def handle_command_exit_code(self, code):
        """ here we determine if we had an exception, or an error code that we
        weren't expecting to see.  if we did, we create and raise an exception
        """
        ca = self.call_args
        exc_class = get_exc_exit_code_would_raise(code, ca["ok_code"],
                ca["piped"])
        if exc_class:
            exc = exc_class(self.ran, self.process.stdout, self.process.stderr,
                    ca["truncate_exc"])
>           raise exc
E           sh.ErrorReturnCode_1: 
E           
E             RAN: /home/travis/build/ansible/molecule/.tox/ansible27-functional/bin/molecule test
E           
E             STDOUT:
E           --> Validating schema /tmp/pytest-of-travis/pytest-0/test_command_init_role_inspec0/SVPPY/test-init/molecule/default/molecule.yml.
E           Validation completed successfully.
E           --> Test matrix
E               
E           └── default
E               ├── lint
E               ├── dependency
E               ├── cleanup
E               ├── destroy
E               ├── syntax
E               ├── create
E               ├── prepare
E               ├── converge
E               ├── idempotence
E               ├── side_effect
E               ├── verify
E               ├── cleanup
E               └── destroy
E               
E           --> Scenario: 'default'
E           --> Action: 'lint'
E           --> Executing Yamllint on files found in /tmp/pytest-of-travis/pytest-0/test_command_init_role_inspec0/SVPPY/test-init/...
E           Lint completed successf... (1530 more, please see e.stdout)
E           
E             STDERR:
/home/travis/build/ansible/molecule/.tox/ansible27-functional/lib/python3.7/site-packages/sh.py:815: ErrorReturnCode_1
----------------------------- Captured stdout call -----------------------------
    --> Initializing new role test-init...
    Initialized role in /tmp/pytest-of-travis/pytest-0/test_command_init_role_inspec0/SVPPY/test-init successfully.
@decentral1se decentral1se added test Improvement to quality assurance: CI/CD, testing, building critical labels May 14, 2019
@webknjaz
Copy link
Member

It looks like molecule test returned status code 1 but I have no idea why.

@webknjaz webknjaz pinned this issue May 16, 2019
@seandst
Copy link
Contributor

seandst commented May 16, 2019

After upgrading my local install of inspec from 3.6.6 to 4.3.2, I'm able to reproduce this with the same (lack of) error seen in travis. Digging deeper now...

@seandst
Copy link
Contributor

seandst commented May 16, 2019

Downgrading to 3.6 to see if it's a matter of pinning inspec or not revealed that it was actually rubocop raising the error. :)

rubocop/rubocop@80bc828#diff-fd50647d8291ed0994bf3f0ba3162662 set the rubocop cop in question to be always enforced with the most recent rubocop release, 0.69. Here's the error in the pytest logs after disabling exception truncation in sh for test runs:

    --> Executing RuboCop on files found in /tmp/pytest-of-semyers/pytest-10/test_command_init_role_inspec0/PNOOM/test-init/molecule/default/tests/...                                                                                         
        Inspecting 1 file                                                                                                                                                                                                                      
        C                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                               
        Offenses:                                                                                                                                                                                                                              
                                                                                                                                                                                                                                               
        molecule/default/tests/test_default.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.                                                                                                  
        # Molecule managed                                                                                                                                                                                                                     
        ^                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                               
        1 file inspected, 1 offense detected                                                                                                                                                                                                   
    An error occurred during the test sequence action: 'lint'. Cleaning up.                                   

Both the fix to this lint error and the related fix to prevent truncating exception strings are up in PR #2045.

@helpr helpr bot added pr-merged and removed pr-available labels May 16, 2019
decentral1se added a commit to decentral1se/molecule that referenced this issue May 16, 2019
decentral1se added a commit to decentral1se/molecule that referenced this issue May 16, 2019
decentral1se added a commit to decentral1se/molecule that referenced this issue May 16, 2019
@webknjaz webknjaz unpinned this issue May 17, 2019
decentral1se added a commit that referenced this issue May 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical test Improvement to quality assurance: CI/CD, testing, building
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants