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

split bats into the real tests and roles to set stuff up #465

Merged
merged 1 commit into from Jun 9, 2017

Conversation

evgeni
Copy link
Member

@evgeni evgeni commented Jun 2, 2017

before we had bats doing a lot of setup and then running tests.
this moves the setup tasks into a series of own roles (haveged, disable_firewall, clean_puppet) and lets bats do what it is supposed to do: run tests.

Copy link
Member

@stbenjam stbenjam left a comment

Choose a reason for hiding this comment

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

Looks good to me

@@ -44,6 +44,7 @@ centos7-bats-ci:
bats_tests:
- "swapfile.bats"
- "fb-install-katello.bats"
Copy link
Member

Choose a reason for hiding this comment

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

IMHO this can be left out now. We should rely on ansible for installation.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean basically completely dropping fb-install-katello.bats? Yeah we can do that.

Copy link
Member

Choose a reason for hiding this comment

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

The file can stay, but we shouldn't recommend using it I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

If the file is not used and not recommended, why should it stay? Archaeology lessons can still be done using the Git history, an unused file is just confusing. Same applies for katello-bats btw, I think it's unused by now?

Copy link
Member

Choose a reason for hiding this comment

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

That's the problem I have with this repo: I don't know how people use it. Maybe @ehelms or @stbenjam know it better.

Copy link
Member

Choose a reason for hiding this comment

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

One of the biggest things we need is https://github.com/evgeni/forklift/blob/99fdda8d44631373e75ece1bb3aefdc2a970f52a/bats/fb-install-katello.bats#L47-L52 which was put in to help out on the CI system as far as I remember.

So maybe we need like a setup role to do a few of those items (instead of "testing" them). Otherwise I think it's safe to remove the install test file.

Copy link
Member

Choose a reason for hiding this comment

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

For now I'd suggest a haveged role rather than a more global setup role which may get parameters. Start simple.

@@ -5,5 +5,6 @@ bats_output_dir: "/root/bats_results"
bats_update_forklift: "yes"
bats_tests:
- "fb-install-katello.bats"
Copy link
Member

Choose a reason for hiding this comment

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

Should also be left out IMHO.

@ekohl
Copy link
Member

ekohl commented Jun 2, 2017

Thanks you for this! I wanted to do this but hadn't gotten around to it.

@@ -0,0 +1,42 @@
#!/usr/bin/env bats
Copy link
Member

Choose a reason for hiding this comment

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

@evgeni I think one additional check could be valuable here -- doing a curl of /katello/api/ping since this provides information of about services that the status check does not, e.g. whether or not Katello can talk to Pulp or Candlepin and whether or not Pulp is having any connectivity issues with the workers. These are things that can produce big smells for installation health.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's what hammer ping does. No need to curl yourself ;)

}

@test "check host is registered" {
[ x$FOREMAN_VERSION = "x1.3" ] && skip "Only supported on 1.4+"
Copy link
Member

Choose a reason for hiding this comment

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

Ha - I think we could drop this line

Copy link
Member Author

Choose a reason for hiding this comment

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

So I did in my local branch, let me polish and push that before you continue review.

@evgeni evgeni changed the title move the basic katello tests to an own bats file split bats into the real tests and roles to set stuff up Jun 7, 2017
@evgeni
Copy link
Member Author

evgeni commented Jun 7, 2017

@ekohl @ehelms @stbenjam please re-review, I made all the setup steps into own roles, and killed fb-install-katello.bats :)

@ehelms
Copy link
Member

ehelms commented Jun 7, 2017

Looks good to me, will let @ekohl have a final pass at the updated version


@test "check smart proxy is registered" {
count=$(hammer --csv proxy list | wc -l)
[ $count -gt 1 ]
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if grepping for the hostname would be a better check, but I think this is directly ported so it's fine to leave this in.

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah. grep -q $hostname sounds good to me.

Sent from my OnePlus ONEPLUS A3003 using FastHub

@@ -0,0 +1,22 @@
---
Copy link
Member

Choose a reason for hiding this comment

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

I'd drop this role. It was originally added in the foreman-bats because you want to start with a clean install, but in the ansible context it doesn't really make sense (unless you do it before the foreman-installer run).

Copy link
Member Author

Choose a reason for hiding this comment

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

ack. Was not sure about the history and thought porting was cheaper then thinking.

- name: 'Install Haveged (faster population of PRNG)'
yum:
name: haveged
state: latest
Copy link
Member

Choose a reason for hiding this comment

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

I think just ensuring it's installed is good enough.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats how it was in the freeipa role.

Sent from my OnePlus ONEPLUS A3003 using FastHub

@evgeni
Copy link
Member Author

evgeni commented Jun 8, 2017

@ekohl there we go, all 3 comments done

before we had bats doing a lot of setup and then running tests.
this moves the setup tasks into a series of own roles (haveged,
disable_firewall) and lets bats do what it is supposed to do:
run tests.
Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Untested but it looks correct.

@ekohl ekohl merged commit 1619743 into theforeman:master Jun 9, 2017
@ekohl
Copy link
Member

ekohl commented Jun 9, 2017

Thanks!

johnpmitsch pushed a commit to johnpmitsch/forklift that referenced this pull request Jun 27, 2019
)

before we had bats doing a lot of setup and then running tests.
this moves the setup tasks into a series of own roles (haveged,
disable_firewall) and lets bats do what it is supposed to do:
run tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants