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

tests: set up the spread execution in linode #1374

Merged
merged 9 commits into from Jun 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -19,6 +19,9 @@ jobs:
- script: if [ "$TRAVIS_EVENT_TYPE" != "cron" ]; then ./tools/travis/run_tests.sh store; fi
# CLA check, only in pull requests.
- script: if [ "$TRAVIS_PULL_REQUEST" != "false" ] && [ "$TRAVIS_EVENT_TYPE" != 'cron' ]; then ./tools/travis/run_cla_check.sh; fi
# Trigger edge tests, only in the daily cron.
- stage: edge
script: if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then ./runtests.sh spread; fi
# Trigger beta tests, only in the daily cron.
- stage: beta
script: if [ "$TRAVIS_EVENT_TYPE" = "cron" ]; then ./tools/travis/make_beta_pr.sh; fi
Expand Down
18 changes: 17 additions & 1 deletion runtests.sh
Expand Up @@ -28,6 +28,7 @@ parseargs(){
export RUN_STORE="true"
export RUN_PLUGINS="true"
export RUN_SNAPS="true"
export RUN_SPREAD="true"
else
if [ "$1" == "static" ] ; then
export RUN_STATIC="true"
Expand All @@ -44,8 +45,10 @@ parseargs(){
# Temporary: backward compatibility until CI run the "snaps" target
elif [ "$1" == "examples" ] ; then
export RUN_SNAPS="true"
elif [ "$1" == "spread" ] ; then
export RUN_SPREAD="true"
else
echo "Not recognized option, should be one of all, static, unit, integration, store or snaps"
echo "Not recognized option, should be one of all, static, unit, integration, store, snaps or spread"
exit 1
fi
fi
Expand Down Expand Up @@ -104,6 +107,15 @@ run_snaps(){
python3 -m snaps_tests "$@"
}

run_spread(){
TMP_SPREAD="$(mktemp -d)"

export PATH=$TMP_SPREAD:$PATH
( cd "$TMP_SPREAD" && curl -s -O https://niemeyer.s3.amazonaws.com/spread-amd64.tar.gz && tar xzvf spread-amd64.tar.gz )

spread -v linode:
}

parseargs "$@"

if [ ! -z "$RUN_STATIC" ] ; then
Expand Down Expand Up @@ -142,6 +154,10 @@ if [ ! -z "$RUN_SNAPS" ]; then
run_snaps "$@"
fi

if [ ! -z "$RUN_SPREAD" ]; then
run_spread
fi

if [ ! -z "$RUN_UNIT" ]; then
if [ ! -z "$coverage" ]; then
python3 -m coverage report
Expand Down
34 changes: 31 additions & 3 deletions spread.yaml
Expand Up @@ -8,15 +8,43 @@ environment:
backends:
lxd:
systems: [ubuntu-16.04]
linode:
key: "$(HOST: echo $SPREAD_LINODE_KEY)"
systems:
- ubuntu-16.04-64:

Choose a reason for hiding this comment

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

The default linode kernels don't play well with snapd because of the lack of apparmor support, not sure if this apply here but, because you install snapd later, maybe you should use a specific kernel like we do in snapd's suite https://github.com/snapcore/snapd/blob/master/spread.yaml#L51

kernel: GRUB 2
workers: 3

suites:
spread_tests/:
summary: tests of the snapcraft snap
prepare: |
# apt update is hanging on security.ubuntu.com with IPv6, prefer IPv4 over IPv6
cat <<EOF > gai.conf
precedence ::1/128 50
precedence ::/0 40
precedence 2002::/16 30
precedence ::/96 20
precedence ::ffff:0:0/96 100
EOF
if ! mv gai.conf /etc/gai.conf; then
# not writable, disable ipv6 through sysctl
sysctl -w net.ipv6.conf.all.disable_ipv6=1
rm -f gai.conf
fi

apt update
apt build-dep -y snapcraft
apt install -y bzr git curl mercurial subversion lxd python3-pep8 pyflakes python-flake8 python3-fixtures python3-pexpect python3-pyftpdlib python3-testscenarios
apt install -y squashfuse
apt install --yes gcc g++ make python3-dev python3-venv libffi-dev libsodium-dev libapt-pkg-dev libarchive13 squashfs-tools xdelta3 bzr git mercurial subversion
# Only required for the lxd backend.
apt install --yes squashfuse
mkdir -p /snapcraft/venv
python3 -m venv /snapcraft/venv
# XXX the activate script has an unbound variable.
sed -i '1s/^/set +u\n/' /snapcraft/venv/bin/activate
source /snapcraft/venv/bin/activate
pip install --upgrade pip
pip install -r /snapcraft/requirements.txt -r /snapcraft/requirements-devel.txt
apt install --yes snapd
snap install snapcraft --classic --edge
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait... I don't understand what's happening here. You're installing via pip, but also installing the snap. They'll both be in the path. Which one is being tested?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm installing only the requirements. They are all needed to run the integration tests. I didn't add the ., and take a look here where we chec that we are using the right command:
https://github.com/snapcore/snapcraft/pull/1374/files#diff-408b0efbb4ace174e50d6bd885ae24baL7

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh, stupid periods. So easy to miss. Thanks for the info!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yay!!!


path: /snapcraft/
1 change: 1 addition & 0 deletions spread_tests/integration/task.yaml
Expand Up @@ -5,5 +5,6 @@ execute: |
echo "Check that we are using the snapcraft snap"
snapcraft_path="$(which snapcraft)"
[ "$snapcraft_path" = "/snap/bin/snapcraft" ]
source /snapcraft/venv/bin/activate
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this necessary given that it's already in the suite's prepare step?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, apparently it happens in a different environment or something. I added it just because without it, it failed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, okay. Does it need to be in the suite's prepare step, then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry, I merged before reading this question.
Yes, how would I install the requirements in the venv without activating it?

cd /snapcraft
./runtests.sh integration
1 change: 1 addition & 0 deletions spread_tests/plugins/task.yaml
Expand Up @@ -5,5 +5,6 @@ execute: |
echo "Check that we are using the snapcraft snap"
snapcraft_path="$(which snapcraft)"
[ "$snapcraft_path" = "/snap/bin/snapcraft" ]
source /snapcraft/venv/bin/activate
cd /snapcraft
./runtests.sh plugins
1 change: 1 addition & 0 deletions spread_tests/store/task.yaml
Expand Up @@ -5,5 +5,6 @@ execute: |
echo "Check that we are using the snapcraft snap"
snapcraft_path="$(which snapcraft)"
[ "$snapcraft_path" = "/snap/bin/snapcraft" ]
source /snapcraft/venv/bin/activate
cd /snapcraft
./runtests.sh store