tests, integration-tests: port network interface test to spread #1367

Merged
merged 4 commits into from Jun 22, 2016

Conversation

Projects
None yet
4 participants
Contributor

fgimenez commented Jun 21, 2016

No description provided.

fgimenez added some commits Jun 21, 2016

Contributor

zyga commented Jun 22, 2016

+1

Contributor

zyga commented Jun 22, 2016

The code looks good but tests fail:

+ echo Given a snap declaring the network plug is installed
Given a snap declaring the network plug is installed
+ snapbuild ../lib/snaps/network-consumer .
snapbuild: open ../lib/snaps/network-consumer/meta/snap.yaml: no such file or directory
-----
2016/06/22 08:00:34 Restoring linode:ubuntu-16.04-32-grub:tests/interfaces-network...
2016/06/22 08:00:34 Error restoring linode:ubuntu-16.04-32-grub:tests/interfaces-network : 
-----
+ sudo snap remove network-consumer
error: cannot remove "network-consumer": cannot find snap "network-consumer"
Contributor

zyga commented Jun 22, 2016

+1, except tests fail now

Contributor

fgimenez commented Jun 22, 2016

@zyga yep, a problem with the snap path, fixed.

Thanks!

Member

kyrofa commented Jun 22, 2016

autopkgtest is failing.

Contributor

fgimenez commented Jun 22, 2016

retest this please

Contributor

fgimenez commented Jun 22, 2016

@kyrofa yep mmm the failing test shouldn't be affected by these changes, the snaps have been copied, not moved, and are not changed, i've retriggered them to confirm the error

tests/interfaces-network/task.yaml
@@ -0,0 +1,85 @@
+summary: |
@niemeyer

niemeyer Jun 22, 2016

Contributor

The summary should really be a be a one-line short summary. Something like "Ensure network interface works."

The content below is nice, though, and should go under:

details: |
    The network interface ...
@fgimenez

fgimenez Jun 22, 2016

Contributor

Nice, done, didn't know before of the details key :)

tests/interfaces-network/task.yaml
+ SERVICE_FILE: "./service.sh"
+ SERVICE_NAME: "test-service"
+
+kill-wait: 1m
@niemeyer

niemeyer Jun 22, 2016

Contributor

Let's please not have 1m kill timeout on anything unless it's extremely trivial. Otherwise it's way too short.. any sort of network instability would kill the test, as has happened before in the other case we discussed yesterday.

Also note that the field is kill-timeout not kill-wait.

@fgimenez

fgimenez Jun 22, 2016

Contributor

ok, removed

tests/interfaces-network/task.yaml
+environment:
+ SNAP_NAME: network-consumer
+ SNAP_FILE: "./$[SNAP_NAME]_1.0_all.snap"
+ PLUG: network
@niemeyer

niemeyer Jun 22, 2016

Contributor

Can we please have the word "network" inlined instead of this variable? This is a constant really, and is used in contexts which are not about a plug, specifically. So it's obscuring the test rather than helping out.

@fgimenez

fgimenez Jun 22, 2016

Contributor

Done, this could allow us to share common bits between all the interface tests, but now it isn't useful at all

tests/interfaces-network/task.yaml
+prepare: |
+ echo "Given a snap declaring the $PLUG plug is installed"
+ snapbuild ../lib/snaps/$SNAP_NAME .
+ sudo snap install $SNAP_FILE
@niemeyer

niemeyer Jun 22, 2016

Contributor

Please drop all use of sudo. We're root.

@fgimenez

fgimenez Jun 22, 2016

Contributor

ok done

tests/interfaces-network/task.yaml
+ SNAP_FILE: "./$[SNAP_NAME]_1.0_all.snap"
+ PLUG: network
+ PORT: 8081
+ REQUEST_FILE: "./request.txt"
@niemeyer

niemeyer Jun 22, 2016

Contributor

Unused?

@fgimenez

fgimenez Jun 22, 2016

Contributor

yes, this comes from the network-bind interface test, removed

tests/interfaces-network/task.yaml
+ EOF
+
+restore: |
+ sudo snap remove $SNAP_NAME
@niemeyer

niemeyer Jun 22, 2016

Contributor

This must not be required. We're resetting the state on the suite.

tests/interfaces-network/task.yaml
+ while ! netstat -lnt | grep -Pq "tcp.*?:$PORT +.*?LISTEN\n*"; do sleep 0.5; done
+
+ echo "And we store a basic HTTP request"
+ cat > $REQUEST_FILE <<EOF
@niemeyer

niemeyer Jun 22, 2016

Contributor

echo "GET / HTTP/1.0\n\n" > $REQUEST_FILE

But I believe REQUEST_FILE isn't being used at all?

tests/interfaces-network/task.yaml
+ PLUG: network
+ PORT: 8081
+ REQUEST_FILE: "./request.txt"
+ SERVICE_FILE: "./service.sh"
@niemeyer

niemeyer Jun 22, 2016

Contributor

rm -f on restore?

@fgimenez

fgimenez Jun 22, 2016

Contributor

yes, that was missing

tests/interfaces-network/task.yaml
+restore: |
+ sudo snap remove $SNAP_NAME
+ rm -f $SNAP_FILE $REQUEST_FILE
+ sudo systemctl stop $SERVICE_NAME
@niemeyer

niemeyer Jun 22, 2016

Contributor

It's a good practice to first stop the activity, then remove content. Not sure if it makes a difference on this specific test, though.

@fgimenez

fgimenez Jun 22, 2016

Contributor

yes, the service only depends on SERVICE_FILE, and it wasn't being removed :) Now it's in the right order, the service is stopped and the file removed afterwards

@niemeyer niemeyer merged commit cdcf360 into snapcore:master Jun 22, 2016

2 of 3 checks passed

autopkgtest Started
Details
Integration tests Success 18 tests run, 0 skipped, 0 failed.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment