Skip to content
This repository was archived by the owner on Oct 10, 2020. It is now read-only.

[merged] make vagrant-check: Run tests with vagrant#736

Closed
baude wants to merge 1 commit intoprojectatomic:masterfrom
baude:vagrant
Closed

[merged] make vagrant-check: Run tests with vagrant#736
baude wants to merge 1 commit intoprojectatomic:masterfrom
baude:vagrant

Conversation

@baude
Copy link
Member

@baude baude commented Oct 27, 2016

Run tests in a vagrant session (w/libvirt for now). This allows
the tests to occur similar to the way our jenkins tests work. Run
make vagrant-check and we created an F24 session and install
the proper deps. We then call the .redhat-ci.sh script inside
the vagrant session and the tests are executed. At this time, you
will need to vagrant halt to shutdown the session when comlete.

Vagrantfile Outdated

# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "fedora/24-cloud-base"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not fedora/24-atomic-host here? Or even better, define all three (the CentOS box is called centos/atomic-host). Someone can then choose to only bring up a single one, e.g. vagrant up fedora/24/atomic.

Copy link
Member Author

@baude baude Oct 27, 2016

Choose a reason for hiding this comment

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

Well, two quick reasons.

  1. If I understood you correctly, the CentOS and Fedora Atomic host required greater preparations than simply dnf install coverage and atomic. And that is normally handled specially by your tools right which arent in play local use.

  2. Aim small, miss small :)

In all seriousness, if you think I should pursue, I'm happy to do so. I think the Makefile would then need to call a bash script instead of trying to handle this all in make. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. If I understood you correctly, the CentOS and Fedora Atomic host required greater preparations than simply dnf install coverage and atomic. And that is normally handled specially by your tools right which arent in play local use.

For fedora/24/atomic, we don't do any special handling. So the rest of your Vagrantfile should just work as is (minus the dnf install part). For CentOS, hmmm... yeah that's an issue. You'd have to rebase to CAHC, since the official release lags so much behind (or layer all the new reqs). I researched this a while back (we have a similar setup in rpm-ostree), and rebasing and rebooting as part of the Vagrant provisioning process was not straightforward.

  1. Aim small, miss small :)

Agreed! This is definitely a good start. How about we start with just fedora/24-atomic-host, since I'd say this project holds more importance on AH than in the Cloud variant. Plus, I assume most developers here are not using an Atomic Host to hack on atomic, so this would be an easy way to provide them that environment. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree. I'll fixer it up.

Copy link
Member

Choose a reason for hiding this comment

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

We actually have Vagrant boxes generated for CAHC (both continuous and alpha) btw, and I switched to using CAHC Alpha in coreos/rpm-ostree#502

@rhatdan
Copy link
Member

rhatdan commented Oct 27, 2016

SGTM

@cgwalters
Copy link
Member

See also coreos/rpm-ostree#502

Copy link
Contributor

@jlebon jlebon left a comment

Choose a reason for hiding this comment

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

👍

@baude
Copy link
Member Author

baude commented Oct 31, 2016

Rebasing

@miabbott
Copy link
Contributor

miabbott commented Nov 1, 2016

One thing of note, if you run make vagrant-check in succession, you might get an error like this:

$ make vagrant-check
vagrant up "fedora_atomic"
Bringing machine 'fedora_atomic' up with 'libvirt' provider...
vagrant ssh "fedora_atomic" -c "cd /home/vagrant/atomic && sudo sh ./.redhat-ci.sh"
+ mount --make-rshared /
+ systemctl start docker
+ '[' -f /run/ostree-booted ']'
+ ostree admin unlock
error: Deployment is already in unlocked state: development
Connection to 192.168.121.23 closed.
Makefile:97: recipe for target 'vagrant-check' failed
make: *** [vagrant-check] Error 1

I think you'll have to vagrant destroy before re-running it.

@baude baude force-pushed the vagrant branch 3 times, most recently from 4890fd2 to f6ea503 Compare November 1, 2016 18:08
vagrant.sh Outdated


