influxdb/testing/telegraf.go

1662 lines
40 KiB
Go
Raw Normal View History

2018-10-15 19:17:01 +00:00
package testing
import (
"bytes"
"context"
"fmt"
"sort"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
platform "github.com/influxdata/influxdb"
"github.com/influxdata/influxdb/mock"
"github.com/influxdata/influxdb/telegraf/plugins/inputs"
"github.com/influxdata/influxdb/telegraf/plugins/outputs"
2018-10-15 19:17:01 +00:00
)
// TelegrafConfigFields includes prepopulated data for mapping tests.
type TelegrafConfigFields struct {
IDGenerator platform.IDGenerator
TelegrafConfigs []*platform.TelegrafConfig
UserResourceMappings []*platform.UserResourceMapping
}
var telegrafCmpOptions = cmp.Options{
cmpopts.IgnoreUnexported(
inputs.CPUStats{},
inputs.MemStats{},
inputs.Kubernetes{},
inputs.File{},
outputs.File{},
outputs.InfluxDBV2{},
),
2018-10-15 19:17:01 +00:00
cmp.Transformer("Sort", func(in []*platform.TelegrafConfig) []*platform.TelegrafConfig {
out := append([]*platform.TelegrafConfig(nil), in...)
sort.Slice(out, func(i, j int) bool {
return out[i].ID > out[j].ID
})
return out
}),
}
var userResourceMappingCmpOptions = cmp.Options{
cmp.Comparer(func(x, y []byte) bool {
return bytes.Equal(x, y)
}),
cmp.Transformer("Sort", func(in []*platform.UserResourceMapping) []*platform.UserResourceMapping {
out := append([]*platform.UserResourceMapping(nil), in...)
sort.Slice(out, func(i, j int) bool {
return out[i].ResourceID.String() > out[j].ResourceID.String()
})
return out
}),
}
// TelegrafConfigStore tests all the service functions.
func TelegrafConfigStore(
init func(TelegrafConfigFields, *testing.T) (platform.TelegrafConfigStore, func()), t *testing.T,
) {
tests := []struct {
name string
fn func(init func(TelegrafConfigFields, *testing.T) (platform.TelegrafConfigStore, func()),
t *testing.T)
}{
{
name: "CreateTelegrafConfig",
fn: CreateTelegrafConfig,
},
{
name: "FindTelegrafConfigByID",
fn: FindTelegrafConfigByID,
},
{
name: "FindTelegrafConfigs",
fn: FindTelegrafConfigs,
},
{
name: "UpdateTelegrafConfig",
fn: UpdateTelegrafConfig,
},
{
name: "DeleteTelegrafConfig",
fn: DeleteTelegrafConfig,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.fn(init, t)
})
}
}
// CreateTelegrafConfig testing.
func CreateTelegrafConfig(
init func(TelegrafConfigFields, *testing.T) (platform.TelegrafConfigStore, func()),
t *testing.T,
) {
type args struct {
telegrafConfig *platform.TelegrafConfig
userID platform.ID
}
type wants struct {
err error
telegrafs []*platform.TelegrafConfig
userResourceMapping []*platform.UserResourceMapping
}
tests := []struct {
name string
fields TelegrafConfigFields
args args
wants wants
}{
{
name: "create telegraf config without organization ID should error",
fields: TelegrafConfigFields{
IDGenerator: mock.NewIDGenerator(oneID, t),
TelegrafConfigs: []*platform.TelegrafConfig{},
UserResourceMappings: []*platform.UserResourceMapping{},
},
args: args{
telegrafConfig: &platform.TelegrafConfig{},
},
wants: wants{
err: &platform.Error{
Code: platform.EEmptyValue,
2019-04-15 19:25:48 +00:00
Msg: platform.ErrTelegrafConfigInvalidOrgID,
},
},
},
2018-10-15 19:17:01 +00:00
{
name: "create telegraf config with empty set",
fields: TelegrafConfigFields{
IDGenerator: mock.NewIDGenerator(oneID, t),
2018-10-15 19:17:01 +00:00
TelegrafConfigs: []*platform.TelegrafConfig{},
UserResourceMappings: []*platform.UserResourceMapping{},
},
args: args{
userID: MustIDBase16(threeID),
telegrafConfig: &platform.TelegrafConfig{
2019-04-15 19:25:48 +00:00
OrgID: MustIDBase16(twoID),
Name: "name1",
2018-10-15 19:17:01 +00:00
Agent: platform.TelegrafAgentConfig{
Interval: 1000,
},
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.CPUStats{},
},
{
Comment: "comment2",
Config: &outputs.InfluxDBV2{
URLs: []string{"localhost/9999"},
Token: "token1",
Organization: "org1",
Bucket: "bucket1",
},
},
},
},
},
wants: wants{
userResourceMapping: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
2018-10-15 19:17:01 +00:00
},
},
telegrafs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(twoID),
Name: "name1",
2018-10-15 19:17:01 +00:00
Agent: platform.TelegrafAgentConfig{
Interval: 1000,
},
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.CPUStats{},
},
{
Comment: "comment2",
Config: &outputs.InfluxDBV2{
URLs: []string{"localhost/9999"},
Token: "token1",
Organization: "org1",
Bucket: "bucket1",
},
},
},
},
},
},
},
{
name: "basic create telegraf config",
fields: TelegrafConfigFields{
IDGenerator: mock.NewIDGenerator(twoID, t),
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(twoID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Agent: platform.TelegrafAgentConfig{
Interval: 4000,
},
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.MemStats{},
},
},
},
},
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
2018-10-15 19:17:01 +00:00
},
},
},
args: args{
userID: MustIDBase16(threeID),
telegrafConfig: &platform.TelegrafConfig{
2019-04-15 19:25:48 +00:00
OrgID: MustIDBase16(twoID),
Name: "name2",
2018-10-15 19:17:01 +00:00
Agent: platform.TelegrafAgentConfig{
Interval: 1001,
},
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment2",
Config: &inputs.CPUStats{},
},
{
Comment: "comment3",
Config: &outputs.InfluxDBV2{
URLs: []string{"localhost/9999"},
Token: "token3",
Organization: "org3",
Bucket: "bucket3",
},
},
},
},
},
wants: wants{
telegrafs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(twoID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Agent: platform.TelegrafAgentConfig{
Interval: 4000,
},
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.MemStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(twoID),
Name: "name2",
2018-10-15 19:17:01 +00:00
Agent: platform.TelegrafAgentConfig{
Interval: 1001,
},
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment2",
Config: &inputs.CPUStats{},
},
{
Comment: "comment3",
Config: &outputs.InfluxDBV2{
URLs: []string{"localhost/9999"},
Token: "token3",
Organization: "org3",
Bucket: "bucket3",
},
},
},
},
},
userResourceMapping: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
2018-10-15 19:17:01 +00:00
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, done := init(tt.fields, t)
defer done()
ctx := context.Background()
2018-12-21 16:05:55 +00:00
err := s.CreateTelegrafConfig(ctx, tt.args.telegrafConfig, tt.args.userID)
2018-10-15 19:17:01 +00:00
if (err != nil) != (tt.wants.err != nil) {
t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err)
}
if tt.wants.err == nil && !tt.args.telegrafConfig.ID.Valid() {
t.Fatalf("telegraf config ID not set from CreateTelegrafConfig")
}
if err != nil && tt.wants.err != nil {
if platform.ErrorCode(err) != platform.ErrorCode(tt.wants.err) {
t.Fatalf("expected error messages to match '%v' got '%v'", platform.ErrorCode(tt.wants.err), platform.ErrorCode(err))
}
}
filter := platform.TelegrafConfigFilter{
UserResourceMappingFilter: platform.UserResourceMappingFilter{
UserID: MustIDBase16(threeID),
ResourceType: platform.TelegrafsResourceType,
},
}
tcs, _, err := s.FindTelegrafConfigs(ctx, filter)
2018-10-15 19:17:01 +00:00
if err != nil {
t.Fatalf("failed to retrieve telegraf configs: %v", err)
}
if diff := cmp.Diff(tcs, tt.wants.telegrafs, telegrafCmpOptions...); diff != "" {
t.Errorf("telegraf configs are different -got/+want\ndiff %s", diff)
}
urms, _, err := s.FindUserResourceMappings(ctx, platform.UserResourceMappingFilter{
UserID: tt.args.userID,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
})
if err != nil {
t.Fatalf("failed to retrieve user resource mappings: %v", err)
}
if diff := cmp.Diff(urms, tt.wants.userResourceMapping, userResourceMappingCmpOptions...); diff != "" {
t.Errorf("user resource mappings are different -got/+want\ndiff %s", diff)
}
})
}
}
// FindTelegrafConfigByID testing.
func FindTelegrafConfigByID(
init func(TelegrafConfigFields, *testing.T) (platform.TelegrafConfigStore, func()),
t *testing.T,
) {
type args struct {
id platform.ID
}
type wants struct {
err error
telegrafConfig *platform.TelegrafConfig
}
tests := []struct {
name string
fields TelegrafConfigFields
args args
wants wants
}{
{
name: "bad id",
fields: TelegrafConfigFields{
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(twoID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(twoID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
id: platform.ID(0),
},
wants: wants{
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 15:06:47 +00:00
err: fmt.Errorf("provided telegraf configuration ID has invalid format"),
2018-10-15 19:17:01 +00:00
},
},
{
name: "not found",
fields: TelegrafConfigFields{
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(twoID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(twoID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
id: MustIDBase16(threeID),
},
wants: wants{
err: &platform.Error{
Code: platform.ENotFound,
feat(kv): implemented key/value store with end-to-end integration tests * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): initial port of scrapers in bolt to kv * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * fix(http): s/platform/influxdb/ for user service * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * feat(kv): implement labels generically on kv * refactor(passwords): rename from BasicAuth to Passwords * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(http): initial support for flushing all key/values from kv store * feat(kv): rename macro to variable * feat(cmd/influxd/launcher): user kv services where appropriate * refactor(passwords): rename from BasicAuth to Passwords * feat(kv): implement macro service * test(ui): introduce cypress * test(ui): introduce first typescript test * test(ui/e2e): add ci job * chore: update gitignore to ignore test outputs * feat(inmem): in memory influxdb * test(e2e): adding pinger that checks if influxdb is alive * hackathon * hack * hack * hack * hack * Revert "feat(inmem): in memory influxdb" This reverts commit 30ddf032003e704643b07ce80df61c3299ea7295. * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * chore: lint ignore node_modules * hack * hack * hack * add user and flush * hack * remove unused vars * hack * hack * ci(circle): prefix e2e artifacts * change test to testid * update cypress * moar testid * fix npm warnings * remove absolte path * chore(ci): remove /home/circleci proto mkdir hack * wip: crud resources e2e * fix(inmem): use inmem kv store services * test(dashboard): add first dashboard crud tests * hack * undo hack * fix: use response from setup for orgID * chore: wip * add convenience getByTitle function * test(e2e): ui can create orgs * test(e2e): add test for org deletion and update * test(e2e): introduce task creation test * test(e2e): create and update of buckets on org view * chore: move types to declaration file * chore: use route fixture in dashboard tests * chore(ci): hack back * test(ui): update snapshots * chore: package-lock * chore: remove macros * fix: launcher rebase issues * fix: compile errors * fix: compile errors * feat(cmd/influxdb): add explicit testing, asset-path, and store flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * fix(cmd/influxd): set default HTTP handler and flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * build(Makefile): add run-e2e and PHONY * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv): rename macro to variable * refactor(kv): auth/bucket/org/user unique checks return errors now * feat(inmem): add way to get all bucket names from store * feat(inmem): Buckets to return slice of bytes rather than strings * feat(inmem): add locks around Buckets to avoid races * feat(cmd/influx): check for unauthorized error in wrapCheckSetup * chore(e2e): add video and screenshot artifcats to gitignore * docs(ci): add build instructions for e2e tests * feat(kv): add id lookup for authorized resources
2019-02-19 23:47:19 +00:00
Msg: "telegraf configuration not found",
2018-10-15 19:17:01 +00:00
},
},
},
{
name: "basic find telegraf config by id",
fields: TelegrafConfigFields{
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(threeID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
id: MustIDBase16(twoID),
},
wants: wants{
telegrafConfig: &platform.TelegrafConfig{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, done := init(tt.fields, t)
defer done()
ctx := context.Background()
tc, err := s.FindTelegrafConfigByID(ctx, tt.args.id)
if (err != nil) != (tt.wants.err != nil) {
t.Fatalf("expected errors to be equal '%v' got '%v'", tt.wants.err, err)
}
if err != nil && tt.wants.err != nil {
feat(kv): implemented key/value store with end-to-end integration tests * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): initial port of scrapers in bolt to kv * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * fix(http): s/platform/influxdb/ for user service * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * feat(kv): implement labels generically on kv * refactor(passwords): rename from BasicAuth to Passwords * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(http): initial support for flushing all key/values from kv store * feat(kv): rename macro to variable * feat(cmd/influxd/launcher): user kv services where appropriate * refactor(passwords): rename from BasicAuth to Passwords * feat(kv): implement macro service * test(ui): introduce cypress * test(ui): introduce first typescript test * test(ui/e2e): add ci job * chore: update gitignore to ignore test outputs * feat(inmem): in memory influxdb * test(e2e): adding pinger that checks if influxdb is alive * hackathon * hack * hack * hack * hack * Revert "feat(inmem): in memory influxdb" This reverts commit 30ddf032003e704643b07ce80df61c3299ea7295. * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * chore: lint ignore node_modules * hack * hack * hack * add user and flush * hack * remove unused vars * hack * hack * ci(circle): prefix e2e artifacts * change test to testid * update cypress * moar testid * fix npm warnings * remove absolte path * chore(ci): remove /home/circleci proto mkdir hack * wip: crud resources e2e * fix(inmem): use inmem kv store services * test(dashboard): add first dashboard crud tests * hack * undo hack * fix: use response from setup for orgID * chore: wip * add convenience getByTitle function * test(e2e): ui can create orgs * test(e2e): add test for org deletion and update * test(e2e): introduce task creation test * test(e2e): create and update of buckets on org view * chore: move types to declaration file * chore: use route fixture in dashboard tests * chore(ci): hack back * test(ui): update snapshots * chore: package-lock * chore: remove macros * fix: launcher rebase issues * fix: compile errors * fix: compile errors * feat(cmd/influxdb): add explicit testing, asset-path, and store flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * fix(cmd/influxd): set default HTTP handler and flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * build(Makefile): add run-e2e and PHONY * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv): rename macro to variable * refactor(kv): auth/bucket/org/user unique checks return errors now * feat(inmem): add way to get all bucket names from store * feat(inmem): Buckets to return slice of bytes rather than strings * feat(inmem): add locks around Buckets to avoid races * feat(cmd/influx): check for unauthorized error in wrapCheckSetup * chore(e2e): add video and screenshot artifcats to gitignore * docs(ci): add build instructions for e2e tests * feat(kv): add id lookup for authorized resources
2019-02-19 23:47:19 +00:00
if want, got := tt.wants.err.Error(), err.Error(); want != got {
t.Fatalf("expected error '%s' got '%s'", want, got)
2018-10-15 19:17:01 +00:00
}
}
if diff := cmp.Diff(tc, tt.wants.telegrafConfig, telegrafCmpOptions...); diff != "" {
t.Errorf("telegraf configs are different -got/+want\ndiff %s", diff)
}
})
}
}
// FindTelegrafConfigs testing
func FindTelegrafConfigs(
init func(TelegrafConfigFields, *testing.T) (platform.TelegrafConfigStore, func()),
t *testing.T,
) {
type args struct {
filter platform.TelegrafConfigFilter
2018-10-15 19:17:01 +00:00
}
type wants struct {
telegrafConfigs []*platform.TelegrafConfig
err error
}
tests := []struct {
name string
fields TelegrafConfigFields
args args
wants wants
}{
2018-11-14 02:30:32 +00:00
{
name: "find nothing (empty set)",
2018-11-14 02:30:32 +00:00
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{},
TelegrafConfigs: []*platform.TelegrafConfig{},
},
args: args{
filter: platform.TelegrafConfigFilter{
UserResourceMappingFilter: platform.UserResourceMappingFilter{
ResourceType: platform.TelegrafsResourceType,
},
2018-11-14 02:30:32 +00:00
},
},
wants: wants{
telegrafConfigs: []*platform.TelegrafConfig{},
},
},
2018-10-15 19:17:01 +00:00
{
name: "find all telegraf configs",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
2018-10-15 19:17:01 +00:00
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(threeID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
filter: platform.TelegrafConfigFilter{
UserResourceMappingFilter: platform.UserResourceMappingFilter{
UserID: MustIDBase16(threeID),
ResourceType: platform.TelegrafsResourceType,
},
2018-10-15 19:17:01 +00:00
},
},
wants: wants{
telegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(threeID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
},
{
name: "find owners only",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
2018-10-15 19:17:01 +00:00
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
filter: platform.TelegrafConfigFilter{
UserResourceMappingFilter: platform.UserResourceMappingFilter{
UserID: MustIDBase16(threeID),
ResourceType: platform.TelegrafsResourceType,
UserType: platform.Owner,
},
},
},
wants: wants{
telegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
},
},
},
{
name: "filter by organization only",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
},
{
ResourceID: MustIDBase16(twoID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
},
{
ResourceID: MustIDBase16(fourID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(fourID),
OrgID: MustIDBase16(oneID),
Name: "tc3",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
},
},
args: args{
filter: platform.TelegrafConfigFilter{
2019-04-15 19:25:48 +00:00
OrgID: idPtr(MustIDBase16(oneID)),
},
},
wants: wants{
telegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(fourID),
OrgID: MustIDBase16(oneID),
Name: "tc3",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
},
},
},
{
name: "find owners and restrict by organization",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
},
{
ResourceID: MustIDBase16(twoID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
},
{
ResourceID: MustIDBase16(fourID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(fourID),
OrgID: MustIDBase16(oneID),
Name: "tc3",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
},
},
args: args{
filter: platform.TelegrafConfigFilter{
2019-04-15 19:25:48 +00:00
OrgID: idPtr(MustIDBase16(oneID)),
UserResourceMappingFilter: platform.UserResourceMappingFilter{
UserID: MustIDBase16(threeID),
ResourceType: platform.TelegrafsResourceType,
UserType: platform.Owner,
},
2018-10-15 19:17:01 +00:00
},
},
wants: wants{
telegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(fourID),
OrgID: MustIDBase16(oneID),
Name: "tc3",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
},
},
},
{
name: "look for organization not bound to any telegraf config",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
},
{
ResourceID: MustIDBase16(twoID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(threeID),
Name: "tc1",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
filter: platform.TelegrafConfigFilter{
2019-04-15 19:25:48 +00:00
OrgID: idPtr(MustIDBase16(oneID)),
},
},
wants: wants{
telegrafConfigs: []*platform.TelegrafConfig{},
},
},
2018-10-15 19:17:01 +00:00
{
name: "find nothing",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
ResourceType: platform.TelegrafsResourceType,
UserID: MustIDBase16(threeID),
UserType: platform.Member,
2018-10-15 19:17:01 +00:00
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(threeID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
filter: platform.TelegrafConfigFilter{
UserResourceMappingFilter: platform.UserResourceMappingFilter{
UserID: MustIDBase16(fourID),
ResourceType: platform.TelegrafsResourceType,
},
2018-10-15 19:17:01 +00:00
},
},
wants: wants{
err: &platform.Error{
Code: platform.ENotFound,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, done := init(tt.fields, t)
defer done()
ctx := context.Background()
tcs, n, err := s.FindTelegrafConfigs(ctx, tt.args.filter)
if err != nil && tt.wants.err == nil {
t.Fatalf("expected errors to be nil got '%v'", err)
}
if err != nil && tt.wants.err != nil {
if platform.ErrorCode(err) != platform.ErrorCode(tt.wants.err) {
t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err)
}
}
if n != len(tt.wants.telegrafConfigs) {
t.Fatalf("telegraf configs length is different got %d, want %d", n, len(tt.wants.telegrafConfigs))
}
if diff := cmp.Diff(tcs, tt.wants.telegrafConfigs, telegrafCmpOptions...); diff != "" {
t.Errorf("telegraf configs are different -got/+want\ndiff %s", diff)
}
})
}
}
// UpdateTelegrafConfig testing.
func UpdateTelegrafConfig(
init func(TelegrafConfigFields, *testing.T) (platform.TelegrafConfigStore, func()),
t *testing.T,
) {
type args struct {
userID platform.ID
id platform.ID
telegrafConfig *platform.TelegrafConfig
}
type wants struct {
telegrafConfig *platform.TelegrafConfig
err error
}
tests := []struct {
name string
fields TelegrafConfigFields
args args
wants wants
}{
{
name: "can't find the id",
fields: TelegrafConfigFields{
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
userID: MustIDBase16(threeID),
id: MustIDBase16(fourID),
telegrafConfig: &platform.TelegrafConfig{
2018-12-21 16:05:55 +00:00
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
wants: wants{
err: &platform.Error{
Code: platform.ENotFound,
Msg: fmt.Sprintf("telegraf config with ID %v not found", MustIDBase16(fourID)),
},
},
},
{
name: "regular update",
fields: TelegrafConfigFields{
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
userID: MustIDBase16(fourID),
id: MustIDBase16(twoID),
telegrafConfig: &platform.TelegrafConfig{
2019-04-15 19:25:48 +00:00
OrgID: MustIDBase16(oneID), // notice this get ignored - ie., resulting TelegrafConfig will have OrgID equal to fourID
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment3",
Config: &inputs.CPUStats{},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
wants: wants{
telegrafConfig: &platform.TelegrafConfig{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment3",
Config: &inputs.CPUStats{},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
{
name: "config update",
fields: TelegrafConfigFields{
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(oneID),
Name: "tc1",
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(oneID),
Name: "tc2",
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.Kubernetes{
URL: "http://1.2.3.4",
},
},
{
Config: &inputs.Kubernetes{
URL: "123",
},
},
},
},
},
},
args: args{
userID: MustIDBase16(fourID),
id: MustIDBase16(twoID),
telegrafConfig: &platform.TelegrafConfig{
2018-12-21 16:05:55 +00:00
Name: "tc2",
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2", "f3"},
},
},
{
Comment: "comment2",
Config: &inputs.Kubernetes{
URL: "http://1.2.3.5",
},
},
{
Config: &inputs.Kubernetes{
URL: "1234",
},
},
},
},
},
wants: wants{
telegrafConfig: &platform.TelegrafConfig{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(oneID),
Name: "tc2",
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2", "f3"},
},
},
{
Comment: "comment2",
Config: &inputs.Kubernetes{
URL: "http://1.2.3.5",
},
},
{
Config: &inputs.Kubernetes{
URL: "1234",
},
},
},
},
},
},
2018-10-15 19:17:01 +00:00
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, done := init(tt.fields, t)
defer done()
ctx := context.Background()
tc, err := s.UpdateTelegrafConfig(ctx, tt.args.id,
2018-12-21 16:05:55 +00:00
tt.args.telegrafConfig, tt.args.userID)
2018-10-15 19:17:01 +00:00
if err != nil && tt.wants.err == nil {
t.Fatalf("expected errors to be nil got '%v'", err)
}
if err != nil && tt.wants.err != nil {
if platform.ErrorCode(err) != platform.ErrorCode(tt.wants.err) {
t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err)
}
}
if diff := cmp.Diff(tc, tt.wants.telegrafConfig, telegrafCmpOptions...); tt.wants.err == nil && diff != "" {
t.Errorf("telegraf configs are different -got/+want\ndiff %s", diff)
}
})
}
}
// DeleteTelegrafConfig testing.
func DeleteTelegrafConfig(
init func(TelegrafConfigFields, *testing.T) (platform.TelegrafConfigStore, func()),
t *testing.T,
) {
type args struct {
id platform.ID
userID platform.ID
}
type wants struct {
telegrafConfigs []*platform.TelegrafConfig
userResourceMappings []*platform.UserResourceMapping
err error
}
tests := []struct {
name string
fields TelegrafConfigFields
args args
wants wants
}{
{
name: "bad id",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
UserType: platform.Member,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
id: platform.ID(0),
userID: MustIDBase16(threeID),
},
wants: wants{
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 15:06:47 +00:00
err: fmt.Errorf("provided telegraf configuration ID has invalid format"),
2018-10-15 19:17:01 +00:00
userResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
UserType: platform.Member,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
},
telegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(fourID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(fourID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
},
{
name: "none existing config",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
UserType: platform.Member,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(threeID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
id: MustIDBase16(fourID),
userID: MustIDBase16(threeID),
},
wants: wants{
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 15:06:47 +00:00
err: fmt.Errorf("telegraf configuration not found"),
2018-10-15 19:17:01 +00:00
userResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
UserType: platform.Member,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
},
telegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(threeID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(threeID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
},
{
name: "regular delete",
fields: TelegrafConfigFields{
UserResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
UserType: platform.Member,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
},
TelegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(twoID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(twoID),
OrgID: MustIDBase16(twoID),
Name: "tc2",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Comment: "comment1",
Config: &inputs.File{
Files: []string{"f1", "f2"},
},
},
{
Comment: "comment2",
Config: &inputs.MemStats{},
},
},
},
},
},
args: args{
id: MustIDBase16(twoID),
userID: MustIDBase16(threeID),
},
wants: wants{
userResourceMappings: []*platform.UserResourceMapping{
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
UserType: platform.Owner,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
},
},
telegrafConfigs: []*platform.TelegrafConfig{
{
2019-04-15 19:25:48 +00:00
ID: MustIDBase16(oneID),
OrgID: MustIDBase16(twoID),
Name: "tc1",
2018-10-15 19:17:01 +00:00
Plugins: []platform.TelegrafPlugin{
{
Config: &inputs.CPUStats{},
},
},
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, done := init(tt.fields, t)
defer done()
ctx := context.Background()
err := s.DeleteTelegrafConfig(ctx, tt.args.id)
if err != nil && tt.wants.err == nil {
t.Fatalf("expected errors to be nil got '%v'", err)
}
if err != nil && tt.wants.err != nil {
feat(kv): implemented key/value store with end-to-end integration tests * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): initial port of scrapers in bolt to kv * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * fix(http): s/platform/influxdb/ for user service * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * feat(kv): implement labels generically on kv * refactor(passwords): rename from BasicAuth to Passwords * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(http): initial support for flushing all key/values from kv store * feat(kv): rename macro to variable * feat(cmd/influxd/launcher): user kv services where appropriate * refactor(passwords): rename from BasicAuth to Passwords * feat(kv): implement macro service * test(ui): introduce cypress * test(ui): introduce first typescript test * test(ui/e2e): add ci job * chore: update gitignore to ignore test outputs * feat(inmem): in memory influxdb * test(e2e): adding pinger that checks if influxdb is alive * hackathon * hack * hack * hack * hack * Revert "feat(inmem): in memory influxdb" This reverts commit 30ddf032003e704643b07ce80df61c3299ea7295. * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * chore: lint ignore node_modules * hack * hack * hack * add user and flush * hack * remove unused vars * hack * hack * ci(circle): prefix e2e artifacts * change test to testid * update cypress * moar testid * fix npm warnings * remove absolte path * chore(ci): remove /home/circleci proto mkdir hack * wip: crud resources e2e * fix(inmem): use inmem kv store services * test(dashboard): add first dashboard crud tests * hack * undo hack * fix: use response from setup for orgID * chore: wip * add convenience getByTitle function * test(e2e): ui can create orgs * test(e2e): add test for org deletion and update * test(e2e): introduce task creation test * test(e2e): create and update of buckets on org view * chore: move types to declaration file * chore: use route fixture in dashboard tests * chore(ci): hack back * test(ui): update snapshots * chore: package-lock * chore: remove macros * fix: launcher rebase issues * fix: compile errors * fix: compile errors * feat(cmd/influxdb): add explicit testing, asset-path, and store flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * fix(cmd/influxd): set default HTTP handler and flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * build(Makefile): add run-e2e and PHONY * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv): rename macro to variable * refactor(kv): auth/bucket/org/user unique checks return errors now * feat(inmem): add way to get all bucket names from store * feat(inmem): Buckets to return slice of bytes rather than strings * feat(inmem): add locks around Buckets to avoid races * feat(cmd/influx): check for unauthorized error in wrapCheckSetup * chore(e2e): add video and screenshot artifcats to gitignore * docs(ci): add build instructions for e2e tests * feat(kv): add id lookup for authorized resources
2019-02-19 23:47:19 +00:00
if want, got := tt.wants.err.Error(), err.Error(); want != got {
2018-10-15 19:17:01 +00:00
t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err)
}
}
feat(kv): implemented key/value store with end-to-end integration tests * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): initial port of scrapers in bolt to kv * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * fix(http): s/platform/influxdb/ for user service * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * feat(kv): implement labels generically on kv * refactor(passwords): rename from BasicAuth to Passwords * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(http): initial support for flushing all key/values from kv store * feat(kv): rename macro to variable * feat(cmd/influxd/launcher): user kv services where appropriate * refactor(passwords): rename from BasicAuth to Passwords * feat(kv): implement macro service * test(ui): introduce cypress * test(ui): introduce first typescript test * test(ui/e2e): add ci job * chore: update gitignore to ignore test outputs * feat(inmem): in memory influxdb * test(e2e): adding pinger that checks if influxdb is alive * hackathon * hack * hack * hack * hack * Revert "feat(inmem): in memory influxdb" This reverts commit 30ddf032003e704643b07ce80df61c3299ea7295. * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * chore: lint ignore node_modules * hack * hack * hack * add user and flush * hack * remove unused vars * hack * hack * ci(circle): prefix e2e artifacts * change test to testid * update cypress * moar testid * fix npm warnings * remove absolte path * chore(ci): remove /home/circleci proto mkdir hack * wip: crud resources e2e * fix(inmem): use inmem kv store services * test(dashboard): add first dashboard crud tests * hack * undo hack * fix: use response from setup for orgID * chore: wip * add convenience getByTitle function * test(e2e): ui can create orgs * test(e2e): add test for org deletion and update * test(e2e): introduce task creation test * test(e2e): create and update of buckets on org view * chore: move types to declaration file * chore: use route fixture in dashboard tests * chore(ci): hack back * test(ui): update snapshots * chore: package-lock * chore: remove macros * fix: launcher rebase issues * fix: compile errors * fix: compile errors * feat(cmd/influxdb): add explicit testing, asset-path, and store flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * fix(cmd/influxd): set default HTTP handler and flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * build(Makefile): add run-e2e and PHONY * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv): rename macro to variable * refactor(kv): auth/bucket/org/user unique checks return errors now * feat(inmem): add way to get all bucket names from store * feat(inmem): Buckets to return slice of bytes rather than strings * feat(inmem): add locks around Buckets to avoid races * feat(cmd/influx): check for unauthorized error in wrapCheckSetup * chore(e2e): add video and screenshot artifcats to gitignore * docs(ci): add build instructions for e2e tests * feat(kv): add id lookup for authorized resources
2019-02-19 23:47:19 +00:00
filter := platform.TelegrafConfigFilter{
UserResourceMappingFilter: platform.UserResourceMappingFilter{
UserID: tt.args.userID,
ResourceType: platform.TelegrafsResourceType,
},
}
tcs, n, err := s.FindTelegrafConfigs(ctx, filter)
2018-10-15 19:17:01 +00:00
if err != nil && tt.wants.err == nil {
t.Fatalf("expected errors to be nil got '%v'", err)
}
if err != nil && tt.wants.err != nil {
feat(kv): implemented key/value store with end-to-end integration tests * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): initial port of scrapers in bolt to kv * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * fix(http): s/platform/influxdb/ for user service * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * feat(kv): implement labels generically on kv * refactor(passwords): rename from BasicAuth to Passwords * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(http): initial support for flushing all key/values from kv store * feat(kv): rename macro to variable * feat(cmd/influxd/launcher): user kv services where appropriate * refactor(passwords): rename from BasicAuth to Passwords * feat(kv): implement macro service * test(ui): introduce cypress * test(ui): introduce first typescript test * test(ui/e2e): add ci job * chore: update gitignore to ignore test outputs * feat(inmem): in memory influxdb * test(e2e): adding pinger that checks if influxdb is alive * hackathon * hack * hack * hack * hack * Revert "feat(inmem): in memory influxdb" This reverts commit 30ddf032003e704643b07ce80df61c3299ea7295. * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * chore: lint ignore node_modules * hack * hack * hack * add user and flush * hack * remove unused vars * hack * hack * ci(circle): prefix e2e artifacts * change test to testid * update cypress * moar testid * fix npm warnings * remove absolte path * chore(ci): remove /home/circleci proto mkdir hack * wip: crud resources e2e * fix(inmem): use inmem kv store services * test(dashboard): add first dashboard crud tests * hack * undo hack * fix: use response from setup for orgID * chore: wip * add convenience getByTitle function * test(e2e): ui can create orgs * test(e2e): add test for org deletion and update * test(e2e): introduce task creation test * test(e2e): create and update of buckets on org view * chore: move types to declaration file * chore: use route fixture in dashboard tests * chore(ci): hack back * test(ui): update snapshots * chore: package-lock * chore: remove macros * fix: launcher rebase issues * fix: compile errors * fix: compile errors * feat(cmd/influxdb): add explicit testing, asset-path, and store flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * fix(cmd/influxd): set default HTTP handler and flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * build(Makefile): add run-e2e and PHONY * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv): rename macro to variable * refactor(kv): auth/bucket/org/user unique checks return errors now * feat(inmem): add way to get all bucket names from store * feat(inmem): Buckets to return slice of bytes rather than strings * feat(inmem): add locks around Buckets to avoid races * feat(cmd/influx): check for unauthorized error in wrapCheckSetup * chore(e2e): add video and screenshot artifcats to gitignore * docs(ci): add build instructions for e2e tests * feat(kv): add id lookup for authorized resources
2019-02-19 23:47:19 +00:00
if want, got := tt.wants.err.Error(), err.Error(); want != got {
2018-10-15 19:17:01 +00:00
t.Fatalf("expected error '%v' got '%v'", tt.wants.err, err)
}
}
feat(kv): implemented key/value store with end-to-end integration tests * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): initial port of scrapers in bolt to kv * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * fix(http): s/platform/influxdb/ for user service * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * feat(kv): implement labels generically on kv * refactor(passwords): rename from BasicAuth to Passwords * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(http): initial support for flushing all key/values from kv store * feat(kv): rename macro to variable * feat(cmd/influxd/launcher): user kv services where appropriate * refactor(passwords): rename from BasicAuth to Passwords * feat(kv): implement macro service * test(ui): introduce cypress * test(ui): introduce first typescript test * test(ui/e2e): add ci job * chore: update gitignore to ignore test outputs * feat(inmem): in memory influxdb * test(e2e): adding pinger that checks if influxdb is alive * hackathon * hack * hack * hack * hack * Revert "feat(inmem): in memory influxdb" This reverts commit 30ddf032003e704643b07ce80df61c3299ea7295. * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * hack * chore: lint ignore node_modules * hack * hack * hack * add user and flush * hack * remove unused vars * hack * hack * ci(circle): prefix e2e artifacts * change test to testid * update cypress * moar testid * fix npm warnings * remove absolte path * chore(ci): remove /home/circleci proto mkdir hack * wip: crud resources e2e * fix(inmem): use inmem kv store services * test(dashboard): add first dashboard crud tests * hack * undo hack * fix: use response from setup for orgID * chore: wip * add convenience getByTitle function * test(e2e): ui can create orgs * test(e2e): add test for org deletion and update * test(e2e): introduce task creation test * test(e2e): create and update of buckets on org view * chore: move types to declaration file * chore: use route fixture in dashboard tests * chore(ci): hack back * test(ui): update snapshots * chore: package-lock * chore: remove macros * fix: launcher rebase issues * fix: compile errors * fix: compile errors * feat(cmd/influxdb): add explicit testing, asset-path, and store flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * fix(cmd/influxd): set default HTTP handler and flags Co-authored-by: Andrew Watkins <watts@influxdb.com> * build(Makefile): add run-e2e and PHONY * feat(kv:inmem:bolt): implement user service in a kv * refactor(kv): use consistent func receiver name * feat(kv): add initial basic auth service * refactor(passwords): move auth interface into own file * refactor(passwords): rename basic auth files to passwords * refactor(passwords): rename from BasicAuth to Passwords * refactor(kv): copy bolt user test into kv Co-authored-by: Michael Desa <mjdesa@gmail.com> * feat(kv): add inmem testing to kv store * fix(kv): remove extra user index initialization * feat(kv): attempt at making errors nice * fix(http): return not found error if filter is invalid * fix(http): s/platform/influxdb/ for user service * fix(http): s/platform/influxdb/ for user service * feat(kv): initial port of telegraf configs to kv * feat(kv): initial port of scrapers in bolt to kv * feat(kv): first pass at migrating bolt org service to kv * feat(kv): first pass at bucket service * feat(kv): first pass at migrating kvlog to kv package * feat(kv): add resource op logs * feat(kv): first pass at user resource mapping migration * feat(kv): add urm usage to bucket and org services * feat(kv): first pass at kv authz service * feat(kv): add cascading auth delete for users * feat(kv): first pass d authorizer.OrganizationService in kv * feat(cmd/influxd/launcher): user kv services where appropriate * fix(kv): initialize authorizations * fix(influxdb): use same buckets while slowly migrating stuff * fix(kv): make staticcheck pass * feat(kv): add dashboards to kv review: make suggestions from pr review fix: use common bucket names for bolt/kv stores * test(kv): add complete password test coverage * chore(kv): fixes for staticcheck * feat(kv): implement labels generically on kv * feat(kv): implement macro service * feat(kv): add source service * feat(kv): add session service * feat(kv): add kv secret service * refactor(kv): update telegraf and urm with error messages * feat(kv): add lookup service * feat(kv): add kv onboarding service * refactor(kv): update telegraf to avoid repetition * feat(cmd/influxd): use kv lookup service * feat(kv): add telegraf to lookup service * feat(cmd/influxd): use kv telegraf service * feat(kv): update scraper error messaging * feat(cmd/influxd): add kv scraper * feat(kv): add inmem backend tests * refactor(kv): copy paste errors * refactor(kv): add code to password errors * fix(testing): update error messages for incorrect passwords * feat(kv): rename macro to variable * refactor(kv): auth/bucket/org/user unique checks return errors now * feat(inmem): add way to get all bucket names from store * feat(inmem): Buckets to return slice of bytes rather than strings * feat(inmem): add locks around Buckets to avoid races * feat(cmd/influx): check for unauthorized error in wrapCheckSetup * chore(e2e): add video and screenshot artifcats to gitignore * docs(ci): add build instructions for e2e tests * feat(kv): add id lookup for authorized resources
2019-02-19 23:47:19 +00:00
2018-10-15 19:17:01 +00:00
if n != len(tt.wants.telegrafConfigs) {
t.Fatalf("telegraf configs length is different got %d, want %d", n, len(tt.wants.telegrafConfigs))
}
if diff := cmp.Diff(tcs, tt.wants.telegrafConfigs, telegrafCmpOptions...); diff != "" {
t.Errorf("telegraf configs are different -got/+want\ndiff %s", diff)
}
urms, _, err := s.FindUserResourceMappings(ctx, platform.UserResourceMappingFilter{
UserID: tt.args.userID,
ResourceType: platform.TelegrafsResourceType,
2018-10-15 19:17:01 +00:00
})
if err != nil {
t.Fatalf("failed to retrieve user resource mappings: %v", err)
}
if diff := cmp.Diff(urms, tt.wants.userResourceMappings, userResourceMappingCmpOptions...); diff != "" {
t.Errorf("user resource mappings are different -got/+want\ndiff %s", diff)
}
})
}
}