Commit Graph

241 Commits (master)

Author SHA1 Message Date
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
Jeffrey Smith II 090f681737
feat: Add remotes and replications to telemetry (#23456)
* feat: start work on remotes/replications phone home data

* feat: add remotes/replications phone home data (no tests

* refactor: use erroring binary conversions

* style: gofmt

* refactor: improve some error handling

* style: cleanup

* feat: add tests

* refactor: just list remotes/replications rather than decrement

* chore: linting fix

Co-authored-by: DStrand1 <dstrandboge@influxdata.com>
2022-06-16 14:48:06 -04:00
Dane Strandboge 82d1123e78
build: upgrade to Go 1.18.1 (#23252) 2022-04-13 15:24:27 -05:00
Sam Arnold 5015297d40
fix: more expressive errors (#22448)
* fix: more expressive errors

Closes #22446

* fix: server only logging for untyped errors

* chore: fix formatting
2021-09-13 15:12:35 -04:00
Daniel Moran dc3b501298
refactor: rename Lock/Unlock on KV stores to RLock/RUnlock (#22357) 2021-08-31 17:03:54 -04:00
William Baker b5b36b2804
feat: migrations for annotations & notebooks resource types on operator token (#21840)
* feat: migration for operator token to include permissions for annotations and notebooks

* feat: run migrations for restored dbs

* chore: cleanup go.mod

* chore: better description comment for migration

* fix: fixed cursor return condition

* fix: hard code the list of old operator permissions

* feat: run migrations prior to swapping restored dbs

* fix: fix the sqlite migrator

* chore: update CHANGELOG
2021-07-14 09:23:25 -05:00
William Baker b0ea3b6675
feat: backup and restore sqlite database (#21584)
* feat: new metadata backup endpoint

* feat: added restore/sql API endpoint

* fix: content-type is multipart/mixed, part names are kv and sql

* fix: changed multipart manifest to buckets and made it .json

* feat: added lock for backing up sqlite and bolt dbs

* fix: use read lock instead of write lock on kv during backup

* fix: use filepath.Join for temp dirs
2021-06-02 19:07:53 -04:00
Daniel Moran 00afd95cb7
refactor: automated move of errors and id from root to kit (#21101)
Co-authored-by: Sam Arnold <sarnold@influxdata.com>
2021-03-30 14:10:02 -04:00
Daniel Moran 4c59a34bae
fix(bolt): prevent concurrent access to telegraf plugin metrics cache (#21042) 2021-03-23 14:16:14 -04:00
Daniel Moran 1fa321d85c
fix: inject more specific error message for bolt on shared FS (#20489) 2021-01-11 13:08:47 -08:00
Ben Johnson 419b0cf76b feat: Implement full restore 2020-11-05 10:05:01 -07:00
Gershon Shif d8a10e5311
chore: update circleci config to use golang:1.15 images (#19624)
* chore: update circleci config to use golang:1.15 images

* fix: Update Go version and use temporary override for Arrow

The Arrow override is to fix race detection problem. Once the
Arrow PR merges, this override can be removed.

Co-authored-by: Stuart Carnie <stuart.carnie@gmail.com>
2020-09-23 14:07:13 -07:00
Stuart Carnie 39ab4a10c5
Merge remote-tracking branch 'origin/master' into sgc/tsm1
# Conflicts:
#	cmd/influxd/launcher/query_test.go
#	go.mod
#	go.sum
#	query/promql/internal/promqltests/go.mod
#	task/backend/executor/executor.go
#	task/backend/executor/support_test.go
2020-08-26 09:26:43 -07:00
George e2e954b47a
feat(kv): add support for WithCursorLimit to ForwardCursor (#17524) 2020-08-26 12:10:00 +01:00
Stuart Carnie 3d14b1128e
fix: Speed up tests by disabling bolt fsync 2020-08-03 09:20:51 -07:00
George 1b6d9abc00
chore(bolt): add option to skip fsync for test purposes (#19037) 2020-07-24 10:13:05 +01:00
George 96d84b9126
refactor: migrator and introduce Store.(Create|Delete)Bucket (#18570)
* refactor: migrator and introduce Store.(Create|Delete)Bucket

feat: kvmigration internal utility to create / managing kv store migrations

fix: ensure migrations applied in all test cases

* chore: update kv and migration documentation
2020-07-01 12:08:20 +01:00
Jonathan A. Sternberg 5aeca082c8
chore: update staticcheck and fix newly identified lint checks (#18737) 2020-06-26 18:54:09 -05:00
Jonathan A. Sternberg 0ae8bebd75
refactor: rewrite imports to include the /v2 suffix for version 2 2020-04-03 12:39:20 -05:00
George 9d5d63518d
feat(kv): add support for batch getting keys on bucket interface (#17531) 2020-04-01 17:51:35 +01:00
George 1d400a4f0f
feat(kv): support for migrations (#17145)
* feat(kv): migration types for managing kv buckets and indexes over time

chore(kv): fixup comments in migrator types

fix(kv): initialize migrator bucket on kv service initialize

chore(kv): remove currently unused auth index

chore(kv): remove currently unused urm index

* chore(kv): move migrator tests into testing package and run for inmem and bolt

* chore(changelog): update changelog to reflect kv migrator type

* fix(kv): update auto migration store to return migratable store

* chore(kv): wrap error using func instead of defer in index

* chore(kv): rename Name method to MigrationName for clarity

* chore(kv): update migration log messages to match influxdb standard
2020-03-18 12:23:51 +00:00
George fe990aa4db
feat(kv): add cursor option skip first item (#16758) 2020-02-06 12:18:47 -07:00
Greg e593119c3d
feat: report telegraf plugin usage metrics (#16378)
* Begin implementing retreival of telegraf plugin stats

* Implement storing/deletion of telegraf plugin stats

* Test plugin stats

* Initialize plugins bucket for tests

* Add comment

* Shorten time and frequency in bolt when providing telegraf plugins metrics

* Simplify ticker loop

* Leak underlying ticker while still satisfying linter
2020-02-04 08:24:58 -07:00
Lyon Hill 635be50323
fix(kv): Update dashboard collection to use new forward cursor (#16626)
By updating to the new forward pointer the query should be more efficient.
2020-01-22 11:01:09 -07:00
George 8b2109362d fix(kv): use forward cursor in find all buckets (#16605)
* fix(kv): use forward cursor in find all buckets

Co-authored-by: Lyon Hill <lyondhill@gmail.com>
2020-01-21 15:27:47 -07:00
Jacob Marble b836ab9c17
feat(storage): implement backup and restore (#16504)
* feat(backup): `influx backup` creates data backup

* feat(backup): initial restore work

* feat(restore): initial restore impl

Adds a restore tool which does offline restore of data and metadata.

* fix(restore): pr cleanup

* fix(restore): fix data dir creation

* fix(restore): pr cleanup

* chore: amend CHANGELOG

* fix: restore to empty dir fails differently

* feat(backup): backup and restore credentials

Saves the credentials file to backups and restores it from backups.

Additionally adds some logging for errors when fetching backup files.

* fix(restore): add missed commit

* fix(restore): pr cleanup

* fix(restore): fix default credentials restore path

* fix(backup): actually copy the credentials file for the backup

* fix: dirs get 0777, files get 0666

* fix: small review feedback

Co-authored-by: tmgordeeva <tanya@influxdata.com>
2020-01-21 14:22:45 -08:00
George 4f14ceabab
feat(kv): add support for prefixed cursor search (#16545)
* feat(kv): add support for prefixed cursor search

* chore(kv): ensure kv store implementation return seek missing prefix error in tests

* chore(kv): update changelog
2020-01-21 12:52:30 +00:00
Johnny Steenbergen 8d6d44ac79 chore(bolt): nuke crufty bolt db service
kv store is a thing.. use it instead
2019-12-30 11:19:48 -08:00
Greg abd8ce0089
feat(http): add functionality to retrieve/store telegraf config as toml (#16132) 2019-12-20 14:20:13 -07:00
George 48b8cb84f7
feat(kv): define forward cursor interface (#16212)
* feat(kv): define forward cursor interface

* feat(kv): implement ForwardCursor on bolt and inmem buckets

* feat(kv): update tests to capture forward cursor

* fix(kv): typo in docs

* feat(kv): add Err method to ForwardCursor interface

* feat(inmem): batch pair channel sends in forward cursor

* fix(kv): remove Err field from kv.Pair

* feat(kv): add Close to kv.ForwardCursor interface
2019-12-19 17:30:05 +01:00
Jacob Marble 5f19c6cace
chore: Remove several instances of WithLogger (#15996)
* chore: Remove several instances of WithLogger

* chore: unexport Logger fields

* chore: unexport some more Logger fields

* chore: go fmt

chore: fix test

chore: s/logger/log

chore: fix test

chore: revert http.Handler.Handler constructor initialization

* refactor: integrate review feedback, fix all test nop loggers

* refactor: capitalize all log messages

* refactor: rename two logger to log
2019-12-04 15:10:23 -08:00
Jakub Bednář f25fe8c5a2 fix(http): Return an empty array if organization has no secret keys (#15363)
* fix(http): Return an empty array if organization has no secret keys

* fix(http): Return an empty array if organization has no secret keys instead nil
2019-12-04 13:29:05 -08:00
Johnny Steenbergen bc083e169c chore: refactor password service to provide userID instead of name 2019-11-20 09:16:31 -08:00
Ariel Salem 3ba8eaac3e
feat(createdAt): Added createdat and updatedAt to Authorization (#15784)
* feat(auth): add createdAt and updatedAt to authorization

Co-Authored-By: Ariel <ariel.salem1989@gmail.com>

* feat(auth): passing createAuth tests

* test: ensured that createdAt and updatedAt are valid on authorizations
2019-11-07 06:46:30 -08:00
Deary Hudson III 81965f0b33
feat(kv): unique variable names (#15695)
* feat(kv): unique variable names

- adds system bucket for creating an index of unique variable names
- adds tests
- deleted unit tests for dead code
- removed a test runner for the variable service from http
2019-11-04 14:28:21 -06:00
Stuart Carnie b1875d2def
feat(kv): Cursor API accepts hints for improving performance
Implementations of the `kv.Bucket#Cursor` API may use
the hints to instruct the access or read behavior to
the underlying key/value store.

The `findAllTasks` function was also fixed to ensure
that paging works as expected when using a name filter.
Tests were added to verify this behavior.

Redundant error checks were also removed.
2019-11-01 14:48:50 -07:00
Brandon Farmer b343250390 fix(influxdb): fixes broken tests from system bucket changes 2019-10-21 14:48:47 -07:00
Deary Hudson bd7c4dad8f fix(http): Ensures users are created with an active status 2019-09-30 15:37:59 -07:00
Brandon Farmer f61fe82708 fix(influxdb): Always return user status 2019-09-24 15:19:16 -07:00
Jonathan A. Sternberg cbd04f2884
refactor: http error serialization matches the new error schema (#15196)
The http error schema has been changed to simplify the outward facing
API. The `op` and `error` attributes have been dropped because they
confused people. The `error` attribute will likely be readded in some
form in the future, but only as additional context and will not be
required or even suggested for the UI to use.

Errors are now output differently both when they are serialized to JSON
and when they are output as strings. The `op` is no longer used if it is
present. It will only appear as an optional attribute if at all. The
`message` attribute for an error is always output and it will be the
prefix for any nested error. When this is serialized to JSON, the
message is automatically flattened so a nested error such as:

    influxdb.Error{
        Msg: errors.New("something bad happened"),
        Err: io.EOF,
    }

This would be written to the message as:

    something bad happened: EOF

This matches a developers expectations much more easily as most
programmers assume that wrapping an error will act as a prefix for the
inner error.

This is flattened when written out to HTTP in order to make this logic
immaterial to a frontend developer.

The code is still present and plays an important role in categorizing
the error type. On the other hand, the code will not be output as part
of the message as it commonly plays a redundant and confusing role when
humans read it. The human readable message usually gives more context
and a message like with the code acting as a prefix is generally not
desired. But, the code plays a very important role in helping to
identify categories of errors and so it is very important as part of the
return response.
2019-09-19 10:06:47 -05:00
Chris Goller 623224614e feat(kv): random ids without comma, space, backslash for org and bucket
At times snowflake id generation would create org and bucket IDs with
characters that had special meaning for the storage engine.

The storage engine concats the org and bucket bytes together into a
single 128 bit value.  That value is used in the old measurement
section.  Measurement was transformed into the tag, _measurement.

However, certain properties of the older measurement data location
are still required for the org/bucket bytes.  We cannot have
commas, spaces, nor backslashes.

This PR puts a specific ID generator in place during the creation of
orgs and buckets.  The IDs are just random numbers but with each
of the restricted chars incremented by one.  While this changes the
entropy distribution somewhat, it does not matter too much for our
purposes.

... because now org and bucket ids are checked for previous existence
transactionally in the key-value stores.  If the ID does already exist
then we try to generate a new key up to 100 times.
2019-09-08 01:50:05 -05:00
Jade McGough d147874c1e
fix(kv): mock system buckets (#14884) 2019-08-30 12:47:06 -07:00
Jonathan A. Sternberg e925b0ad72
fix(bolt): use named imports for bbolt (#14841)
The bbolt project has one version that uses the import `bolt` and one
that uses `bbolt`. The go module system doesn't really differentiate
between these two as different modules though so it is easy to switch to
using one or the other.

To remain consistent, the `bolt` named import is used everywhere so it
doesn't matter which version is used.
2019-08-28 12:30:06 -05:00
lisale0 6206b905a4 set va directly and remove comment 2019-06-20 16:30:25 -07:00
lisale0 63bc965606 fix findvar test 2019-06-20 16:25:38 -07:00
lisale0 3d18984c70 fix tests 2019-06-20 16:25:38 -07:00
lisale0 2187bf345b fixed bolt and inmem tests 2019-06-20 16:25:38 -07:00
lisale0 4057183dac setting createdAt and updatedAt in bolt and inmem 2019-06-20 16:25:38 -07:00
lisale0 3330d38984 feat(http): adding createdAt variable 2019-06-20 16:25:38 -07:00
Kelvin Wang 18a0f3f542 fix(influxdb): rename telegraf orgID 2019-06-03 16:20:53 -04:00