influxdb/tsdb/engine/tsm1
Eng Zer Jun 903d30d658
test: use `T.TempDir` to create temporary test directory (#23258)
* test: use `T.TempDir` to create temporary test directory

This commit replaces `os.MkdirTemp` with `t.TempDir` in tests. The
directory created by `t.TempDir` is automatically removed when the test
and all its subtests complete.

Prior to this commit, temporary directory created using `os.MkdirTemp`
needs to be removed manually by calling `os.RemoveAll`, which is omitted
in some tests. The error handling boilerplate e.g.
	defer func() {
		if err := os.RemoveAll(dir); err != nil {
			t.Fatal(err)
		}
	}
is also tedious, but `t.TempDir` handles this for us nicely.

Reference: https://pkg.go.dev/testing#T.TempDir
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix failing TestSendWrite on Windows

=== FAIL: replications/internal TestSendWrite (0.29s)
    logger.go:130: 2022-06-23T13:00:54.290Z	DEBUG	Created new durable queue for replication stream	{"id": "0000000000000001", "path": "C:\\Users\\circleci\\AppData\\Local\\Temp\\TestSendWrite1627281409\\001\\replicationq\\0000000000000001"}
    logger.go:130: 2022-06-23T13:00:54.457Z	ERROR	Error in replication stream	{"replication_id": "0000000000000001", "error": "remote timeout", "retries": 1}
    testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\circleci\AppData\Local\Temp\TestSendWrite1627281409\001\replicationq\0000000000000001\1: The process cannot access the file because it is being used by another process.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix failing TestStore_BadShard on Windows

=== FAIL: tsdb TestStore_BadShard (0.09s)
    logger.go:130: 2022-06-23T12:18:21.827Z	INFO	Using data dir	{"service": "store", "path": "C:\\Users\\circleci\\AppData\\Local\\Temp\\TestStore_BadShard1363295568\\001"}
    logger.go:130: 2022-06-23T12:18:21.827Z	INFO	Compaction settings	{"service": "store", "max_concurrent_compactions": 2, "throughput_bytes_per_second": 50331648, "throughput_bytes_per_second_burst": 50331648}
    logger.go:130: 2022-06-23T12:18:21.828Z	INFO	Open store (start)	{"service": "store", "op_name": "tsdb_open", "op_event": "start"}
    logger.go:130: 2022-06-23T12:18:21.828Z	INFO	Open store (end)	{"service": "store", "op_name": "tsdb_open", "op_event": "end", "op_elapsed": "77.3µs"}
    testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\circleci\AppData\Local\Temp\TestStore_BadShard1363295568\002\data\db0\rp0\1\index\0\L0-00000001.tsl: The process cannot access the file because it is being used by another process.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix failing TestPartition_PrependLogFile_Write_Fail and TestPartition_Compact_Write_Fail on Windows

=== FAIL: tsdb/index/tsi1 TestPartition_PrependLogFile_Write_Fail/write_MANIFEST (0.06s)
    testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\circleci\AppData\Local\Temp\TestPartition_PrependLogFile_Write_Failwrite_MANIFEST656030081\002\0\L0-00000003.tsl: The process cannot access the file because it is being used by another process.
    --- FAIL: TestPartition_PrependLogFile_Write_Fail/write_MANIFEST (0.06s)

=== FAIL: tsdb/index/tsi1 TestPartition_Compact_Write_Fail/write_MANIFEST (0.08s)
    testing.go:1090: TempDir RemoveAll cleanup: remove C:\Users\circleci\AppData\Local\Temp\TestPartition_Compact_Write_Failwrite_MANIFEST3398667527\002\0\L0-00000003.tsl: The process cannot access the file because it is being used by another process.
    --- FAIL: TestPartition_Compact_Write_Fail/write_MANIFEST (0.08s)

We must close the open file descriptor otherwise the temporary file
cannot be cleaned up on Windows.

Fixes: 619eb1cae6 ("fix: restore in-memory Manifest on write error")
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix failing TestReplicationStartMissingQueue on Windows

=== FAIL: TestReplicationStartMissingQueue (1.60s)
    logger.go:130: 2023-03-17T10:42:07.269Z	DEBUG	Created new durable queue for replication stream	{"id": "0000000000000001", "path": "C:\\Users\\circleci\\AppData\\Local\\Temp\\TestReplicationStartMissingQueue76668607\\001\\replicationq\\0000000000000001"}
    logger.go:130: 2023-03-17T10:42:07.305Z	INFO	Opened replication stream	{"id": "0000000000000001", "path": "C:\\Users\\circleci\\AppData\\Local\\Temp\\TestReplicationStartMissingQueue76668607\\001\\replicationq\\0000000000000001"}
    testing.go:1206: TempDir RemoveAll cleanup: remove C:\Users\circleci\AppData\Local\Temp\TestReplicationStartMissingQueue76668607\001\replicationq\0000000000000001\1: The process cannot access the file because it is being used by another process.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: update TestWAL_DiskSize

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

* test: fix failing TestWAL_DiskSize on Windows

=== FAIL: tsdb/engine/tsm1 TestWAL_DiskSize (2.65s)
    testing.go:1206: TempDir RemoveAll cleanup: remove C:\Users\circleci\AppData\Local\Temp\TestWAL_DiskSize2736073801\001\_00006.wal: The process cannot access the file because it is being used by another process.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

---------

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2023-03-21 16:22:11 -04:00
..
DESIGN.md chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
array_cursor.gen.go fix(storage): cursor requests are [start, stop] instead of [start, stop) (#21318) 2021-04-30 12:15:06 -04:00
array_cursor.gen.go.tmpl fix(storage): cursor requests are [start, stop] instead of [start, stop) (#21318) 2021-04-30 12:15:06 -04:00
array_cursor_iterator.gen.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
array_cursor_iterator.gen.go.tmpl chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
array_cursor_iterator.go fix(storage): cursor requests are [start, stop] instead of [start, stop) (#21318) 2021-04-30 12:15:06 -04:00
array_cursor_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
array_encoding.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
array_encoding_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
batch_boolean.go fix: typos (#19734) 2020-10-13 09:50:32 -07:00
batch_boolean_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
batch_float.go fix: correct various typos (#19987) 2020-11-11 13:54:21 -05:00
batch_float_test.go chore(influxdb): Placate the linter. 2020-08-27 15:46:32 -04:00
batch_integer.go fix: typos (#19734) 2020-10-13 09:50:32 -07:00
batch_integer_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
batch_string.go fix: typos (#19734) 2020-10-13 09:50:32 -07:00
batch_string_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
batch_timestamp.go fix: typos (#19734) 2020-10-13 09:50:32 -07:00
batch_timestamp_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
bit_reader.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
bit_reader_test.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
bool.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
bool_test.go refactor: delete old backup/restore CLI commands, replace with dependency on new CLI repo (#21703) 2021-06-17 09:18:55 -04:00
cache.go chore: remove duplicate word in comments (#23685) 2022-09-13 11:00:52 -05:00
cache_race_test.go feat: remaining storage metrics from OSS engine (#22938) 2021-12-02 09:01:46 -05:00
cache_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
compact.gen.go refactor: remove dead iterator code (#23887) 2022-11-09 19:26:12 -05:00
compact.gen.go.tmpl refactor: remove dead iterator code (#23887) 2022-11-09 19:26:12 -05:00
compact.gen.go.tmpldata chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
compact.go refactor: remove dead iterator code (#23887) 2022-11-09 19:26:12 -05:00
compact_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
digest.go fix: Do not close connection twice in DigestWithOptions (#21659) (#21662) 2021-06-10 13:32:36 -07:00
digest_reader.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
digest_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
digest_writer.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
digest_writer_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
encoding.gen.go chore(influxdb): Placate the linter. 2020-08-27 15:46:32 -04:00
encoding.gen.go.tmpl chore(influxdb): Placate the linter. 2020-08-27 15:46:32 -04:00
encoding.gen.go.tmpldata chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
encoding.gen_test.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
encoding.go chore(influxdb): Placate the linter. 2020-08-27 15:46:32 -04:00
encoding_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
engine.gen.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
engine.gen.go.tmpl chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
engine.go refactor: remove dead iterator code (#23887) 2022-11-09 19:26:12 -05:00
engine_cursor.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
engine_internal_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
engine_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
file_store.gen.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
file_store.gen.go.tmpl refactor: remove dead iterator code (#23887) 2022-11-09 19:26:12 -05:00
file_store.gen.go.tmpldata chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
file_store.go feat: remaining storage metrics from OSS engine (#22938) 2021-12-02 09:01:46 -05:00
file_store_array.gen.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
file_store_array_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
file_store_key_iterator.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
file_store_key_iterator_test.go fix(tsm1): fix data race when accessing tombstone stats (#20773) 2021-02-18 20:23:57 -05:00
file_store_observer.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
file_store_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
float.go fix: typos (#19734) 2020-10-13 09:50:32 -07:00
float_test.go refactor: delete old backup/restore CLI commands, replace with dependency on new CLI repo (#21703) 2021-06-17 09:18:55 -04:00
int.go chore: remove duplicate word in comments (#23685) 2022-09-13 11:00:52 -05:00
int_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
iterator.gen.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
iterator.gen.go.tmpl chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
iterator.gen.go.tmpldata chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
iterator.go feat(tsi): optimize series iteration (#22316) 2021-08-27 09:59:23 -04:00
iterator_test.go test: replace influxlogger with zaptest logger (#20589) 2021-02-11 10:12:39 -05:00
mmap_unix.go build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
mmap_windows.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
pools.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
predicate.go build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
predicate_test.go build: upgrade protobuf library (#22654) 2021-11-02 16:00:54 -05:00
reader.gen.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
reader.gen.go.tmpl chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
reader.gen.go.tmpldata chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
reader.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
reader_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
ring.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
ring_test.go refactor: Remove unused function add and unused variable keysHint (#20803) 2021-02-25 08:31:00 -05:00
scheduler.go feat: tsm compaction metrics via prometheus (#22904) 2021-11-19 14:51:22 -05:00
scheduler_test.go feat: tsm compaction metrics via prometheus (#22904) 2021-11-19 14:51:22 -05:00
string.go chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
string_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
timestamp.go chore: remove duplicate word in comments (#23685) 2022-09-13 11:00:52 -05:00
timestamp_test.go chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
tombstone.go chore: use io/os over ioutil (#22656) 2021-10-12 16:55:07 -05:00
tombstone_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
wal.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
wal_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
writer.go chore: remove duplicate word in comments (#23685) 2022-09-13 11:00:52 -05:00
writer_test.go test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00