Skip to content

[wip] better tests for handling server failures - #676

Merged
technoweenie merged 10 commits into
masterfrom
better-server-failure-handling-tests
Sep 21, 2015
Merged

technoweenie merged 10 commits into
masterfrom
better-server-failure-handling-tests

Conversation

@technoweenie

Copy link
Copy Markdown
Contributor

No description provided.

@technoweenie

Copy link
Copy Markdown
Contributor Author

This is an attempt to test various failure scenarios so we can catch things like #675 before they happen. Ideally, this PR fails until #675 is merged in, but I don't think that's quite the case just yet. But before I dig in, is this on the right track? Do the tests look useful?

I went with magic content strings because then it should be clear that the integration test is trying to trigger specific failure behavior on the server. The case statements are a lot more clear, despite the lines of copied code. If this approach works, we can replace testingChunkedTransferEncoding() with a magic string too.

old api doesnt have the error object on the json responses
seems to help keep the output of the parallel scripts consistent
@technoweenie

Copy link
Copy Markdown
Contributor Author

While writing this, I expected all of the push tests with the batch api to pass, and the push tests with the legacy api to fail until #675 was merged. However, the batch api tests were failing too.

# STDOUT
    Tracking *.dat
    [master (root-commit) bdc7654] welp
     3 files changed, 7 insertions(+)
     create mode 100644 .gitattributes
     create mode 100644 bad.dat
     create mode 100644 good.dat
(1 of 2 files, 1 skipped) 2 B / 18 B, 16 B skipped                             
    push successful?

# STDERR
    + git lfs track '*.dat'
    + printf hi
    + printf status-batch-403
    + git add .gitattributes good.dat bad.dat
    + git commit -m welp
    + set +e
    + git push origin master
    To http://127.0.0.1:58006/test-push-failures-status-batch-403
     * [new branch]      master -> master
    + '[' 0 = 0 ']'
    + echo 'push successful?'
    + exit 1

Looks like the file was being skipped, but not treated as an error. 3671cc7 changes the batch response handler too look for an object error before looking for a link relation.

@technoweenie

Copy link
Copy Markdown
Contributor Author

@rubyist

rubyist commented Sep 21, 2015

Copy link
Copy Markdown
Contributor

:shipit:

@technoweenie

Copy link
Copy Markdown
Contributor Author

technoweenie added a commit that referenced this pull request Sep 21, 2015
[wip] better tests for handling server failures
@technoweenie
technoweenie merged commit 8e2638b into master Sep 21, 2015
@technoweenie
technoweenie deleted the better-server-failure-handling-tests branch September 21, 2015 21:02
chrisd8088 added a commit to chrisd8088/git-lfs that referenced this pull request Jun 23, 2026
Since we first introduced the calc_oid() helper function to our
shell test suite in commit 54601c6
of PR git-lfs#676, we have used the "printf" shell built-in command to pass
the function's first parameter to a program which calculates the
SHA-256 hash of its input.  (Note that the specific program used
for this purpose depends on the operating system.)

However, because the calc_oid() function assigns its first parameter
to be the "format" argument of the "printf" built-in command, if the
parameter were to contain any backslash characters or format
specifications like "%d", the hash value calculated from the
argument's contents might not match the value we expect.

In a subsequent commit in this PR we intend to revise several of
our shell tests to make use of the calc_oid() function with
dynamically-generated data of various sizes.  This data should
not contain any special formatting characters like "\" or "%".

Nevertheless, we can guard against the possibility that such
characters might be inadvertently introduced in the future by using
"%s" as the "format" argument of the "printf" built-in command, and
then passing the calc_oid() function's first parameter as the second
argument of the "printf" command.  This guarantees that the
function's parameter will be interpolated in place of the "%s"
format specification in a literal, unmodified form.

We then update four of our shell tests that depend on the legacy
behaviour of the calc_oid() function to convert the character
sequence "\n" into an LF (linefeed) character.  In each of these
tests, we can simply use our calc_oid_file() helper function
to determine the SHA-256 hash of a given file's contents, instead
of passing a string which represents the contents of the file to
the calc_oid() function.
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