influxdb/testing/scraper_target.go

977 lines
24 KiB
Go
Raw Normal View History

2018-09-07 15:45:28 +00:00
package testing
import (
"bytes"
"context"
"sort"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/influxdata/influxdb/v2"
"github.com/influxdata/influxdb/v2/mock"
2018-09-07 15:45:28 +00:00
)
const (
targetOneID = "020f755c3c082000"
targetTwoID = "020f755c3c082001"
targetThreeID = "020f755c3c082002"
)
2019-04-12 16:45:48 +00:00
var (
target1 = influxdb.ScraperTarget{
Name: "name1",
Type: influxdb.PrometheusScraperType,
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
}
target2 = influxdb.ScraperTarget{
Name: "name2",
Type: influxdb.PrometheusScraperType,
OrgID: MustIDBase16(orgTwoID),
BucketID: MustIDBase16(bucketTwoID),
URL: "url2",
ID: MustIDBase16(targetTwoID),
}
target3 = influxdb.ScraperTarget{
Name: "name3",
Type: influxdb.PrometheusScraperType,
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketThreeID),
URL: "url3",
ID: MustIDBase16(targetThreeID),
}
org1 = influxdb.Organization{
ID: MustIDBase16(orgOneID),
Name: "org1",
}
org2 = influxdb.Organization{
ID: MustIDBase16(orgTwoID),
Name: "org2",
}
)
2018-09-07 15:45:28 +00:00
// TargetFields will include the IDGenerator, and targets
type TargetFields struct {
2019-04-12 16:45:48 +00:00
IDGenerator influxdb.IDGenerator
Targets []*influxdb.ScraperTarget
UserResourceMappings []*influxdb.UserResourceMapping
Organizations []*influxdb.Organization
2018-09-07 15:45:28 +00:00
}
var targetCmpOptions = cmp.Options{
cmp.Comparer(func(x, y []byte) bool {
return bytes.Equal(x, y)
}),
2019-04-12 16:45:48 +00:00
cmp.Transformer("Sort", func(in []influxdb.ScraperTarget) []influxdb.ScraperTarget {
out := append([]influxdb.ScraperTarget(nil), in...) // Copy input to avoid mutating it
2018-09-07 15:45:28 +00:00
sort.Slice(out, func(i, j int) bool {
return out[i].ID.String() > out[j].ID.String()
})
return out
}),
}
// ScraperService tests all the service functions.
func ScraperService(
2019-04-12 16:45:48 +00:00
init func(TargetFields, *testing.T) (influxdb.ScraperTargetStoreService, string, func()), t *testing.T,
) {
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
t.Helper()
tests := []struct {
name string
2019-04-12 16:45:48 +00:00
fn func(init func(TargetFields, *testing.T) (influxdb.ScraperTargetStoreService, string, func()),
t *testing.T)
}{
{
name: "AddTarget",
fn: AddTarget,
},
{
name: "ListTargets",
fn: ListTargets,
},
{
name: "GetTargetByID",
fn: GetTargetByID,
},
{
name: "RemoveTarget",
fn: RemoveTarget,
},
{
name: "UpdateTarget",
fn: UpdateTarget,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.fn(init, t)
})
}
}
2018-09-07 15:45:28 +00:00
// AddTarget testing.
func AddTarget(
2019-04-12 16:45:48 +00:00
init func(TargetFields, *testing.T) (influxdb.ScraperTargetStoreService, string, func()),
2018-09-07 15:45:28 +00:00
t *testing.T,
) {
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
t.Helper()
2018-09-07 15:45:28 +00:00
type args struct {
2019-04-12 16:45:48 +00:00
userID influxdb.ID
target *influxdb.ScraperTarget
2018-09-07 15:45:28 +00:00
}
type wants struct {
2019-01-18 20:46:37 +00:00
err error
2019-04-12 16:45:48 +00:00
targets []influxdb.ScraperTarget
userResourceMappings []*influxdb.UserResourceMapping
2018-09-07 15:45:28 +00:00
}
tests := []struct {
name string
fields TargetFields
args args
wants wants
}{
{
name: "create targets with empty set",
fields: TargetFields{
2019-01-18 20:46:37 +00:00
IDGenerator: mock.NewIDGenerator(targetOneID, t),
2019-04-12 16:45:48 +00:00
Targets: []*influxdb.ScraperTarget{},
UserResourceMappings: []*influxdb.UserResourceMapping{},
Organizations: []*influxdb.Organization{&org1},
2018-09-07 15:45:28 +00:00
},
args: args{
2019-01-18 20:46:37 +00:00
userID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
target: &influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
2018-09-07 15:45:28 +00:00
},
},
wants: wants{
2019-04-12 16:45:48 +00:00
userResourceMappings: []*influxdb.UserResourceMapping{
2019-01-18 20:46:37 +00:00
{
ResourceID: MustIDBase16(oneID),
2019-04-12 16:45:48 +00:00
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Owner,
2019-01-18 20:46:37 +00:00
},
},
2019-04-12 16:45:48 +00:00
targets: []influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
},
},
},
},
{
name: "create target with invalid org id",
fields: TargetFields{
2019-01-18 20:46:37 +00:00
IDGenerator: mock.NewIDGenerator(targetTwoID, t),
2019-04-12 16:45:48 +00:00
UserResourceMappings: []*influxdb.UserResourceMapping{},
Organizations: []*influxdb.Organization{&org1},
Targets: []*influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
{
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
},
},
},
args: args{
2019-04-12 16:45:48 +00:00
target: &influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
Name: "name2",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
BucketID: MustIDBase16(bucketTwoID),
URL: "url2",
},
},
wants: wants{
2019-04-12 16:45:48 +00:00
err: &influxdb.Error{
Code: influxdb.EInvalid,
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: "provided organization ID has invalid format",
2019-04-12 16:45:48 +00:00
Op: influxdb.OpAddTarget,
2019-01-10 17:39:37 +00:00
},
2019-04-12 16:45:48 +00:00
userResourceMappings: []*influxdb.UserResourceMapping{},
targets: []influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
{
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
},
},
},
},
{
name: "create target with invalid bucket id",
fields: TargetFields{
2019-01-18 20:46:37 +00:00
IDGenerator: mock.NewIDGenerator(targetTwoID, t),
2019-04-12 16:45:48 +00:00
UserResourceMappings: []*influxdb.UserResourceMapping{},
Organizations: []*influxdb.Organization{&org1},
Targets: []*influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
{
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
},
},
},
args: args{
2019-04-12 16:45:48 +00:00
target: &influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
Name: "name2",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgTwoID),
URL: "url2",
},
},
wants: wants{
2019-04-12 16:45:48 +00:00
err: &influxdb.Error{
Code: influxdb.EInvalid,
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: "provided bucket ID has invalid format",
2019-04-12 16:45:48 +00:00
Op: influxdb.OpAddTarget,
2019-01-10 17:39:37 +00:00
},
2019-04-12 16:45:48 +00:00
userResourceMappings: []*influxdb.UserResourceMapping{},
targets: []influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
{
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
2018-09-07 15:45:28 +00:00
},
},
},
},
{
name: "basic create target",
fields: TargetFields{
IDGenerator: mock.NewIDGenerator(targetTwoID, t),
2019-04-12 16:45:48 +00:00
Targets: []*influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
2018-09-07 15:45:28 +00:00
},
},
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{&org1, &org2},
UserResourceMappings: []*influxdb.UserResourceMapping{
2019-01-18 20:46:37 +00:00
{
ResourceID: MustIDBase16(targetOneID),
2019-04-12 16:45:48 +00:00
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Member,
2019-01-18 20:46:37 +00:00
},
},
2018-09-07 15:45:28 +00:00
},
args: args{
2019-01-18 20:46:37 +00:00
userID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
target: &influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
Name: "name2",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgTwoID),
BucketID: MustIDBase16(bucketTwoID),
URL: "url2",
2018-09-07 15:45:28 +00:00
},
},
wants: wants{
2019-04-12 16:45:48 +00:00
userResourceMappings: []*influxdb.UserResourceMapping{
2019-01-18 20:46:37 +00:00
{
ResourceID: MustIDBase16(oneID),
2019-04-12 16:45:48 +00:00
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Member,
2019-01-18 20:46:37 +00:00
},
{
ResourceID: MustIDBase16(twoID),
2019-04-12 16:45:48 +00:00
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Owner,
2019-01-18 20:46:37 +00:00
},
},
2019-04-12 16:45:48 +00:00
targets: []influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
Name: "name1",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
URL: "url1",
ID: MustIDBase16(targetOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
Name: "name2",
2019-04-12 16:45:48 +00:00
Type: influxdb.PrometheusScraperType,
2019-01-10 17:39:37 +00:00
OrgID: MustIDBase16(orgTwoID),
BucketID: MustIDBase16(bucketTwoID),
URL: "url2",
ID: MustIDBase16(targetTwoID),
2018-09-07 15:45:28 +00:00
},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, opPrefix, done := init(tt.fields, t)
2018-09-07 15:45:28 +00:00
defer done()
ctx := context.Background()
2019-01-18 20:46:37 +00:00
err := s.AddTarget(ctx, tt.args.target, tt.args.userID)
diffPlatformErrors(tt.name, err, tt.wants.err, opPrefix, t)
2018-09-07 15:45:28 +00:00
defer s.RemoveTarget(ctx, tt.args.target.ID)
2019-04-12 16:45:48 +00:00
targets, err := s.ListTargets(ctx, influxdb.ScraperTargetFilter{})
2018-09-07 15:45:28 +00:00
if err != nil {
t.Fatalf("failed to retrieve scraper targets: %v", err)
}
if diff := cmp.Diff(targets, tt.wants.targets, targetCmpOptions...); diff != "" {
t.Errorf("scraper targets are different -got/+want\ndiff %s", diff)
}
2019-04-12 16:45:48 +00:00
urms, _, err := s.FindUserResourceMappings(ctx, influxdb.UserResourceMappingFilter{
2019-01-18 20:46:37 +00:00
UserID: tt.args.userID,
2019-04-12 16:45:48 +00:00
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +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)
}
2018-09-07 15:45:28 +00:00
})
}
}
// ListTargets testing
func ListTargets(
2019-04-12 16:45:48 +00:00
init func(TargetFields, *testing.T) (influxdb.ScraperTargetStoreService, string, func()),
2018-09-07 15:45:28 +00:00
t *testing.T,
) {
2019-04-12 16:45:48 +00:00
type args struct {
filter influxdb.ScraperTargetFilter
}
2018-09-07 15:45:28 +00:00
type wants struct {
2019-04-12 16:45:48 +00:00
targets []influxdb.ScraperTarget
2018-09-07 15:45:28 +00:00
err error
}
tests := []struct {
name string
fields TargetFields
2019-04-12 16:45:48 +00:00
args args
2018-09-07 15:45:28 +00:00
wants wants
}{
{
2019-04-12 16:45:48 +00:00
name: "get all targets",
2018-09-07 15:45:28 +00:00
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{
&org1,
&org2,
},
Targets: []*influxdb.ScraperTarget{
&target1,
&target2,
&target3,
2018-09-07 15:45:28 +00:00
},
},
2019-04-12 16:45:48 +00:00
args: args{
filter: influxdb.ScraperTargetFilter{},
},
2018-09-07 15:45:28 +00:00
wants: wants{
2019-04-12 16:45:48 +00:00
targets: []influxdb.ScraperTarget{
target1,
target2,
target3,
},
},
},
{
name: "filter by name",
fields: TargetFields{
Organizations: []*influxdb.Organization{
&org1,
&org2,
},
Targets: []*influxdb.ScraperTarget{
&target1,
&target2,
&target3,
},
},
args: args{
filter: influxdb.ScraperTargetFilter{
Name: strPtr(target2.Name),
},
},
wants: wants{
targets: []influxdb.ScraperTarget{
target2,
},
},
},
{
name: "filter by id",
fields: TargetFields{
Organizations: []*influxdb.Organization{
&org1,
&org2,
},
Targets: []*influxdb.ScraperTarget{
&target1,
&target2,
&target3,
},
},
args: args{
filter: influxdb.ScraperTargetFilter{
IDs: map[influxdb.ID]bool{target2.ID: false},
},
},
wants: wants{
targets: []influxdb.ScraperTarget{
target2,
},
},
},
{
name: "filter targets by orgID",
fields: TargetFields{
Organizations: []*influxdb.Organization{
&org1,
&org2,
},
Targets: []*influxdb.ScraperTarget{
&target1,
&target2,
&target3,
},
},
args: args{
filter: influxdb.ScraperTargetFilter{
OrgID: idPtr(MustIDBase16(orgOneID)),
},
},
wants: wants{
targets: []influxdb.ScraperTarget{
target1,
target3,
},
},
},
{
name: "filter targets by orgID not exist",
fields: TargetFields{
Organizations: []*influxdb.Organization{
&org2,
},
Targets: []*influxdb.ScraperTarget{
&target1,
&target2,
&target3,
},
},
args: args{
filter: influxdb.ScraperTargetFilter{
OrgID: idPtr(MustIDBase16(orgOneID)),
},
},
wants: wants{
targets: []influxdb.ScraperTarget{},
err: &influxdb.Error{
Code: influxdb.ENotFound,
Msg: "organization not found",
},
},
},
{
name: "filter targets by org name",
fields: TargetFields{
Organizations: []*influxdb.Organization{
&org1,
&org2,
},
Targets: []*influxdb.ScraperTarget{
&target1,
&target2,
&target3,
},
},
args: args{
filter: influxdb.ScraperTargetFilter{
Org: strPtr("org1"),
},
},
wants: wants{
targets: []influxdb.ScraperTarget{
target1,
target3,
},
},
},
{
name: "filter targets by org name not exist",
fields: TargetFields{
Organizations: []*influxdb.Organization{
&org1,
},
Targets: []*influxdb.ScraperTarget{
&target1,
&target2,
&target3,
},
},
args: args{
filter: influxdb.ScraperTargetFilter{
Org: strPtr("org2"),
},
},
wants: wants{
targets: []influxdb.ScraperTarget{},
err: &influxdb.Error{
Code: influxdb.ENotFound,
Msg: `organization name "org2" not found`,
2018-09-07 15:45:28 +00:00
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, opPrefix, done := init(tt.fields, t)
2018-09-07 15:45:28 +00:00
defer done()
ctx := context.Background()
2019-04-12 16:45:48 +00:00
targets, err := s.ListTargets(ctx, tt.args.filter)
diffPlatformErrors(tt.name, err, tt.wants.err, opPrefix, t)
2018-09-07 15:45:28 +00:00
if diff := cmp.Diff(targets, tt.wants.targets, targetCmpOptions...); diff != "" {
t.Errorf("targets are different -got/+want\ndiff %s", diff)
}
})
}
}
// GetTargetByID testing
func GetTargetByID(
2019-04-12 16:45:48 +00:00
init func(TargetFields, *testing.T) (influxdb.ScraperTargetStoreService, string, func()),
2018-09-07 15:45:28 +00:00
t *testing.T,
) {
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
t.Helper()
2018-09-07 15:45:28 +00:00
type args struct {
2019-04-12 16:45:48 +00:00
id influxdb.ID
2018-09-07 15:45:28 +00:00
}
type wants struct {
err error
2019-04-12 16:45:48 +00:00
target *influxdb.ScraperTarget
2018-09-07 15:45:28 +00:00
}
tests := []struct {
name string
fields TargetFields
args args
wants wants
}{
{
name: "basic find target by id",
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{&org1},
Targets: []*influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
Name: "target1",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
Name: "target2",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
args: args{
id: MustIDBase16(targetTwoID),
2018-09-07 15:45:28 +00:00
},
wants: wants{
2019-04-12 16:45:48 +00:00
target: &influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
Name: "target2",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
{
name: "find target by id not find",
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Targets: []*influxdb.ScraperTarget{
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
Name: "target1",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
Name: "target2",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
},
},
},
args: args{
id: MustIDBase16(threeID),
},
wants: wants{
2019-04-12 16:45:48 +00:00
err: &influxdb.Error{
Code: influxdb.ENotFound,
Op: influxdb.OpGetTargetByID,
Msg: "scraper target is not found",
},
},
},
2018-09-07 15:45:28 +00:00
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, opPrefix, done := init(tt.fields, t)
2018-09-07 15:45:28 +00:00
defer done()
ctx := context.Background()
2018-09-07 15:45:28 +00:00
target, err := s.GetTargetByID(ctx, tt.args.id)
diffPlatformErrors(tt.name, err, tt.wants.err, opPrefix, t)
2018-09-07 15:45:28 +00:00
if diff := cmp.Diff(target, tt.wants.target, targetCmpOptions...); diff != "" {
t.Errorf("target is different -got/+want\ndiff %s", diff)
}
})
}
}
// RemoveTarget testing
2019-04-12 16:45:48 +00:00
func RemoveTarget(init func(TargetFields, *testing.T) (influxdb.ScraperTargetStoreService, string, func()),
2018-09-07 15:45:28 +00:00
t *testing.T) {
type args struct {
2019-04-12 16:45:48 +00:00
ID influxdb.ID
userID influxdb.ID
2018-09-07 15:45:28 +00:00
}
type wants struct {
2019-01-18 20:46:37 +00:00
err error
2019-04-12 16:45:48 +00:00
userResourceMappings []*influxdb.UserResourceMapping
targets []influxdb.ScraperTarget
2018-09-07 15:45:28 +00:00
}
tests := []struct {
name string
fields TargetFields
args args
wants wants
}{
{
name: "delete targets using exist id",
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{&org1},
UserResourceMappings: []*influxdb.UserResourceMapping{
2019-01-18 20:46:37 +00:00
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Owner,
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Member,
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
},
},
2019-04-12 16:45:48 +00:00
Targets: []*influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
args: args{
2019-01-18 20:46:37 +00:00
ID: MustIDBase16(targetOneID),
userID: MustIDBase16(threeID),
2018-09-07 15:45:28 +00:00
},
wants: wants{
2019-04-12 16:45:48 +00:00
userResourceMappings: []*influxdb.UserResourceMapping{
2019-01-18 20:46:37 +00:00
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Member,
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
},
},
2019-04-12 16:45:48 +00:00
targets: []influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
},
{
name: "delete targets using id that does not exist",
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{&org1},
UserResourceMappings: []*influxdb.UserResourceMapping{
2019-01-18 20:46:37 +00:00
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Owner,
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Member,
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
},
},
2019-04-12 16:45:48 +00:00
Targets: []*influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
args: args{
2019-01-18 20:46:37 +00:00
ID: MustIDBase16(targetThreeID),
userID: MustIDBase16(threeID),
2018-09-07 15:45:28 +00:00
},
wants: wants{
2019-04-12 16:45:48 +00:00
err: &influxdb.Error{
Code: influxdb.ENotFound,
Op: influxdb.OpRemoveTarget,
Msg: "scraper target is not found",
},
2019-04-12 16:45:48 +00:00
targets: []influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
2019-04-12 16:45:48 +00:00
userResourceMappings: []*influxdb.UserResourceMapping{
2019-01-18 20:46:37 +00:00
{
ResourceID: MustIDBase16(oneID),
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Owner,
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
},
{
ResourceID: MustIDBase16(twoID),
UserID: MustIDBase16(threeID),
2019-04-12 16:45:48 +00:00
UserType: influxdb.Member,
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +00:00
},
},
2018-09-07 15:45:28 +00:00
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, opPrefix, done := init(tt.fields, t)
2018-09-07 15:45:28 +00:00
defer done()
ctx := context.Background()
2018-09-07 15:45:28 +00:00
err := s.RemoveTarget(ctx, tt.args.ID)
diffPlatformErrors(tt.name, err, tt.wants.err, opPrefix, t)
2018-09-07 15:45:28 +00:00
2019-04-12 16:45:48 +00:00
targets, err := s.ListTargets(ctx, influxdb.ScraperTargetFilter{})
2018-09-07 15:45:28 +00:00
if err != nil {
t.Fatalf("failed to retrieve targets: %v", err)
}
if diff := cmp.Diff(targets, tt.wants.targets, targetCmpOptions...); diff != "" {
t.Errorf("targets are different -got/+want\ndiff %s", diff)
}
2019-04-12 16:45:48 +00:00
urms, _, err := s.FindUserResourceMappings(ctx, influxdb.UserResourceMappingFilter{
2019-01-18 20:46:37 +00:00
UserID: tt.args.userID,
2019-04-12 16:45:48 +00:00
ResourceType: influxdb.ScraperResourceType,
2019-01-18 20:46:37 +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)
}
2018-09-07 15:45:28 +00:00
})
}
}
// UpdateTarget testing
func UpdateTarget(
2019-04-12 16:45:48 +00:00
init func(TargetFields, *testing.T) (influxdb.ScraperTargetStoreService, string, func()),
2018-09-07 15:45:28 +00:00
t *testing.T,
) {
type args struct {
2019-01-18 20:46:37 +00:00
url string
2019-04-12 16:45:48 +00:00
userID influxdb.ID
id influxdb.ID
2018-09-07 15:45:28 +00:00
}
type wants struct {
err error
2019-04-12 16:45:48 +00:00
target *influxdb.ScraperTarget
2018-09-07 15:45:28 +00:00
}
tests := []struct {
name string
fields TargetFields
args args
wants wants
}{
{
name: "update url with blank id",
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{&org1},
Targets: []*influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
URL: "url1",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
URL: "url2",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
args: args{
url: "changed",
},
wants: wants{
2019-04-12 16:45:48 +00:00
err: &influxdb.Error{
Code: influxdb.EInvalid,
Op: influxdb.OpUpdateTarget,
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: "provided scraper target ID has invalid format",
},
2018-09-07 15:45:28 +00:00
},
},
{
name: "update url with non exist id",
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{&org1},
Targets: []*influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
URL: "url1",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
URL: "url2",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
args: args{
id: MustIDBase16(targetThreeID),
2018-09-07 15:45:28 +00:00
url: "changed",
},
wants: wants{
2019-04-12 16:45:48 +00:00
err: &influxdb.Error{
Code: influxdb.ENotFound,
Op: influxdb.OpUpdateTarget,
Msg: "scraper target is not found",
},
2018-09-07 15:45:28 +00:00
},
},
{
name: "update url",
fields: TargetFields{
2019-04-12 16:45:48 +00:00
Organizations: []*influxdb.Organization{&org1},
Targets: []*influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
URL: "url1",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetTwoID),
URL: "url2",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
args: args{
id: MustIDBase16(targetOneID),
2018-09-07 15:45:28 +00:00
url: "changed",
},
wants: wants{
2019-04-12 16:45:48 +00:00
target: &influxdb.ScraperTarget{
2019-01-10 17:39:37 +00:00
ID: MustIDBase16(targetOneID),
URL: "changed",
OrgID: MustIDBase16(orgOneID),
BucketID: MustIDBase16(bucketOneID),
2018-09-07 15:45:28 +00:00
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
s, opPrefix, done := init(tt.fields, t)
2018-09-07 15:45:28 +00:00
defer done()
ctx := context.Background()
2018-09-07 15:45:28 +00:00
2019-04-12 16:45:48 +00:00
upd := &influxdb.ScraperTarget{
2018-09-07 15:45:28 +00:00
ID: tt.args.id,
URL: tt.args.url,
}
2019-01-18 20:46:37 +00:00
target, err := s.UpdateTarget(ctx, upd, tt.args.userID)
diffPlatformErrors(tt.name, err, tt.wants.err, opPrefix, t)
2018-09-07 15:45:28 +00:00
if diff := cmp.Diff(target, tt.wants.target, targetCmpOptions...); diff != "" {
t.Errorf("scraper target is different -got/+want\ndiff %s", diff)
}
})
}
}