is_running() {
status=$(vagrant status | grep fedora_atomic | awk '{print $2}')
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll have to change this to grep for ${BOX} since it is selectable

Copy link
Member Author

Choose a reason for hiding this comment

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

Got it, good catch @miabbott

exit 1
fi
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add some logic before running the bulk of the script to validate that the value of ${BOX} is supported? Some usage feedback with supported values would go nicely here, too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a check.

@@ -0,0 +1,31 @@
#!/bin/bash

Copy link
Contributor

Choose a reason for hiding this comment

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

set -euo pipefail would be a nice addition

vagrant.sh Outdated
tee_file="${BOX}_${timestamp}.log"
is_running
vagrant up ${BOX}
vagrant ssh ${BOX} -c "cd /home/vagrant/atomic && sudo sh ./.redhat-ci.sh"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this needs to be piped to tee?

Copy link
Member Author

Choose a reason for hiding this comment

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

The piping to tee seems to break $? reflecting the actual test result.

@baude baude force-pushed the vagrant branch 3 times, most recently from 01c70db to 5ccc8de Compare November 2, 2016 19:14
@baude
Copy link
Member Author

baude commented Nov 2, 2016

@rhatdan this is good to go now, not sure what is up with the ci tests

vagrant.sh Outdated
status=$(vagrant status | grep ${BOX} | awk '{print $2}')
if [ ${status} == "running" ]; then
echo ""
echo "'${BOX}' is already running. Perform a 'vagrant halt|destroy ${BOX}'"
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than having to destroy and bring back up each time, can't we just vagrant rsync here if we see it's already up?

Copy link
Member Author

Choose a reason for hiding this comment

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

How do I know if it is already running a test? I defaulted to this because I really dont know the existing state if it is running. Thoughts? @rhatdan

Copy link
Contributor

Choose a reason for hiding this comment

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

We can leave that to the user, no? I.e. expect them to know when the previous make vagrant-check is done before starting a new one. Or are you thinking of another use case here?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jlebon OK I have implemented your suggestion but I hit ...


/usr/share/gems/gems/net-ssh-2.9.1/lib/net/ssh/transport/session.rb:67:in `initialize': Object#timeout is deprecated, use Timeout.timeout instead.
/usr/share/gems/gems/net-ssh-2.9.1/lib/net/ssh/transport/session.rb:84:in`initialize': Object#timeout is deprecated, use Timeout.timeout instead.
==> fedora_atomic: Rsyncing folder: /home/bbaude/docker/atomic/ => /home/vagrant/atomic
==> fedora_atomic:   - Exclude: [".vagrant/", ".tmp*"]
- mount --make-rshared /
- systemctl start docker
- '[' -f /run/ostree-booted ']'
- ostree admin unlock
  error: Deployment is already in unlocked state: development
  Connection to 192.168.121.217 closed.

*\* Test failed.  Leaving 'fedora_atomic' running for debug.
*\* Be sure to halt or destroy prior to re-running the check
*\* Logs are stored at fedora_atomic_2016_11_03_09_34.log

Makefile:97: recipe for target 'vagrant-check' failed
make: **\* [vagrant-check] Error 1

So can your rh ci script handle this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, we just need to tweak the unlock part. Maybe e.g.:

if [ -f /run/ostree-booted ]; then
  ostree admin unlock || :
fi

Copy link
Contributor

Choose a reason for hiding this comment

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

Or maybe if we want to be more correct, e.g. check rpm-ostree status --json or whether a /var/tmp/ostree-unlock-ovl.* dir exists.

@baude baude force-pushed the vagrant branch 2 times, most recently from 3f03d87 to 0a4038e Compare November 3, 2016 18:16
@rhatdan
Copy link
Member

rhatdan commented Nov 7, 2016

@miabbott @cgwalters Are you guys happy with this?

@cgwalters
Copy link
Member

Down the line we'll definitely want to do more dedup across projects and such, but this seems sane to me to start.

@cgwalters
Copy link
Member

Why does the PR have a merge from master instead of being rebased though?

@jlebon
Copy link
Contributor

jlebon commented Nov 7, 2016

Yup, looks good on my end as well.

@rhatdan
Copy link
Member

rhatdan commented Nov 7, 2016

@baude REBASE please and then we can merge.

Run tests in a vagrant session (w/libvirt for now).  This allows
the tests to occur similar to the way our jenkins tests work. Run
make vagrant-check and we created an F24 session and install
the proper deps.  We then call the .redhat-ci.sh script inside
the vagrant session and the tests are executed.  At this time, you
will need to vagrant halt to shutdown the session when comlete.

By default, the tests will exeute on an instance of fedora-24-atomic.
You can test on Colin's CAHC centos-atomic by:

make vagrant-check BOX=centos_atomic
@baude
Copy link
Member Author

baude commented Nov 7, 2016

@rhatdan rebased

@rhatdan
Copy link
Member

rhatdan commented Nov 7, 2016

@rh-atomic-bot r+

@rh-atomic-bot
Copy link

📌 Commit 671ed30 has been approved by rhatdan

@rh-atomic-bot
Copy link

⌛ Testing commit 671ed30 with merge b982674...

rh-atomic-bot pushed a commit that referenced this pull request Nov 7, 2016
Run tests in a vagrant session (w/libvirt for now).  This allows
the tests to occur similar to the way our jenkins tests work. Run
make vagrant-check and we created an F24 session and install
the proper deps.  We then call the .redhat-ci.sh script inside
the vagrant session and the tests are executed.  At this time, you
will need to vagrant halt to shutdown the session when comlete.

By default, the tests will exeute on an instance of fedora-24-atomic.
You can test on Colin's CAHC centos-atomic by:

make vagrant-check BOX=centos_atomic

Closes: #736
Approved by: rhatdan
@rh-atomic-bot
Copy link

💔 Test failed - status-atomicjenkins

@baude
Copy link
Member Author

baude commented Nov 7, 2016

@rh-atomic-bot retry

@rh-atomic-bot
Copy link

⌛ Testing commit 671ed30 with merge 8ea8d1e...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: rhatdan
Pushing 8ea8d1e to master...

@rh-atomic-bot rh-atomic-bot changed the title make vagrant-check: Run tests with vagrant [merged] make vagrant-check: Run tests with vagrant Nov 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants