Implement basic bolt OrganizationsStore

pull/10616/head
Michael Desa 2017-10-20 11:13:13 -04:00
parent 41386ca546
commit de6ae41c60
6 changed files with 484 additions and 98 deletions

View File

@ -462,6 +462,7 @@ func UnmarshalUserPB(data []byte, u *User) error {
// MarshalOrganization encodes a organization to binary protobuf format.
func MarshalOrganization(o *chronograf.Organization) ([]byte, error) {
return MarshalOrganizationPB(&Organization{
ID: o.ID,
Name: o.Name,
})
}
@ -477,6 +478,7 @@ func UnmarshalOrganization(data []byte, o *chronograf.Organization) error {
if err := UnmarshalOrganizationPB(data, &pb); err != nil {
return err
}
o.ID = pb.ID
o.Name = pb.Name
return nil

View File

@ -312,8 +312,44 @@ func (m *User) String() string { return proto.CompactTextString(m) }
func (*User) ProtoMessage() {}
func (*User) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{13} }
func (m *User) GetID() uint64 {
if m != nil {
return m.ID
}
return 0
}
func (m *User) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func (m *User) GetProvider() string {
if m != nil {
return m.Provider
}
return ""
}
func (m *User) GetScheme() string {
if m != nil {
return m.Scheme
}
return ""
}
func (m *User) GetRoles() []string {
if m != nil {
return m.Roles
}
return nil
}
type Organization struct {
Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"`
ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"`
Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"`
}
func (m *Organization) Reset() { *m = Organization{} }
@ -321,6 +357,20 @@ func (m *Organization) String() string { return proto.CompactTextStri
func (*Organization) ProtoMessage() {}
func (*Organization) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{14} }
func (m *Organization) GetID() uint64 {
if m != nil {
return m.ID
}
return 0
}
func (m *Organization) GetName() string {
if m != nil {
return m.Name
}
return ""
}
func init() {
proto.RegisterType((*Source)(nil), "internal.Source")
proto.RegisterType((*Dashboard)(nil), "internal.Dashboard")
@ -342,72 +392,72 @@ func init() {
func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) }
var fileDescriptorInternal = []byte{
// 1070 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x56, 0xd1, 0x8e, 0xdb, 0x44,
0x17, 0xd6, 0xc4, 0x76, 0x12, 0x9f, 0x6c, 0xf7, 0xff, 0x35, 0xaa, 0xa8, 0x29, 0x37, 0xc1, 0x02,
0x29, 0x48, 0x74, 0x41, 0xad, 0x90, 0x10, 0x77, 0xd9, 0x0d, 0xaa, 0x96, 0xdd, 0xb6, 0xcb, 0x64,
0x77, 0xb9, 0x42, 0xd5, 0xc4, 0x39, 0x49, 0xac, 0x3a, 0xb1, 0x19, 0xdb, 0xbb, 0x31, 0x4f, 0xc1,
0x13, 0x20, 0x21, 0x71, 0xc5, 0x05, 0x17, 0xbc, 0x00, 0xf7, 0x7d, 0x2a, 0x74, 0x66, 0xc6, 0x8e,
0x43, 0x97, 0xaa, 0x37, 0x70, 0x37, 0xdf, 0x39, 0x93, 0x33, 0x33, 0xe7, 0x3b, 0xdf, 0x17, 0xc3,
0x61, 0xbc, 0x29, 0x50, 0x6d, 0x64, 0x72, 0x94, 0xa9, 0xb4, 0x48, 0x79, 0xbf, 0xc6, 0xe1, 0xef,
0x1d, 0xe8, 0x4e, 0xd3, 0x52, 0x45, 0xc8, 0x0f, 0xa1, 0x73, 0x3a, 0x09, 0xd8, 0x90, 0x8d, 0x1c,
0xd1, 0x39, 0x9d, 0x70, 0x0e, 0xee, 0x73, 0xb9, 0xc6, 0xa0, 0x33, 0x64, 0x23, 0x5f, 0xe8, 0x35,
0xc5, 0x2e, 0xab, 0x0c, 0x03, 0xc7, 0xc4, 0x68, 0xcd, 0x1f, 0x42, 0xff, 0x2a, 0xa7, 0x6a, 0x6b,
0x0c, 0x5c, 0x1d, 0x6f, 0x30, 0xe5, 0x2e, 0x64, 0x9e, 0xdf, 0xa6, 0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 0xb7, 0x42, 0x65, 0x5b, 0xed, 0x0b, 0x8b, 0x68,
0x26, 0xcf, 0xb5, 0x99, 0x98, 0xe6, 0x1a, 0xc0, 0x3f, 0x06, 0x4f, 0x50, 0xf3, 0x74, 0x87, 0xf7,
0x78, 0xd1, 0x61, 0x61, 0xb2, 0x54, 0xd4, 0x7c, 0xab, 0xd8, 0xff, 0x13, 0x8b, 0xc2, 0x27, 0xf6,
0xe7, 0x54, 0xfd, 0x2a, 0xcb, 0x50, 0x59, 0x89, 0x19, 0xa0, 0xcf, 0x4c, 0x6f, 0xd1, 0xb8, 0xa3,
0x23, 0x0c, 0x08, 0xbf, 0x07, 0x7f, 0x9c, 0xa0, 0x2a, 0x44, 0x99, 0xbc, 0xe9, 0xa9, 0x1c, 0xdc,
0x6f, 0xa6, 0x2f, 0x9e, 0xd7, 0xc2, 0xa4, 0xf5, 0x4e, 0x4e, 0xce, 0xdf, 0xe4, 0x74, 0x26, 0x33,
0x79, 0x3a, 0xd1, 0x73, 0xe6, 0x08, 0x8b, 0xc2, 0x02, 0x5c, 0x92, 0x6d, 0xab, 0xb2, 0xfb, 0x36,
0xc9, 0x5f, 0xa8, 0xf4, 0x26, 0x9e, 0xa3, 0xaa, 0x25, 0x5f, 0x63, 0xfd, 0xe6, 0x68, 0x85, 0xcd,
0xb7, 0x95, 0x45, 0x74, 0x1b, 0x91, 0x26, 0x4d, 0x7f, 0x0d, 0x08, 0x43, 0x38, 0x78, 0xa1, 0x96,
0x72, 0x13, 0xff, 0x68, 0x74, 0x59, 0x9f, 0xc6, 0x76, 0xa7, 0xcd, 0xba, 0xfa, 0x1b, 0xf0, 0xc9,
0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2f, 0x97, 0x53, 0x8f, 0x15, 0x0a, 0x00, 0x00,
// 1068 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xd1, 0x8e, 0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 0xf9, 0x56, 0xb1, 0xff, 0x27, 0x16, 0x85, 0x4f, 0xed,
0xcf, 0xa9, 0xfa, 0x65, 0x96, 0xa1, 0xb2, 0x12, 0x33, 0x40, 0x9f, 0x99, 0xde, 0xa0, 0x71, 0x47,
0x47, 0x18, 0x10, 0x7e, 0x0f, 0xfe, 0x38, 0x41, 0x55, 0x88, 0x32, 0x79, 0xdb, 0x53, 0x39, 0xb8,
0xdf, 0x4c, 0x5f, 0xbe, 0xa8, 0x85, 0x49, 0xeb, 0x9d, 0x9c, 0x9c, 0xbf, 0xc9, 0xe9, 0x54, 0x66,
0xf2, 0x64, 0xa2, 0xe7, 0xcc, 0x11, 0x16, 0x85, 0x05, 0xb8, 0x24, 0xdb, 0x56, 0x65, 0xf7, 0x5d,
0x92, 0x3f, 0x57, 0xe9, 0x75, 0x3c, 0x47, 0x55, 0x4b, 0xbe, 0xc6, 0xfa, 0xcd, 0xd1, 0x0a, 0x9b,
0x6f, 0x2b, 0x8b, 0xe8, 0x36, 0x22, 0x4d, 0x9a, 0xfe, 0x1a, 0x10, 0x3e, 0x81, 0x83, 0x97, 0x6a,
0x29, 0x37, 0xf1, 0x8f, 0x46, 0x97, 0x77, 0x38, 0x7d, 0xd6, 0xd5, 0xdf, 0x84, 0x4f, 0xff, 0x0a,
0x00, 0x00, 0xff, 0xff, 0xac, 0x72, 0x06, 0x7f, 0x25, 0x0a, 0x00, 0x00,
}

View File

@ -132,7 +132,8 @@ message User {
}
message Organization {
string Name = 1; // Name is the organization's name
uint64 ID = 1; // ID is the unique ID of the organization
string Name = 2; // Name is the organization's name
}
// The following is a vim modeline, it autoconfigures vim to have the

View File

@ -2,6 +2,7 @@ package bolt
import (
"context"
"fmt"
"github.com/boltdb/bolt"
"github.com/influxdata/chronograf"
@ -26,6 +27,7 @@ func (s *OrganizationsStore) Add(ctx context.Context, o *chronograf.Organization
if err != nil {
return err
}
o.ID = seq
if v, err := internal.MarshalOrganization(o); err != nil {
return err
} else if err := b.Put(u64tob(seq), v); err != nil {
@ -39,12 +41,44 @@ func (s *OrganizationsStore) Add(ctx context.Context, o *chronograf.Organization
return o, nil
}
func (s *OrganizationsStore) All(context.Context) ([]chronograf.Organization, error) {
panic("not implemented")
func (s *OrganizationsStore) All(ctx context.Context) ([]chronograf.Organization, error) {
var orgs []chronograf.Organization
err := s.each(ctx, func(o *chronograf.Organization) {
orgs = append(orgs, *o)
})
if err != nil {
return nil, err
}
return orgs, nil
}
func (s *OrganizationsStore) Delete(context.Context, *chronograf.Organization) error {
panic("not implemented")
func (s *OrganizationsStore) Delete(ctx context.Context, o *chronograf.Organization) error {
_, err := s.get(ctx, o.ID)
if err != nil {
return err
}
return s.client.db.Update(func(tx *bolt.Tx) error {
return tx.Bucket(OrganizationsBucket).Delete(u64tob(o.ID))
})
}
func (s *OrganizationsStore) get(ctx context.Context, id uint64) (*chronograf.Organization, error) {
var o chronograf.Organization
err := s.client.db.View(func(tx *bolt.Tx) error {
v := tx.Bucket(OrganizationsBucket).Get(u64tob(id))
if v == nil {
return chronograf.ErrOrganizationNotFound
}
return internal.UnmarshalOrganization(v, &o)
})
if err != nil {
return nil, err
}
return &o, nil
}
func (s *OrganizationsStore) each(ctx context.Context, fn func(*chronograf.Organization)) error {
@ -61,29 +95,48 @@ func (s *OrganizationsStore) each(ctx context.Context, fn func(*chronograf.Organ
return nil
}
func (s *OrganizationsStore) Get(ctx context.Context, name string) (*chronograf.Organization, error) {
var org *chronograf.Organization
err := s.each(ctx, func(o *chronograf.Organization) {
if org != nil {
return
func (s *OrganizationsStore) Get(ctx context.Context, q chronograf.OrganizationQuery) (*chronograf.Organization, error) {
if q.ID != nil {
return s.get(ctx, *q.ID)
}
if q.Name != nil {
var org *chronograf.Organization
err := s.each(ctx, func(o *chronograf.Organization) {
if org != nil {
return
}
if o.Name == *q.Name {
org = o
}
})
if err != nil {
return nil, err
}
if o.Name == name {
org = o
if org == nil {
return nil, chronograf.ErrOrganizationNotFound
}
})
return org, nil
}
return nil, fmt.Errorf("must specify either ID, or Name in OrganizationQuery")
}
func (s *OrganizationsStore) Update(ctx context.Context, o *chronograf.Organization) error {
org, err := s.get(ctx, o.ID)
if err != nil {
return nil, err
return err
}
if org == nil {
return nil, chronograf.ErrOrganizationNotFound
}
return org, nil
}
func (s *OrganizationsStore) Update(context.Context, *chronograf.Organization) error {
panic("not implemented")
return s.client.db.Update(func(tx *bolt.Tx) error {
org.Name = o.Name
if v, err := internal.MarshalOrganization(org); err != nil {
return err
} else if err := tx.Bucket(OrganizationsBucket).Put(u64tob(org.ID), v); err != nil {
return err
}
return nil
})
}

View File

@ -2,6 +2,7 @@ package bolt_test
import (
"context"
"fmt"
"testing"
"github.com/google/go-cmp/cmp"
@ -9,11 +10,12 @@ import (
"github.com/influxdata/chronograf"
)
var orgCMPOptions = cmp.Options{
var orgCmpOptions = cmp.Options{
cmpopts.IgnoreFields(chronograf.Organization{}, "ID"),
cmpopts.EquateEmpty(),
}
func TestOrganizationsStore_Get(t *testing.T) {
func TestOrganizationsStore_GetWithName(t *testing.T) {
type args struct {
ctx context.Context
org *chronograf.Organization
@ -68,14 +70,284 @@ func TestOrganizationsStore_Get(t *testing.T) {
}
}
got, err := s.Get(tt.args.ctx, tt.args.org.Name)
got, err := s.Get(tt.args.ctx, chronograf.OrganizationQuery{Name: &tt.args.org.Name})
if (err != nil) != tt.wantErr {
t.Errorf("%q. OrganizationsStore.Get() error = %v, wantErr %v", tt.name, err, tt.wantErr)
return
}
if diff := cmp.Diff(got, tt.want, orgCMPOptions...); diff != "" {
if diff := cmp.Diff(got, tt.want, orgCmpOptions...); diff != "" {
t.Errorf("%q. OrganizationsStore.Get():\n-got/+want\ndiff %s", tt.name, diff)
}
})
}
}
func TestOrganizationsStore_GetWithID(t *testing.T) {
type args struct {
ctx context.Context
org *chronograf.Organization
}
tests := []struct {
name string
args args
want *chronograf.Organization
wantErr bool
addFirst bool
}{
{
name: "Organization not found",
args: args{
ctx: context.Background(),
org: &chronograf.Organization{},
},
wantErr: true,
},
{
name: "Get Organization",
args: args{
ctx: context.Background(),
org: &chronograf.Organization{
Name: "EE - Evil Empire",
},
},
want: &chronograf.Organization{
Name: "EE - Evil Empire",
},
addFirst: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client, err := NewTestClient()
if err != nil {
t.Fatal(err)
}
if err := client.Open(context.TODO()); err != nil {
t.Fatal(err)
}
defer client.Close()
s := client.OrganizationsStore
if tt.addFirst {
tt.args.org, err = s.Add(tt.args.ctx, tt.args.org)
if err != nil {
t.Fatal(err)
}
}
got, err := s.Get(tt.args.ctx, chronograf.OrganizationQuery{ID: &tt.args.org.ID})
if (err != nil) != tt.wantErr {
t.Errorf("%q. OrganizationsStore.Get() error = %v, wantErr %v", tt.name, err, tt.wantErr)
return
}
if diff := cmp.Diff(got, tt.want, orgCmpOptions...); diff != "" {
t.Errorf("%q. OrganizationsStore.Get():\n-got/+want\ndiff %s", tt.name, diff)
}
})
}
}
func TestOrganizationsStore_All(t *testing.T) {
type args struct {
ctx context.Context
orgs []chronograf.Organization
}
tests := []struct {
name string
args args
want []chronograf.Organization
addFirst bool
}{
{
name: "Get Organization",
args: args{
ctx: context.Background(),
orgs: []chronograf.Organization{
{
Name: "EE - Evil Empire",
},
{
Name: "The Good Place",
},
},
},
want: []chronograf.Organization{
{
Name: "EE - Evil Empire",
},
{
Name: "The Good Place",
},
},
addFirst: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client, err := NewTestClient()
if err != nil {
t.Fatal(err)
}
if err := client.Open(context.TODO()); err != nil {
t.Fatal(err)
}
defer client.Close()
s := client.OrganizationsStore
if tt.addFirst {
for _, org := range tt.args.orgs {
_, err = s.Add(tt.args.ctx, &org)
if err != nil {
t.Fatal(err)
}
}
}
got, err := s.All(tt.args.ctx)
if err != nil {
t.Fatal(err)
return
}
if diff := cmp.Diff(got, tt.want, orgCmpOptions...); diff != "" {
t.Errorf("%q. OrganizationsStore.All():\n-got/+want\ndiff %s", tt.name, diff)
}
})
}
}
func TestOrganizationsStore_Update(t *testing.T) {
type args struct {
ctx context.Context
org *chronograf.Organization
name string
}
tests := []struct {
name string
args args
addFirst bool
want *chronograf.Organization
wantErr bool
}{
{
name: "No such organization",
args: args{
ctx: context.Background(),
org: &chronograf.Organization{
Name: "The Okay Place",
},
},
wantErr: true,
},
{
name: "Update organization name",
args: args{
ctx: context.Background(),
org: &chronograf.Organization{
Name: "The Good Place",
},
name: "The Bad Place",
},
want: &chronograf.Organization{
Name: "The Bad Place",
},
addFirst: true,
},
}
for _, tt := range tests {
client, err := NewTestClient()
if err != nil {
t.Fatal(err)
}
if err := client.Open(context.TODO()); err != nil {
t.Fatal(err)
}
defer client.Close()
s := client.OrganizationsStore
if tt.addFirst {
fmt.Println(tt.args.org)
tt.args.org, err = s.Add(tt.args.ctx, tt.args.org)
fmt.Println(tt.args.org)
if err != nil {
t.Fatal(err)
}
}
if tt.args.name != "" {
tt.args.org.Name = tt.args.name
}
if err := s.Update(tt.args.ctx, tt.args.org); (err != nil) != tt.wantErr {
t.Errorf("%q. OrganizationsStore.Update() error = %v, wantErr %v", tt.name, err, tt.wantErr)
}
// for the empty test
if tt.want == nil {
continue
}
got, err := s.Get(tt.args.ctx, chronograf.OrganizationQuery{Name: &tt.args.org.Name})
if err != nil {
t.Fatalf("failed to get organization: %v", err)
}
if diff := cmp.Diff(got, tt.want, orgCmpOptions...); diff != "" {
t.Errorf("%q. OrganizationsStore.Update():\n-got/+want\ndiff %s", tt.name, diff)
}
}
}
func TestOrganizationStore_Delete(t *testing.T) {
type args struct {
ctx context.Context
org *chronograf.Organization
}
tests := []struct {
name string
args args
addFirst bool
wantErr bool
}{
{
name: "No such organization",
args: args{
ctx: context.Background(),
org: &chronograf.Organization{
ID: 10,
},
},
wantErr: true,
},
{
name: "Delete new organization",
args: args{
ctx: context.Background(),
org: &chronograf.Organization{
Name: "The Deleted Place",
},
},
addFirst: true,
},
}
for _, tt := range tests {
client, err := NewTestClient()
if err != nil {
t.Fatal(err)
}
if err := client.Open(context.TODO()); err != nil {
t.Fatal(err)
}
defer client.Close()
s := client.OrganizationsStore
if tt.addFirst {
tt.args.org, _ = s.Add(tt.args.ctx, tt.args.org)
}
if err := s.Delete(tt.args.ctx, tt.args.org); (err != nil) != tt.wantErr {
t.Errorf("%q. OrganizationsStore.Delete() error = %v, wantErr %v", tt.name, err, tt.wantErr)
}
}
}

View File

@ -747,6 +747,7 @@ type LayoutStore interface {
// Organization is a group of resources under a common name
type Organization struct {
ID uint64 `json:"id"`
Name string `json:"name"`
SourcesStore SourcesStore
ServersStore ServersStore
@ -754,6 +755,13 @@ type Organization struct {
UsersStore UsersStore
}
// OrganizationQuery represents the attributes that a user may be retrieved by.
// It is predominantly used in the OrganizationsStore.Get method.
type OrganizationQuery struct {
ID *uint64
Name *string
}
// OrganizationsStore is the storage and retrieval of Organizations
type OrganizationsStore interface {
// Add creates a new Organization
@ -763,7 +771,7 @@ type OrganizationsStore interface {
// Delete removes an Organization from the OrganizationsStore
Delete(context.Context, *Organization) error
// Get retrieves an Organization from the OrganizationsStore
Get(context.Context, string) (*Organization, error)
Get(context.Context, OrganizationQuery) (*Organization, error)
// Update updates an Organization in the OrganizationsStore
Update(context.Context, *Organization) error
}