Skip to content

tests: online variants#5234

Open
pks-t wants to merge 12 commits into
libgit2:mainfrom
pks-t:pks/tests-online-variants
Open

tests: online variants#5234
pks-t wants to merge 12 commits into
libgit2:mainfrom
pks-t:pks/tests-online-variants

Conversation

@pks-t

@pks-t pks-t commented Sep 19, 2019

Copy link
Copy Markdown
Member

My initial goal has been to clean up our online tests a bit, because I had quite some problems to grasp everything that's going on with environment variables etc. While splitting up the tests I realized that it's quite easy to use our new clar variants for online::clone::http, so I've implemented them.

Due to this we now have additional tests with GitLab (I manage the libgit2 group in GitLab and thus added the required repos). I'd love to test against Azure more thoroughly as well, but I'll have to defer to @ethomson for this. Could you maybe push our libgit2/testgitrepository and libgit2/testemptyproject repos to Azure so that we can add these as variants?

@ethomson

Copy link
Copy Markdown
Member

@pks-t

pks-t commented Sep 21, 2019

Copy link
Copy Markdown
Member Author

Oh, perfect, thanks for letting me know, in that case I'll make use of them. Will have to find out why there is a new memory leak in libssh2 now that even exists if the SSH tests aren't executed at all. Will do after I've polished up the other PRs.

@pks-t pks-t force-pushed the pks/tests-online-variants branch from aeda027 to 1412769 Compare September 21, 2019 14:52
@pks-t

pks-t commented Sep 21, 2019

Copy link
Copy Markdown
Member Author

There was one real memory leak on macOS which I've fixed. The other leaks already exist in master, no idea why I uncovered them just now :/

@pks-t

pks-t commented Sep 21, 2019

Copy link
Copy Markdown
Member Author

Well, they do exist on master now, too. Meh. Will fix...

https://dev.azure.com/libgit2/libgit2/_build/results?buildId=2664

@pks-t pks-t force-pushed the pks/tests-online-variants branch 2 times, most recently from eff7a20 to d549369 Compare September 21, 2019 16:05
@pks-t

pks-t commented Sep 21, 2019

Copy link
Copy Markdown
Member Author

Rebased on top of #5240. Added "test" and "empty" repos to the Azure variant

@pks-t pks-t force-pushed the pks/tests-online-variants branch 8 times, most recently from c5b197f to f1665a5 Compare September 27, 2019 08:57
pks-t added 12 commits October 10, 2019 12:35
On reading from an HTTP stream, when the server has closed a keepalive
socket or when receiving a 401 Unauthorized error, we try to re-connect
the HTTP stream in order to replay the authentication. When failing to
reconnect, we exit directly from the function and thus fail to cleanup
the request buffer.

Fix the memory leak by using `goto done` instead.
When trying to allocate the username that is required to ask for SSH
authentification methods, we check the return value of `git__strdup` but
will not set up a proper error code. Because of this,
`_git_ssh_setup_conn` may return successfully while there was in fact an
out of memory error.

Fix the issue by calling `git_error_set_oom` and setting the error code
to `-1`.
When creating the reflog message "clone: from %s", we do not check the
call to `git_buf_printf` for an error. As we use `git_buf_cstr`
immediately afterwards, we may thus try to use the `git_buf_oom` buffer
without noticing. While this is unproblematic due to the buffer
containing a single NUL byte, only, we should certainly notice
out-of-memory situations early.

Fix this by checking the return value of `git_buf_printf`.
In order to be able to verify that SSH authentication with user and
password works correctly, we need to first set up a password and make it
available via the GITTEST_REMOTE_PASS environment variable.
The test suite online::clone::env will by default refuse any
certificates presented by the remote configured via environment
variables. In order for the tests to succeed with our instance of sshd,
we should either make the expected host key available via the
environment or alternatively just override it by setting
GITTEST_REMOTE_SSL_NOVERIFY.

This commit goes the easier way of just overriding the check, as the
point of the whole series is to first get the online::clone test suite
into a state where it's much easier to improve it at a later point in
time.
The libssh2 library may leak memory when performing the session
handshake in various edge cases, like e.g. timeouts. As there is
multiple memleaks that may happen, depending on when the exact failure
happens inside of libssh2_session_handshake, we shouldn't specify a
detailed stack of which memleaks to suppress, but just suppress all that
happen with `libssh2_session_handshake`.
The clone::nonetwork test suite still has a define for a GitHub
repository URL, which naturally is not tested in the no-network test
suite anymore. Remove it.
Modernize coding style of the clone test suite. Most importantly, we
introduce defines for each of the repo URLS and consistently rely on the
cleanup function to remove the sandbox repository for us.
The test suite online::clone is quite huge and hard to grasp. It
intermingles tests for HTTP and SSH-based clones as well as the ones
that make use of a server defined via environment variables. Split these
all up into different tests to make the suites more focused as well as
easier to understand. Furthermore, this will allow us to introduce
variants for our HTTP tests to more thoroughly test against different
external hosting services.
Right now, we only run each clone test against a single Git provider,
making it hard to understand which features are tested against which
provide. Furthermore, more intricate behaviour like e.g. authentication
is thus not thoroughly tested against the different implementations,
which may differ slightly across hosters.

Introduce test variants to start fixing this. For each provider, we will
initialize an optional set of URLs to test against where each URL aims
to exercise some specific behaviour. For now, we implement tests against
GitHub, Bitbucket, Azure and GitLab. Tests against GitLab and Azure are
completely new.

The variants also uncovered behavioural inconsistencies in how Bitbucket
handles nonexistent repositories: instead of trying to authenticate, it
will directly return a 404 status code and thus reveal that no such repo
exists, not even in private. We thus special-case this behaviour in our
test suite.
@pks-t pks-t force-pushed the pks/tests-online-variants branch from f1665a5 to e980cf5 Compare October 10, 2019 10:36
Base automatically changed from master to main January 7, 2021 10:09
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.

2 participants