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

Test suite hardening #209

Merged
merged 38 commits into from
Nov 23, 2017
Merged

Test suite hardening #209

merged 38 commits into from
Nov 23, 2017

Conversation

dridi
Copy link
Member

@dridi dridi commented Oct 4, 2017

This is work in progress, following #207 I already pushed some improvements but I feel that these changes should run on more than just my system.

Don't hesitate to start reviewing it sooner than later, even though it is far from complete. This should give a precise idea of the direction I'm taking, and how writing test cases should be overall more readable and less error-prone if it proves to be a good direction.

@dridi
Copy link
Member Author

dridi commented Oct 5, 2017

One of my concerns regarding other platforms is the need of lsof that may not have everything we need on older platforms. Also lsof detection isn't done yet in the configure script.

@dridi
Copy link
Member Author

dridi commented Oct 5, 2017

This is almost complete, the remaining bits from the old setup that I need to go over is now tiny:

# begin old setup

export LC_ALL=C

LISTENPORT=`expr $$ % 62000 + 1024`
CERTSDIR="${TESTDIR}/certs"
CONFDIR="${TESTDIR}/configs"

# end old setup

The only part for which I don't have a clear plan is ensuring that no port collisions may occur. I will likely add a new test helper for ports but keep today's best-effort poor-man's pseudo-pseudo-random port selection.

Then I'll document the helpers a bit, and see how to further improve the readability of test reports.

See XXX comments in the test suite to get an idea of where polish is needed.

@daghf
Copy link
Member

daghf commented Oct 18, 2017

I've only had a quick look for now, but this is looking really good!

I think the following is the only thing needed to fix make dist, with that I'd be happy to merge.

diff --git a/src/Makefile.am b/src/Makefile.am
index 40500e0..e72a86e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,7 +3,7 @@ sbin_PROGRAMS = hitch
 noinst_LIBRARIES = libcfg.a libforeign.a
 
 EXTRA_DIST = \
