influxdb/pkg
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
..
binaryutil Initial import pkg package 2018-10-01 12:03:20 +01:00
bloom chore: Skip tests on circleci 2020-08-31 12:14:27 -07:00
bytesutil refactor: rewrite imports to include the /v2 suffix for version 2 2020-04-03 12:39:20 -05:00
cmputil build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
data/gen chore: move v2/v1/tsdb → v2/tsdb 2020-08-26 10:46:47 -07:00
deep build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
durablequeue test: use `T.TempDir` to create temporary test directory (#23258) 2023-03-21 16:22:11 -04:00
encoding/simple8b chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
errors chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
escape chore(tsdb): Initial commit of tsdb package 2020-08-03 09:17:23 -07:00
estimator chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00
file build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
fs build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
httpc build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
jsonnet build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
jsonparser fix: more expressive errors (#22448) 2021-09-13 15:12:35 -04:00
limiter build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
metrics chore: update staticcheck and fix newly identified lint checks (#18737) 2020-06-26 18:54:09 -05:00
mincore build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
mmap fix: fully clean up partially opened TSI (#23430) (#23454) 2022-06-14 11:49:16 -07:00
pointer Fix typos in miscellaneous packages 2019-04-17 13:30:22 -07:00
pool fix(tsm1): limit concurrent WAL encodings to reduce memory pressure under heavy write load (#20814) 2021-06-03 16:11:36 -04:00
radix chore(tsdb): Initial commit of tsdb package 2020-08-03 09:17:23 -07:00
reporthelper feat: port report-db command from 1.x (#23922) 2022-11-21 11:23:13 -05:00
rhh chore: add goimports 2021-01-29 14:06:52 -05:00
slices chore(tsdb): Initial commit of tsdb package 2020-08-03 09:17:23 -07:00
snowflake Initial import pkg package 2018-10-01 12:03:20 +01:00
tar chore: remove duplicate word in comments (#23685) 2022-09-13 11:00:52 -05:00
testing/assert chore(gen): Add ingen generator data structures to platform for reuse 2018-12-11 17:45:57 -07:00
testttp chore(testtp): extend testtp request with SetFormValue 2020-04-16 14:39:07 -07:00
tracing chore: update to go 1.20 (#24088) 2023-02-09 14:14:35 -05:00