Skip to content

Commit 69c7f26

Browse files
authored
DATA-fix - Flip inequality (#3373)
1 parent b5085b4 commit 69c7f26

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

services/datamanager/builtin/sync_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ func TestArbitraryFileUpload(t *testing.T) {
327327
datasync.RetryExponentialFactor.Store(int32(1))
328328
fileName := "some_file_name.txt"
329329
fileExt := ".txt"
330-
330+
// Disable the check to see if the file was modified recently,
331+
// since we are testing instanteous arbitrary file uploads.
332+
datasync.SetFileLastModifiedMillis(0)
331333
tests := []struct {
332334
name string
333335
manualSync bool

services/datamanager/datasync/upload_arbitrary_file.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ import (
1616
var UploadChunkSize = 64 * 1024
1717

1818
// Default time to wait in milliseconds to check if a file has been modified.
19-
const defaultFileLastModifiedMillis = 10000.0
19+
var fileLastModifiedMillis = 10000
20+
21+
// SetFileLastModifiedMillis allows configuring the time to wait in milliseconds
22+
// to check if a file has been modified for arbitrary file uploads.
23+
func SetFileLastModifiedMillis(lastModifiedMillis int) {
24+
fileLastModifiedMillis = lastModifiedMillis
25+
}
2026

2127
var clock = clk.New()
2228

@@ -39,7 +45,7 @@ func uploadArbitraryFile(ctx context.Context, client v1.DataSyncServiceClient, f
3945
return err
4046
}
4147
timeSinceMod := clock.Since(info.ModTime())
42-
if timeSinceMod >= defaultFileLastModifiedMillis*time.Millisecond {
48+
if timeSinceMod < time.Duration(fileLastModifiedMillis)*time.Millisecond {
4349
return errors.New("file modified too recently")
4450
}
4551

0 commit comments

Comments
 (0)