-       $(top_srcdir)/src/tests/common.sh \
+       $(top_srcdir)/src/tests/hitch_test.sh \
        $(top_srcdir)/src/tests/test*.sh \
        $(top_srcdir)/src/tests/certs/* \
        $(top_srcdir)/src/tests/configs/default.cfg

@dridi
Copy link
Member Author

dridi commented Oct 19, 2017

This is embarrassing...

However before fixing this, can you have a look at the XXX comments I added to the test suite? At least those present in test cases:

$ git grep XXX src/tests/test*.sh
src/tests/test07-nomatch-abort.sh:# XXX: why don't we expect 'unrecognized name' again?
src/tests/test08-test-configs.sh:# XXX: unclear check
src/tests/test11-cfg.sh:# XXX: reload only works with absolute paths
src/tests/test15-proxy-v2-npn.sh:# XXX: why do we expect ALPN and not NPN here?
src/tests/test23-tls-protos-tls1_2.sh:# XXX: find how to detect the lack of SSLv3
src/tests/test24-tls-protos-tls1_1.sh:# XXX: find how to detect the lack of SSLv3

Since this work is incomplete, I may push the rest directly if you agree.

@dridi
Copy link
Member Author

dridi commented Oct 31, 2017

Rebased against master, but not ready to merge because the test cases introduced since this pull request was opened aren't migrated yet.

When hitch fails, we are currently blind in the test report. For that I added e4a115e to dump any *.log files found upon failure. Currently that means adding manually log-filename = "something.log" when --config is used. Having the ability to specify a log file on the command line could be used transparently by all tests. A --verbose option would be nice too to "unquiet" the --daemon option for test cases.

@dridi
Copy link
Member Author

dridi commented Oct 31, 2017

As pointed out by @daghf, we already have --log-filename available from the command line, so I just pushed b3b1298.

@ghost
Copy link

ghost commented Nov 7, 2017

OpenBSD doesn't have losof(8). Getting rid of in in the test suite is still on my todo but I'll be happy if anyone beats me to it.

@dridi
Copy link
Member Author

dridi commented Nov 7, 2017

@klenan, thanks for letting us know, I can take care of it and switch to sockstat(1) instead. This pull request is waiting until master is in a merge-able state anyway so I'm not pushing anything until other known issues are solved and remaining tests are ported.

dridi added 13 commits November 13, 2017 10:41
Instead of having all tests repeat the same boilerplate, move the
requirements in one place and generalize the handling of PID files
inside the temp directory.
It takes care of feeding them newlines or checking that options like
-alpn are supported. Start using it in NPN and ALPN test cases.

About this trick:

    ! grep ERROR $DUMPFILE

Instead of using run_cmd we can grep for errors, but this will fail when
there are no errors. With `set -e` enforced in tests 15 and 16 the lack
of error would fail the whole test. So instead the exit status must be
non-zero (thanks to the ! prefix) and when errors occur they are printed
thanks to the lack of a -q option.
Instead provide a reusable test helper.
Now that tests cd in their own temp directory, we can use that to make
things a lot more readable.
dridi and others added 14 commits November 13, 2017 10:41
Test 19 is now half as small because both frontend and global variants
are tested at once.
Whatever happened to test 26, test 27 highlights reload problems with
regard to relative file names.
And keep these functions as part of the new test setup.
The $(...) notation is in POSIX and should be preferred.
Since --daemon implies --quiet, drop it from `start_hitch`.
@dridi
Copy link
Member Author

dridi commented Nov 13, 2017

Rebased against current master, with the addition of 8d796e5 for the tests that were added after the pull request was started. Previous test failures are gone, but test 27 shows relative paths problems.

I believe we can merge this into master, and keep the remaining enhancements for later. One more time, please pay attention to the XXX comments throughout the test suite.


# XXX: unclear check
Copy link

Choose a reason for hiding this comment

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

See the referenced issue #52 (and #22).

You seem to have removed the successfull return check after the --config=... --help invocation, I suggest adding that back in and also leaving the --test --config=... test in place.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm confused by the error message not matching the actual command (--test vs --help) but with #52 and #22 I can see it was probably a matter of copy/pasta. I will re-enable this check, thanks.


# this will fail on platforms that have OpenSSL compiled without SSLv3
openssl s_client -connect $LISTENADDR:$LISTENPORT -tls1_2
test $? -eq 0 || die "Connecting using TLS 1.2 failed."
# XXX: find how to detect the lack of SSLv3
Copy link

Choose a reason for hiding this comment

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

One naive way would be to check for the -ssl3 flag missing (note how -no_ssl3 is still there):
$ openssl s_client -help 2>&1 | grep -Fq -- -ssl3

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want to run s_client in a sub-shell (referring to a previous comment) and -ssl3 wasn't used in the the original test, so I'd need to build openssland find out myself. Otherwise the new check is as comprehensive as the old one. I should probably document how to use the test helpers, I was at least planning to...

But we could do something like this:

openssl s_client -help 2>&1 |
grep -q -e -ssl3 ||
skip "no ssl3 support"

Same as here:

https://github.com/Dridi/hitch/blob/8d796e591db5c06e228f2568b61894af84fe8488/src/tests/test25-dynamic-backend-address.sh#L10-L12

@dridi
Copy link
Member Author

dridi commented Nov 13, 2017

Ready to be merged IMO, and I will retire lsof with a new patch later. The last commit in the list documents the new shell functions and how they are meant to be used. I encourage anyone dealing with the test suite to have a look.

Cheers!

@daghf
Copy link
Member

daghf commented Nov 22, 2017

No complaints from me - great work.

With any remaining issues(?) it's regardless a big net improvement from the current testing setup, so please go ahead and merge.

@dridi
Copy link
Member Author

dridi commented Nov 22, 2017

Instead of merging I decided to get a quick stab at lsof independence, and added 6f8cc44, because my last make check before hitting the merge button didn't go well.

After upgrading to Fedora 27 I have one test failure and one test error (consistently). Off the top of my head one possible related change is that now Fedora is building curl with openssl instead of GnuTLS (but I'm not certain this change was made, poor memory).

[ 1299] {core} Child 1300 was terminated by signal 11.

In order to implement the sockstat support I took 10 minutes to spin up a FreeBSD 11 system, and while the patch was trivial to write, I'm still left performing the ancient ritual of head-scratching trying to understand why two tests fail and two tests err.

[12026] WARNING: {core} Unable to notify worker 12045 with changed backend address (Bad file descriptor).

@klenan, please let us know how things pan out on OpenBSD with the latest patch.

Courtesy of my recent OS upgrade ;)

@daghf
Copy link
Member

daghf commented Nov 22, 2017

I think the test errors you are seeing are due to breakage in the backend refresh bits, hopefully addressed by @dmatetelki in PR #224

@dmatetelki
Copy link
Contributor

dmatetelki commented Nov 23, 2017

@dridi: My PR #224 fixes some broken things, including the child terminated by signal 11. I would vote for get this PR in, so I can apply mine.

@dridi
Copy link
Member Author

dridi commented Nov 23, 2017

@klenan, I'm getting this increasing pressure to merge from the team. Once you have time to test this, please either comment here if it works fine on OpenBSD or open a new issue if it doesn't.

Thanks for the reviews!

@dridi dridi merged commit 5ce3d14 into varnish:master Nov 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants