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

Transplant verify functionality from chef-cli #479

Merged
merged 10 commits into from
Sep 19, 2019
Merged

Conversation

marcparadise
Copy link
Member

@marcparadise marcparadise commented Sep 10, 2019

This moves the verify command into chef-workstation, since it is only used to verify the builds in the omnibus pipeline. This helps reduce the indirect circular dependency between Workstation and CLI as well, since CLI no longer needs to know about what tools ship with Workstation.

This is minimally modified transplant of the Verify class and the supporting class ComponentTest. Once all is well, we can update chef-cli to remove the verify command.

Signed-off-by: Marc A. Paradise marc.paradise@gmail.com

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@marcparadise marcparadise requested review from a team as code owners September 10, 2019 18:27
@marcparadise marcparadise force-pushed the mp/own-verify branch 6 times, most recently from 891992d to dbb3f31 Compare September 12, 2019 14:51
Copy link

@afiune afiune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to talk about this PR. A general question would be

"What happens when a user tries to run chef verify?"

Are we deprecating this command? or just remove it for good without notice?

@marcparadise
Copy link
Member Author

It was hidden internal command which wasn't provided for use to customers, so I'm planning to remove it without deprecation

Copy link

@afiune afiune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of code, it will take me a few to review this.

Do we need this file though?
omnibus/verification/spec/unit/fixtures/eg_omnibus_dir/valid/embedded/apps/chef-dk/.keep

Also it is hard to see what is copy paste code and what are the things you have modified, like commenting out code, etc.

omnibus/omnibus-test.ps1 Outdated Show resolved Hide resolved
omnibus/verification/verify.rb Outdated Show resolved Hide resolved
omnibus/omnibus-test.sh Outdated Show resolved Hide resolved
@marcparadise
Copy link
Member Author

@afiune here's a diff of verify and component_test:

https://gist.github.com/marcparadise/3c7470aee219a0c9ae847ac98928e223

@@ -8,6 +8,15 @@ steps:
executor:
docker:
image: ruby:2.6-stretch
- label: verification-unit-tests-ruby-2.6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just call this component-tests. They're not unit tests really for a lot of things.

@afiune
Copy link

afiune commented Sep 16, 2019

@marcparadise I just looked at the buildkite job output and I see the following:

All examples were filtered out; ignoring {:focus=>true}
  | ........true
  | true
  | true
  | .ruby -e 'puts Dir.pwd'
  | .ruby -e 'puts Dir.pwd'
  | .......exit 0
  | .exit 1
  | .exit 0
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | /usr/local/bin/ruby integration_test
  | .exit 0
  | .exit 0
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | exit 0
  | /usr/local/bin/ruby verify_me
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | exit 0
  | /usr/local/bin/ruby verify_me
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | .exit 0
  | exit 0
  | exit 0
  | /usr/local/bin/ruby verify_me
  | /usr/local/bin/ruby verify_me
  | /usr/local/bin/ruby verify_me
  | .exit 0
  | exit 0
  | exit 0
  | /usr/local/bin/ruby verify_me
  | /usr/local/bin/ruby verify_me
  | /usr/local/bin/ruby verify_me
  | .
  |  
  | Finished in 1.21 seconds (files took 0.92669 seconds to load)
  | 32 examples, 0 failures

https://buildkite.com/chef/chef-chef-workstation-master-verify/builds/610#125ed5e8-80f1-4cb9-9fd3-36acb27131d1

Wondering if thats the expected output and if the exit 1 should actually be a failure?

@tyler-ball tyler-ball added Aspect: Testing Does the project have good coverage, and is CI working? Status: Adopted An issue that is being worked on. Type: Chore non-critical maintenance of a project. labels Sep 16, 2019
Copy link
Contributor

@tyler-ball tyler-ball left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcparadise Salim and I added some commits to help us understand what is going on here.

It looks to me like you wrote some scripts (run.rb, verify.rb, component_test.rb) that contain logic for how to test components included inside Chef Workstation. LGTM, 👍

The spec folder initially confused me until I realized those are the tests for the logic in verify.rb and other scripts. I added a short README to help my future brain remember.

With that understanding this looks 🚀 🍰 to me!

@marcparadise marcparadise requested a review from a team as a code owner September 17, 2019 22:52
This moves the verify command into chef-workstation, since
it is only used to verify the builds in the omnibus pipeline.
This removes the indirect circular dependency between
Workstation and CLI as well, since CLI no longer needs to know
about what tools ship with Workstation.

This is a minimally modified transplant of the Verify class and
the supporting class ComponentTest from chef-cli. Once all is well,
we can update chef-cli to remove the verify command.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
This allows us to keep `verify.rb` containing only
the verification class definition, which prevents us
from actually running verification when attempting
to run unit specs.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Moved inlined ruby into a separate script for readability.
Removed chef-run because it's tested in verify itself.
Removed a second `chef env` run because one verifies just as well as two
in this case.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Because moving `verify` into Workstation doesn't alter
which tests we do/do not run, we will address these separately.
We'll be tracking the state of verification tests
under #487.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
@marcparadise
Copy link
Member Author

Running CI again. The secondary issues we've been having lately have been bubbling through to these builds, but it looks like current master is sane.

@marcparadise
Copy link
Member Author

Thanks for adding the README, I meant to include that when I made that directory - figured it would otherwise be weird -- "Why are these specs in a random omnibus directory..."

Signed-off-by: tyler-ball <tball@chef.io>
We've seen issues where "exit" does not properly
set the system exit code but "exit!" does.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
omnibus/omnibus-test.ps1 Outdated Show resolved Hide resolved
@@ -3,6 +3,9 @@ source "https://rubygems.org"
group :development do
gem "chefstyle"
gem "rake"
# enable tests for the verification behavior in omnibus/verification
gem "chef-cli"
gem "rspec"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If unit is disabled do we still need rspec?

Return to the original state of Workstation
where we did not run unit tests in verification.

There are a couple of problems with unit tests currently
that need to be addressed before we enable them:

- they must be run as root because we bundle install
  in the gem's chef-workstation-ruby source lib directory
- windows unit tests are failing. We don't currently
  know yet if  are legitimate failures, but we do know that
  we've been shipping without runnign those tests for a while now.

Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
@marcparadise marcparadise merged commit cb93e1a into master Sep 19, 2019
@chef-expeditor chef-expeditor bot deleted the mp/own-verify branch September 19, 2019 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Aspect: Testing Does the project have good coverage, and is CI working? Status: Adopted An issue that is being worked on. Type: Chore non-critical maintenance of a project.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants