Commit 35bc8e7e authored by Alessio Caiazza's avatar Alessio Caiazza

Reproduce exif upload failure

Exif cleaner do not support additional reads after the underling process is completed.

When the Object Storage configuration requires a MultipartUpload,
workhorse loops over the input with a LimitReader,
such loop will call Read one extra time to make
sure the input was consumed entirely.

Related to: https://gitlab.com/gitlab-org/gitlab-workhorse/-/issues/233
parent 824f842f
...@@ -75,3 +75,21 @@ func TestNewCleanerWithInvalidFile(t *testing.T) { ...@@ -75,3 +75,21 @@ func TestNewCleanerWithInvalidFile(t *testing.T) {
require.Error(t, err, "Expected error when reading output") require.Error(t, err, "Expected error when reading output")
require.Equal(t, int64(0), size, "Size of invalid image should be 0") require.Equal(t, int64(0), size, "Size of invalid image should be 0")
} }
func TestNewCleanerReadingAfterEOF(t *testing.T) {
input, err := os.Open("testdata/sample_exif.jpg")
require.NoError(t, err)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
cleaner, err := NewCleaner(ctx, input)
require.NoError(t, err, "Expected no error when creating cleaner command")
_, err = io.Copy(ioutil.Discard, cleaner)
require.NoError(t, err, "Expected no error when reading output")
buf := make([]byte, 1)
size, err := cleaner.Read(buf)
require.Equal(t, 0, size, "The output was already consumed by previous reads")
require.Equal(t, io.EOF, err, "We return EOF")
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment