(t *testing.T)
| 150 | } |
| 151 | |
| 152 | func TestInternalUploadQueueMoreFiles(t *testing.T) { |
| 153 | id := fmt.Sprintf("tiuqmf%v", time.Now().Unix()) |
| 154 | rootFs, _ := runInstance.newCacheFs(t, remoteName, id, true, true, |
| 155 | map[string]string{"tmp_upload_path": path.Join(runInstance.tmpUploadDir, id), "tmp_wait_time": "1s"}) |
| 156 | |
| 157 | err := rootFs.Mkdir(context.Background(), "test") |
| 158 | require.NoError(t, err) |
| 159 | minSize := 5242880 |
| 160 | maxSize := 10485760 |
| 161 | totalFiles := 10 |
| 162 | randInstance := rand.New(rand.NewSource(time.Now().Unix())) |
| 163 | |
| 164 | lastFile := "" |
| 165 | for i := range totalFiles { |
| 166 | size := int64(randInstance.Intn(maxSize-minSize) + minSize) |
| 167 | testReader := runInstance.randomReader(t, size) |
| 168 | remote := "test/" + strconv.Itoa(i) + ".bin" |
| 169 | runInstance.writeRemoteReader(t, rootFs, remote, testReader) |
| 170 | |
| 171 | // validate that it exists in temp fs |
| 172 | ti, err := os.Stat(path.Join(runInstance.tmpUploadDir, id, runInstance.encryptRemoteIfNeeded(t, remote))) |
| 173 | require.NoError(t, err) |
| 174 | require.Equal(t, size, runInstance.cleanSize(t, ti.Size())) |
| 175 | |
| 176 | if runInstance.wrappedIsExternal && i < totalFiles-1 { |
| 177 | time.Sleep(time.Second * 3) |
| 178 | } |
| 179 | lastFile = remote |
| 180 | } |
| 181 | |
| 182 | // check if cache lists all files, likely temp upload didn't finish yet |
| 183 | de1, err := runInstance.list(t, rootFs, "test") |
| 184 | require.NoError(t, err) |
| 185 | require.Len(t, de1, totalFiles) |
| 186 | |
| 187 | // wait for background uploader to do its thing |
| 188 | runInstance.completeAllBackgroundUploads(t, rootFs, lastFile) |
| 189 | |
| 190 | // retry until we have no more temp files and fail if they don't go down to 0 |
| 191 | _, err = os.Stat(path.Join(runInstance.tmpUploadDir, id, runInstance.encryptRemoteIfNeeded(t, "test"))) |
| 192 | require.True(t, os.IsNotExist(err)) |
| 193 | |
| 194 | // check if cache lists all files |
| 195 | de1, err = runInstance.list(t, rootFs, "test") |
| 196 | require.NoError(t, err) |
| 197 | require.Len(t, de1, totalFiles) |
| 198 | } |
| 199 | |
| 200 | func TestInternalUploadTempFileOperations(t *testing.T) { |
| 201 | id := "tiutfo" |
nothing calls this directly
no test coverage detected
searching dependent graphs…