From 9df6ae4655867ea1afeca01e00808cd9090c8909 Mon Sep 17 00:00:00 2001 From: kodsurfer Date: Sat, 13 Jul 2024 02:28:09 +0300 Subject: [PATCH] #94 rename OvsSet to OvsDataSet Signed-off-by: kodsurfer --- cache/cache_test.go | 2 +- client/api_test.go | 2 +- client/client_test.go | 2 +- database/inmemory/inmemory_test.go | 16 +++--- mapper/mapper_test.go | 2 +- ovsdb/bindings.go | 8 +-- ovsdb/condition_test.go | 4 +- ovsdb/encoding_test.go | 2 +- ovsdb/mutation_test.go | 4 +- ovsdb/named_uuid.go | 2 +- ovsdb/named_uuid_test.go | 12 ++--- ovsdb/notation.go | 2 +- ovsdb/notation_test.go | 12 ++--- ovsdb/schema.go | 22 ++++---- ovsdb/set.go | 20 ++++---- ovsdb/set_test.go | 2 +- server/server_integration_test.go | 26 +++++----- test/ovs/ovs_integration_test.go | 34 ++++++------- updates/merge.go | 10 ++-- updates/merge_test.go | 80 +++++++++++++++--------------- updates/references.go | 16 +++--- updates/updates_test.go | 54 ++++++++++---------- 22 files changed, 167 insertions(+), 167 deletions(-) diff --git a/cache/cache_test.go b/cache/cache_test.go index abca11d5..74777e2d 100644 --- a/cache/cache_test.go +++ b/cache/cache_test.go @@ -2037,7 +2037,7 @@ func BenchmarkPopulate2UpdateArray(b *testing.B) { b.ResetTimer() for n := 0; n < b.N; n++ { for i := 0; i < numRows; i++ { - updatedRow := ovsdb.Row(map[string]interface{}{"array": ovsdb.OvsSet{GoSet: updateSet}}) + updatedRow := ovsdb.Row(map[string]interface{}{"array": ovsdb.OvsDataSet{GoSet: updateSet}}) err := tc.Populate2(ovsdb.TableUpdates2{ "Open_vSwitch": { "foo": &ovsdb.RowUpdate2{ diff --git a/client/api_test.go b/client/api_test.go index 7c768109..dee32853 100644 --- a/client/api_test.go +++ b/client/api_test.go @@ -1944,7 +1944,7 @@ func TestAPIWait(t *testing.T) { { Column: "up", Function: ovsdb.ConditionNotEqual, - Value: ovsdb.OvsSet{GoSet: []interface{}{true}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{true}}, }, }, Until: string(ovsdb.WaitConditionNotEqual), diff --git a/client/client_test.go b/client/client_test.go index f6e4da05..e1510028 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -493,7 +493,7 @@ var schema = `{ } }` -func testOvsSet(t *testing.T, set interface{}) ovsdb.OvsSet { +func testOvsSet(t *testing.T, set interface{}) ovsdb.OvsDataSet { oSet, err := ovsdb.NewOvsSet(set) assert.Nil(t, err) return oSet diff --git a/database/inmemory/inmemory_test.go b/database/inmemory/inmemory_test.go index 322c021f..f2d9cbfe 100644 --- a/database/inmemory/inmemory_test.go +++ b/database/inmemory/inmemory_test.go @@ -586,7 +586,7 @@ func TestMultipleOps(t *testing.T) { ovsdb.NewCondition("_uuid", ovsdb.ConditionEqual, ovsdb.UUID{GoUUID: bridgeUUID}), }, Row: ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}, ovsdb.UUID{GoUUID: "port10"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}, ovsdb.UUID{GoUUID: "port10"}}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key1": "value1", "key10": "value10"}}, }, } @@ -612,7 +612,7 @@ func TestMultipleOps(t *testing.T) { Op: ovsdb.OperationMutate, Mutations: []ovsdb.Mutation{ *ovsdb.NewMutation("external_ids", ovsdb.MutateOperationInsert, ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"keyA": "valueA"}}), - *ovsdb.NewMutation("ports", ovsdb.MutateOperationDelete, ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}, ovsdb.UUID{GoUUID: "port10"}}}), + *ovsdb.NewMutation("ports", ovsdb.MutateOperationDelete, ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}, ovsdb.UUID{GoUUID: "port10"}}}), }, } ops = append(ops, op) @@ -625,7 +625,7 @@ func TestMultipleOps(t *testing.T) { Op: ovsdb.OperationMutate, Mutations: []ovsdb.Mutation{ *ovsdb.NewMutation("external_ids", ovsdb.MutateOperationDelete, ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key10": "value10"}}), - *ovsdb.NewMutation("ports", ovsdb.MutateOperationInsert, ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}}}), + *ovsdb.NewMutation("ports", ovsdb.MutateOperationInsert, ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}}}), }, } ops = append(ops, op2) @@ -642,19 +642,19 @@ func TestMultipleOps(t *testing.T) { bridgeUUID: &ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"keyA": "valueA", "key10": "value10"}}, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port10"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port10"}}}, }, Old: &ovsdb.Row{ "_uuid": ovsdb.UUID{GoUUID: bridgeUUID}, "name": "a_bridge_to_nowhere", "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key1": "value1", "key10": "value10"}}, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}, ovsdb.UUID{GoUUID: "port10"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}, ovsdb.UUID{GoUUID: "port10"}}}, }, New: &ovsdb.Row{ "_uuid": ovsdb.UUID{GoUUID: bridgeUUID}, "name": "a_bridge_to_nowhere", "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key1": "value1", "keyA": "valueA"}}, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "port1"}}}, }, }, }, @@ -941,7 +941,7 @@ func TestCheckIndexesWithReferentialIntegrity(t *testing.T) { Op: ovsdb.OperationInsert, UUID: ovsUUID, Row: ovsdb.Row{ - "manager_options": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: managerUUID}}}, + "manager_options": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: managerUUID}}}, }, }, { @@ -978,7 +978,7 @@ func TestCheckIndexesWithReferentialIntegrity(t *testing.T) { Table: "Open_vSwitch", Op: ovsdb.OperationUpdate, Row: ovsdb.Row{ - "manager_options": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: managerUUID2}}}, + "manager_options": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: managerUUID2}}}, }, Where: []ovsdb.Condition{ ovsdb.NewCondition("_uuid", ovsdb.ConditionEqual, ovsdb.UUID{GoUUID: ovsUUID}), diff --git a/mapper/mapper_test.go b/mapper/mapper_test.go index 7a4d40b1..7cd3953a 100644 --- a/mapper/mapper_test.go +++ b/mapper/mapper_test.go @@ -1049,7 +1049,7 @@ func TestMapperMutation(t *testing.T) { } } -func testOvsSet(t *testing.T, set interface{}) ovsdb.OvsSet { +func testOvsSet(t *testing.T, set interface{}) ovsdb.OvsDataSet { oSet, err := ovsdb.NewOvsSet(set) assert.Nil(t, err) return oSet diff --git a/ovsdb/bindings.go b/ovsdb/bindings.go index aebe2c2d..1d537661 100644 --- a/ovsdb/bindings.go +++ b/ovsdb/bindings.go @@ -116,7 +116,7 @@ func OvsToNativeSlice(baseType string, ovsElem interface{}) (interface{}, error) naType := NativeTypeFromAtomic(baseType) var nativeSet reflect.Value switch ovsSet := ovsElem.(type) { - case OvsSet: + case OvsDataSet: nativeSet = reflect.MakeSlice(reflect.SliceOf(naType), 0, len(ovsSet.GoSet)) for _, v := range ovsSet.GoSet { nv, err := OvsToNativeAtomic(baseType, v) @@ -152,7 +152,7 @@ func OvsToNative(column *ColumnSchema, ovsElem interface{}) (interface{}, error) switch naType.Kind() { case reflect.Ptr: switch ovsSet := ovsElem.(type) { - case OvsSet: + case OvsDataSet: if len(ovsSet.GoSet) > 1 { return nil, fmt.Errorf("expected a slice of len =< 1, but got a slice with %d elements", len(ovsSet.GoSet)) } @@ -233,7 +233,7 @@ func NativeToOvs(column *ColumnSchema, rawElem interface{}) (interface{}, error) case TypeUUID: return UUID{GoUUID: rawElem.(string)}, nil case TypeSet: - var ovsSet OvsSet + var ovsSet OvsDataSet if column.TypeObj.Key.Type == TypeUUID { ovsSlice := []interface{}{} if _, ok := rawElem.([]string); ok { @@ -250,7 +250,7 @@ func NativeToOvs(column *ColumnSchema, rawElem interface{}) (interface{}, error) } else { return nil, fmt.Errorf("uuid slice was neither []string or *string") } - ovsSet = OvsSet{GoSet: ovsSlice} + ovsSet = OvsDataSet{GoSet: ovsSlice} } else { var err error diff --git a/ovsdb/condition_test.go b/ovsdb/condition_test.go index 4eae9cb8..71b954d3 100644 --- a/ovsdb/condition_test.go +++ b/ovsdb/condition_test.go @@ -71,7 +71,7 @@ func TestConditionMarshalUnmarshalJSON(t *testing.T) { }, { "test set", - Condition{"foo", ConditionExcludes, OvsSet{GoSet: []interface{}{"foo", "bar", "baz"}}}, + Condition{"foo", ConditionExcludes, OvsDataSet{GoSet: []interface{}{"foo", "bar", "baz"}}}, `[ "foo", "excludes", ["set",["foo", "bar", "baz"]] ]`, false, }, @@ -83,7 +83,7 @@ func TestConditionMarshalUnmarshalJSON(t *testing.T) { }, { "test uuid set", - Condition{"foo", ConditionExcludes, OvsSet{GoSet: []interface{}{UUID{GoUUID: "foo"}, UUID{GoUUID: "bar"}}}}, + Condition{"foo", ConditionExcludes, OvsDataSet{GoSet: []interface{}{UUID{GoUUID: "foo"}, UUID{GoUUID: "bar"}}}}, `[ "foo", "excludes", ["set",[["named-uuid", "foo"], ["named-uuid", "bar"]]] ]`, false, }, diff --git a/ovsdb/encoding_test.go b/ovsdb/encoding_test.go index 078bebc8..d7936483 100644 --- a/ovsdb/encoding_test.go +++ b/ovsdb/encoding_test.go @@ -160,7 +160,7 @@ func TestSet(t *testing.T) { assert.Nil(t, err) assert.JSONEqf(t, tt.expected, string(jsonStr), "they should be equal\n") - var res OvsSet + var res OvsDataSet err = json.Unmarshal(jsonStr, &res) assert.Nil(t, err) assert.Equal(t, set.GoSet, res.GoSet, "they should have the same elements\n") diff --git a/ovsdb/mutation_test.go b/ovsdb/mutation_test.go index a70c835b..05e99ddb 100644 --- a/ovsdb/mutation_test.go +++ b/ovsdb/mutation_test.go @@ -65,7 +65,7 @@ func TestMutationMarshalUnmarshalJSON(t *testing.T) { }, { "test set", - Mutation{"foo", MutateOperationInsert, OvsSet{GoSet: []interface{}{"foo", "bar", "baz"}}}, + Mutation{"foo", MutateOperationInsert, OvsDataSet{GoSet: []interface{}{"foo", "bar", "baz"}}}, `[ "foo", "insert", ["set",["foo", "bar", "baz"]] ]`, false, }, @@ -77,7 +77,7 @@ func TestMutationMarshalUnmarshalJSON(t *testing.T) { }, { "test uuid set", - Mutation{"foo", MutateOperationInsert, OvsSet{GoSet: []interface{}{UUID{GoUUID: "foo"}, UUID{GoUUID: "bar"}}}}, + Mutation{"foo", MutateOperationInsert, OvsDataSet{GoSet: []interface{}{UUID{GoUUID: "foo"}, UUID{GoUUID: "bar"}}}}, `[ "foo", "insert", ["set",[["named-uuid", "foo"], ["named-uuid", "bar"]]] ]`, false, }, diff --git a/ovsdb/named_uuid.go b/ovsdb/named_uuid.go index 29034ee9..22d9bec8 100644 --- a/ovsdb/named_uuid.go +++ b/ovsdb/named_uuid.go @@ -117,7 +117,7 @@ func expandNamedUUID(column *ColumnSchema, value interface{}, namedUUIDs map[str } } } else if keyType == TypeUUID { - if ovsSet, ok := value.(OvsSet); ok { + if ovsSet, ok := value.(OvsDataSet); ok { for i, s := range ovsSet.GoSet { if newUUID, ok := expandNamedUUIDAtomic(keyType, s, namedUUIDs); ok { ovsSet.GoSet[i] = newUUID diff --git a/ovsdb/named_uuid_test.go b/ovsdb/named_uuid_test.go index 78f3f9f6..01f21180 100644 --- a/ovsdb/named_uuid_test.go +++ b/ovsdb/named_uuid_test.go @@ -187,23 +187,23 @@ func TestStandaloneExpandNamedUUID(t *testing.T) { "UUID set", map[string]string{"foo": testUUID}, "uuidset", - OvsSet{GoSet: []interface{}{"foo"}}, - OvsSet{GoSet: []interface{}{testUUID}}, + OvsDataSet{GoSet: []interface{}{"foo"}}, + OvsDataSet{GoSet: []interface{}{testUUID}}, }, // OVS []UUID == Go []UUID { "real UUID set", map[string]string{"foo": testUUID}, "real_uuidset", - OvsSet{GoSet: []interface{}{UUID{GoUUID: "foo"}}}, - OvsSet{GoSet: []interface{}{UUID{GoUUID: testUUID}}}, + OvsDataSet{GoSet: []interface{}{UUID{GoUUID: "foo"}}}, + OvsDataSet{GoSet: []interface{}{UUID{GoUUID: testUUID}}}, }, { "set multiple", map[string]string{"foo": testUUID, "bar": testUUID1}, "uuidset", - OvsSet{GoSet: []interface{}{"foo", "bar", "baz"}}, - OvsSet{GoSet: []interface{}{testUUID, testUUID1, "baz"}}, + OvsDataSet{GoSet: []interface{}{"foo", "bar", "baz"}}, + OvsDataSet{GoSet: []interface{}{testUUID, testUUID1, "baz"}}, }, // OVS [UUID]UUID == Go [string]string { diff --git a/ovsdb/notation.go b/ovsdb/notation.go index afad87cd..a664e055 100644 --- a/ovsdb/notation.go +++ b/ovsdb/notation.go @@ -115,7 +115,7 @@ func ovsSliceToGoNotation(val interface{}) (interface{}, error) { err = json.Unmarshal(bsliced, &uuid) return uuid, err case "set": - var oSet OvsSet + var oSet OvsDataSet err = json.Unmarshal(bsliced, &oSet) return oSet, err case "map": diff --git a/ovsdb/notation_test.go b/ovsdb/notation_test.go index c519c69e..61fb1a02 100644 --- a/ovsdb/notation_test.go +++ b/ovsdb/notation_test.go @@ -93,11 +93,11 @@ func TestValidateOvsSet(t *testing.T) { goSlice := []int{1, 2, 3, 4} oSet, err := NewOvsSet(goSlice) if err != nil { - t.Error("Error creating OvsSet ", err) + t.Error("Error creating OvsDataSet ", err) } data, err := json.Marshal(oSet) if err != nil { - t.Error("Error Marshalling OvsSet", err) + t.Error("Error Marshalling OvsDataSet", err) } expected := `["set",[1,2,3,4]]` if string(data) != expected { @@ -106,7 +106,7 @@ func TestValidateOvsSet(t *testing.T) { // Negative condition test oSet, err = NewOvsSet(struct{ foo string }{}) if err == nil { - t.Error("OvsSet must fail for anything other than Slices and atomic types") + t.Error("OvsDataSet must fail for anything other than Slices and atomic types") t.Error("Got", oSet) } } @@ -219,19 +219,19 @@ func TestOvsSliceToGoNotation(t *testing.T) { { "empty set", []interface{}{"set", []interface{}{}}, - OvsSet{GoSet: []interface{}{}}, + OvsDataSet{GoSet: []interface{}{}}, false, }, { "set", []interface{}{"set", []interface{}{"foo", "bar", "baz"}}, - OvsSet{GoSet: []interface{}{"foo", "bar", "baz"}}, + OvsDataSet{GoSet: []interface{}{"foo", "bar", "baz"}}, false, }, { "uuid set", []interface{}{"set", []interface{}{[]interface{}{"named-uuid", "foo"}, []interface{}{"named-uuid", "bar"}}}, - OvsSet{GoSet: []interface{}{UUID{GoUUID: "foo"}, UUID{GoUUID: "bar"}}}, + OvsDataSet{GoSet: []interface{}{UUID{GoUUID: "foo"}, UUID{GoUUID: "bar"}}}, false, }, { diff --git a/ovsdb/schema.go b/ovsdb/schema.go index 285d1e02..2355c3d3 100644 --- a/ovsdb/schema.go +++ b/ovsdb/schema.go @@ -345,7 +345,7 @@ func (b *BaseType) UnmarshalJSON(data []byte) error { // 'enum' is a list or a single element representing a list of exactly one element switch bt.Enum.(type) { case []interface{}: - // it's an OvsSet + // it's an OvsDataSet oSet := bt.Enum.([]interface{}) innerSet := oSet[1].([]interface{}) b.Enum = make([]interface{}, len(innerSet)) @@ -369,16 +369,16 @@ func (b *BaseType) UnmarshalJSON(data []byte) error { // MarshalJSON marshals a base type to JSON func (b BaseType) MarshalJSON() ([]byte, error) { j := struct { - Type string `json:"type,omitempty"` - Enum *OvsSet `json:"enum,omitempty"` - MinReal *float64 `json:"minReal,omitempty"` - MaxReal *float64 `json:"maxReal,omitempty"` - MinInteger *int `json:"minInteger,omitempty"` - MaxInteger *int `json:"maxInteger,omitempty"` - MinLength *int `json:"minLength,omitempty"` - MaxLength *int `json:"maxLength,omitempty"` - RefTable *string `json:"refTable,omitempty"` - RefType *RefType `json:"refType,omitempty"` + Type string `json:"type,omitempty"` + Enum *OvsDataSet `json:"enum,omitempty"` + MinReal *float64 `json:"minReal,omitempty"` + MaxReal *float64 `json:"maxReal,omitempty"` + MinInteger *int `json:"minInteger,omitempty"` + MaxInteger *int `json:"maxInteger,omitempty"` + MinLength *int `json:"minLength,omitempty"` + MaxLength *int `json:"maxLength,omitempty"` + RefTable *string `json:"refTable,omitempty"` + RefType *RefType `json:"refType,omitempty"` }{ Type: b.Type, MinReal: b.minReal, diff --git a/ovsdb/set.go b/ovsdb/set.go index ae1ec59a..e8fc1395 100644 --- a/ovsdb/set.go +++ b/ovsdb/set.go @@ -6,26 +6,26 @@ import ( "reflect" ) -// OvsSet is an OVSDB style set +// OvsDataSet is an OVSDB style set // RFC 7047 has a weird (but understandable) notation for set as described as : // Either an , representing a set with exactly one element, or // a 2-element JSON array that represents a database set value. The // first element of the array must be the string "set", and the // second element must be an array of zero or more s giving the // values in the set. All of the s must have the same type. -type OvsSet struct { +type OvsDataSet struct { GoSet []interface{} } // NewOvsSet creates a new OVSDB style set from a Go interface (object) -func NewOvsSet(obj interface{}) (OvsSet, error) { +func NewOvsSet(obj interface{}) (OvsDataSet, error) { ovsSet := make([]interface{}, 0) var v reflect.Value if reflect.TypeOf(obj).Kind() == reflect.Ptr { v = reflect.ValueOf(obj).Elem() if v.Kind() == reflect.Invalid { // must be a nil pointer, so just return an empty set - return OvsSet{ovsSet}, nil + return OvsDataSet{ovsSet}, nil } } else { v = reflect.ValueOf(obj) @@ -45,16 +45,16 @@ func NewOvsSet(obj interface{}) (OvsSet, error) { if v.Type() == reflect.TypeOf(UUID{}) { ovsSet = append(ovsSet, v.Interface()) } else { - return OvsSet{}, fmt.Errorf("ovsset supports only go slice/string/numbers/uuid or pointers to those types") + return OvsDataSet{}, fmt.Errorf("ovsset supports only go slice/string/numbers/uuid or pointers to those types") } default: - return OvsSet{}, fmt.Errorf("ovsset supports only go slice/string/numbers/uuid or pointers to those types") + return OvsDataSet{}, fmt.Errorf("ovsset supports only go slice/string/numbers/uuid or pointers to those types") } - return OvsSet{ovsSet}, nil + return OvsDataSet{ovsSet}, nil } // MarshalJSON wil marshal an OVSDB style Set in to a JSON byte array -func (o OvsSet) MarshalJSON() ([]byte, error) { +func (o OvsDataSet) MarshalJSON() ([]byte, error) { switch l := len(o.GoSet); { case l == 1: return json.Marshal(o.GoSet[0]) @@ -68,9 +68,9 @@ func (o OvsSet) MarshalJSON() ([]byte, error) { } // UnmarshalJSON will unmarshal a JSON byte array to an OVSDB style Set -func (o *OvsSet) UnmarshalJSON(b []byte) (err error) { +func (o *OvsDataSet) UnmarshalJSON(b []byte) (err error) { o.GoSet = make([]interface{}, 0) - addToSet := func(o *OvsSet, v interface{}) error { + addToSet := func(o *OvsDataSet, v interface{}) error { goVal, err := ovsSliceToGoNotation(v) if err == nil { o.GoSet = append(o.GoSet, goVal) diff --git a/ovsdb/set_test.go b/ovsdb/set_test.go index 12857a87..70189588 100644 --- a/ovsdb/set_test.go +++ b/ovsdb/set_test.go @@ -89,7 +89,7 @@ func BenchmarkSetMarshalJSONUUID8(b *testing.B) { func benchmarkSetUnmarshalJSON(data []byte, b *testing.B) { for n := 0; n < b.N; n++ { - var s OvsSet + var s OvsDataSet err := json.Unmarshal(data, &s) if err != nil { b.Fatal(err) diff --git a/server/server_integration_test.go b/server/server_integration_test.go index e4273df9..879a7a94 100644 --- a/server/server_integration_test.go +++ b/server/server_integration_test.go @@ -547,8 +547,8 @@ func TestReferentialIntegrity(t *testing.T) { UUID: bridgeUUID, Row: ovsdb.Row{ "name": bridgeUUID, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, - "mirrors": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "mirrors": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, }, }, { @@ -565,7 +565,7 @@ func TestReferentialIntegrity(t *testing.T) { UUID: mirrorUUID, Row: ovsdb.Row{ "name": mirrorUUID, - "select_src_port": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "select_src_port": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, }, }, }, @@ -639,8 +639,8 @@ func TestReferentialIntegrity(t *testing.T) { UUID: bridgeUUID, Row: ovsdb.Row{ "name": bridgeUUID, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, - "mirrors": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, + "mirrors": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, }, }, { @@ -665,7 +665,7 @@ func TestReferentialIntegrity(t *testing.T) { UUID: mirrorUUID, Row: ovsdb.Row{ "name": mirrorUUID, - "select_src_port": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, + "select_src_port": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, }, }, }, @@ -702,8 +702,8 @@ func TestReferentialIntegrity(t *testing.T) { UUID: bridgeUUID, Row: ovsdb.Row{ "name": bridgeUUID, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, - "mirrors": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "mirrors": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, }, }, { @@ -720,7 +720,7 @@ func TestReferentialIntegrity(t *testing.T) { UUID: mirrorUUID, Row: ovsdb.Row{ "name": mirrorUUID, - "select_src_port": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "select_src_port": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, }, }, }, @@ -745,8 +745,8 @@ func TestReferentialIntegrity(t *testing.T) { UUID: bridgeUUID, Row: ovsdb.Row{ "name": bridgeUUID, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, - "mirrors": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "mirrors": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, }, }, { @@ -763,7 +763,7 @@ func TestReferentialIntegrity(t *testing.T) { UUID: mirrorUUID, Row: ovsdb.Row{ "name": mirrorUUID, - "select_src_port": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "select_src_port": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, }, }, }, @@ -793,7 +793,7 @@ func TestReferentialIntegrity(t *testing.T) { Table: "Open_vSwitch", UUID: ovsUUID, Row: ovsdb.Row{ - "bridges": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: bridgeUUID}}}, + "bridges": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: bridgeUUID}}}, }, }) diff --git a/test/ovs/ovs_integration_test.go b/test/ovs/ovs_integration_test.go index 88da6419..b6bdd422 100644 --- a/test/ovs/ovs_integration_test.go +++ b/test/ovs/ovs_integration_test.go @@ -1130,7 +1130,7 @@ func (suite *OVSIntegrationSuite) TestMultipleOpsSameRow() { UUIDName: port1UUID, Row: ovsdb.Row{ "name": port1UUID, - "interfaces": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: iface1UUID}}}, + "interfaces": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: iface1UUID}}}, }, }, } @@ -1157,7 +1157,7 @@ func (suite *OVSIntegrationSuite) TestMultipleOpsSameRow() { UUIDName: port10UUID, Row: ovsdb.Row{ "name": port10UUID, - "interfaces": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: iface10UUID}}}, + "interfaces": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: iface10UUID}}}, }, }, } @@ -1315,8 +1315,8 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: bridgeUUID, Row: ovsdb.Row{ "name": bridgeUUID, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, - "mirrors": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "mirrors": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, }, }, { @@ -1325,7 +1325,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: port1UUID, Row: ovsdb.Row{ "name": port1UUID, - "interfaces": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, + "interfaces": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, }, }, { @@ -1342,7 +1342,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: mirrorUUID, Row: ovsdb.Row{ "name": mirrorUUID, - "select_src_port": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "select_src_port": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, }, }, }, @@ -1417,8 +1417,8 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: bridgeUUID, Row: ovsdb.Row{ "name": bridgeUUID, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, - "mirrors": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, + "mirrors": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, }, }, { @@ -1427,7 +1427,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: port1UUID, Row: ovsdb.Row{ "name": port1UUID, - "interfaces": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, + "interfaces": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, }, }, { @@ -1436,7 +1436,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: port2UUID, Row: ovsdb.Row{ "name": port2UUID, - "interfaces": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, + "interfaces": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, }, }, { @@ -1453,7 +1453,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: mirrorUUID, Row: ovsdb.Row{ "name": mirrorUUID, - "select_src_port": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, + "select_src_port": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}, ovsdb.UUID{GoUUID: port2UUID}}}, }, }, }, @@ -1481,8 +1481,8 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: bridgeUUID, Row: ovsdb.Row{ "name": bridgeUUID, - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, - "mirrors": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "mirrors": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: mirrorUUID}}}, }, }, { @@ -1491,7 +1491,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: port1UUID, Row: ovsdb.Row{ "name": port1UUID, - "interfaces": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, + "interfaces": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: interfaceUUID}}}, }, }, { @@ -1508,7 +1508,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { UUID: mirrorUUID, Row: ovsdb.Row{ "name": mirrorUUID, - "select_src_port": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, + "select_src_port": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: port1UUID}}}, }, }, }, @@ -1539,7 +1539,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { { Mutator: ovsdb.MutateOperationInsert, Column: "bridges", - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: bridgeUUID}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: bridgeUUID}}}, }, }, Where: []ovsdb.Condition{ @@ -1601,7 +1601,7 @@ func (suite *OVSIntegrationSuite) TestReferentialIntegrity() { { Mutator: ovsdb.MutateOperationDelete, Column: "bridges", - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: bridgeUUID}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: bridgeUUID}}}, }, }, Where: []ovsdb.Condition{ diff --git a/updates/merge.go b/updates/merge.go index 562f2262..3425e509 100644 --- a/updates/merge.go +++ b/updates/merge.go @@ -97,16 +97,16 @@ func mergeModifyRow(ts *ovsdb.TableSchema, o, a, b *ovsdb.Row) *ovsdb.Row { // difference only supports set or map values that are comparable with // no pointers. This should be currently fine because the set or map // values should only be non pointer atomic types or the UUID struct. - case ovsdb.OvsSet: - aSet := aMod[k].(ovsdb.OvsSet) - bSet := v.(ovsdb.OvsSet) + case ovsdb.OvsDataSet: + aSet := aMod[k].(ovsdb.OvsDataSet) + bSet := v.(ovsdb.OvsDataSet) // handle sets of multiple values, single value sets are handled as // atomic values if ts.Column(k).TypeObj.Max() != 1 { // set difference is a fully transitive operation so we dont // need to do anything special to merge two differences result, changed = setDifference(aSet.GoSet, bSet.GoSet) - result = ovsdb.OvsSet{GoSet: result.([]interface{})} + result = ovsdb.OvsDataSet{GoSet: result.([]interface{})} } case ovsdb.OvsMap: aMap := aMod[k].(ovsdb.OvsMap) @@ -132,7 +132,7 @@ func mergeModifyRow(ts *ovsdb.TableSchema, o, a, b *ovsdb.Row) *ovsdb.Row { // assume zero value if original does not have the column o = reflect.Zero(reflect.TypeOf(v)).Interface() } - if set, ok := o.(ovsdb.OvsSet); ok { + if set, ok := o.(ovsdb.OvsDataSet); ok { // atomic optional values are cleared out with an empty set // if the original value was also cleared out, use an empty set // instead of a nil set so that mergeAtomicDifference notices diff --git a/updates/merge_test.go b/updates/merge_test.go index 1b6318ad..c9cea93b 100644 --- a/updates/merge_test.go +++ b/updates/merge_test.go @@ -724,10 +724,10 @@ func Test_merge(t *testing.T) { }, New: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -743,14 +743,14 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -769,10 +769,10 @@ func Test_merge(t *testing.T) { }, New: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -792,14 +792,14 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -815,14 +815,14 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, }, }, }, @@ -845,10 +845,10 @@ func Test_merge(t *testing.T) { }, New: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -863,13 +863,13 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge", }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{}}, }, }, }, @@ -890,14 +890,14 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -912,13 +912,13 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge", }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{}}, }, }, }, @@ -934,13 +934,13 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge", }, Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{}}, }, }, }, @@ -959,13 +959,13 @@ func Test_merge(t *testing.T) { }, rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port2"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port2"}}, }, New: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port3"}}, }, Modify: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port2", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port2", "port3"}}, }, }, }, @@ -980,13 +980,13 @@ func Test_merge(t *testing.T) { }, rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port3"}}, }, New: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port2"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port2"}}, }, Modify: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port2", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port2", "port3"}}, }, }, }, @@ -1058,21 +1058,21 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port2"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port2"}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key": "value", "key1": "value1", "key2": "value2"}}, - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, }, New: &ovsdb.Row{ "name": "bridge2", - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port3"}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key": "value1", "key1": "value1", "key3": "value3"}}, - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, Modify: &ovsdb.Row{ "name": "bridge2", - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port2", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port2", "port3"}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key": "value1", "key2": "value2", "key3": "value3"}}, - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -1092,19 +1092,19 @@ func Test_merge(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge2", - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port3"}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key": "value1", "key1": "value1", "key3": "value3"}}, }, New: &ovsdb.Row{ "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port1", "port2"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port1", "port2"}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key": "value", "key1": "value1", "key2": "value2"}}, }, Modify: &ovsdb.Row{ "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{"port2", "port3"}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{"port2", "port3"}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{"key": "value", "key2": "value2", "key3": "value3"}}, - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, }, }, }, diff --git a/updates/references.go b/updates/references.go index 938d02aa..371a1205 100644 --- a/updates/references.go +++ b/updates/references.go @@ -376,17 +376,17 @@ func (rt *referenceTracker) processWeakReferences() (ModelUpdates, error) { if !ok { mutationSet = []interface{}{} } else { - mutationSet = value.(ovsdb.OvsSet).GoSet + mutationSet = value.(ovsdb.OvsDataSet).GoSet } mutationSet = append(mutationSet, ovsdb.UUID{GoUUID: to}) // track the new length of the set if !isEmptyAllowed { - originalSet := originalRows[uuid][spec.FromColumn].(ovsdb.OvsSet).GoSet + originalSet := originalRows[uuid][spec.FromColumn].(ovsdb.OvsDataSet).GoSet becomesLen = len(originalSet) - len(mutationSet) } - updatedRows[uuid][spec.FromColumn] = ovsdb.OvsSet{GoSet: mutationSet} + updatedRows[uuid][spec.FromColumn] = ovsdb.OvsDataSet{GoSet: mutationSet} case ovsdb.TypeUUID: // this is an atomic UUID value that needs to be cleared @@ -501,7 +501,7 @@ func (rt *referenceTracker) updateRow(table, uuid string, row ovsdb.Row) (ModelU mutations = append(mutations, *ovsdb.NewMutation(column, ovsdb.MutateOperationDelete, value)) continue } - update[column] = ovsdb.OvsSet{GoSet: []interface{}{}} + update[column] = ovsdb.OvsDataSet{GoSet: []interface{}{}} } updates := ModelUpdates{} @@ -606,10 +606,10 @@ func getReferenceModificationsFromColumn(dbModel *model.DatabaseModel, table, uu oldUUID = old.(ovsdb.UUID) } return getReferenceModificationsFromAtom(dbModel, table, uuid, column, v, oldUUID) - case ovsdb.OvsSet: - var oldSet ovsdb.OvsSet + case ovsdb.OvsDataSet: + var oldSet ovsdb.OvsDataSet if old != nil { - oldSet = old.(ovsdb.OvsSet) + oldSet = old.(ovsdb.OvsDataSet) } return getReferenceModificationsFromSet(dbModel, table, uuid, column, v, oldSet) case ovsdb.OvsMap: @@ -661,7 +661,7 @@ func getReferenceModificationsFromMap(dbModel *model.DatabaseModel, table, uuid, return refs } -func getReferenceModificationsFromSet(dbModel *model.DatabaseModel, table, uuid, column string, modify, old ovsdb.OvsSet) database.References { +func getReferenceModificationsFromSet(dbModel *model.DatabaseModel, table, uuid, column string, modify, old ovsdb.OvsDataSet) database.References { // if the modify set is empty, it means the op is clearing an atomic value // so pick the old value instead value := modify diff --git a/updates/updates_test.go b/updates/updates_test.go index 6d67fee5..7273858e 100644 --- a/updates/updates_test.go +++ b/updates/updates_test.go @@ -679,12 +679,12 @@ func TestUpdates_AddOperation(t *testing.T) { { Column: "ports", Mutator: ovsdb.MutateOperationInsert, - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid1"}, ovsdb.UUID{GoUUID: "uuid3"}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid1"}, ovsdb.UUID{GoUUID: "uuid3"}}}, }, { Column: "ports", Mutator: ovsdb.MutateOperationDelete, - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid3"}, ovsdb.UUID{GoUUID: "uuid1"}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid3"}, ovsdb.UUID{GoUUID: "uuid1"}}}, }, }, }, @@ -707,15 +707,15 @@ func TestUpdates_AddOperation(t *testing.T) { Old: &ovsdb.Row{ "_uuid": ovsdb.UUID{GoUUID: "uuid"}, "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid1"}, ovsdb.UUID{GoUUID: "uuid2"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid1"}, ovsdb.UUID{GoUUID: "uuid2"}}}, }, New: &ovsdb.Row{ "_uuid": ovsdb.UUID{GoUUID: "uuid"}, "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid2"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid2"}}}, }, Modify: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid1"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid1"}}}, }, }, }, @@ -749,7 +749,7 @@ func TestUpdates_AddOperation(t *testing.T) { { Column: "external_ids", Mutator: ovsdb.MutateOperationDelete, - Value: ovsdb.OvsSet{GoSet: []interface{}{"key"}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{"key"}}, }, { Column: "external_ids", @@ -775,7 +775,7 @@ func TestUpdates_AddOperation(t *testing.T) { { Column: "ports", Mutator: ovsdb.MutateOperationInsert, - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, }, }, }, @@ -813,12 +813,12 @@ func TestUpdates_AddOperation(t *testing.T) { New: &ovsdb.Row{ "_uuid": ovsdb.UUID{GoUUID: "uuid"}, "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, }, Insert: &ovsdb.Row{ "_uuid": ovsdb.UUID{GoUUID: "uuid"}, "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, }, }, }, @@ -841,7 +841,7 @@ func TestUpdates_AddOperation(t *testing.T) { { Column: "ports", Mutator: ovsdb.MutateOperationInsert, - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, }, }, }, @@ -893,11 +893,11 @@ func TestUpdates_AddOperation(t *testing.T) { New: &ovsdb.Row{ "_uuid": ovsdb.UUID{GoUUID: "uuid"}, "name": "bridge2", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, }, Modify: &ovsdb.Row{ "name": "bridge2", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid"}}}, }, }, }, @@ -997,7 +997,7 @@ func TestUpdates_AddOperation(t *testing.T) { { Column: "ports", Mutator: ovsdb.MutateOperationInsert, - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-2"}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-2"}}}, }, }, }, @@ -1014,11 +1014,11 @@ func TestUpdates_AddOperation(t *testing.T) { rowUpdate2: &ovsdb.RowUpdate2{ Old: &ovsdb.Row{ "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-1"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-1"}}}, }, Delete: &ovsdb.Row{ "name": "bridge", - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-1"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-1"}}}, }, }, }, @@ -1038,7 +1038,7 @@ func TestUpdates_AddOperation(t *testing.T) { { Column: "ports", Mutator: ovsdb.MutateOperationInsert, - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-2"}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-2"}}}, }, }, }, @@ -1057,7 +1057,7 @@ func TestUpdates_AddOperation(t *testing.T) { { Column: "ports", Mutator: ovsdb.MutateOperationInsert, - Value: ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-2"}}}, + Value: ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "uuid-2"}}}, }, }, }, @@ -1374,7 +1374,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, ru2: ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "foo"}, ovsdb.UUID{GoUUID: "bar"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "foo"}, ovsdb.UUID{GoUUID: "bar"}}}, }, }, }, @@ -1394,7 +1394,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, rowUpdate2: &ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "ports": ovsdb.OvsSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "foo"}, ovsdb.UUID{GoUUID: "bar"}}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{ovsdb.UUID{GoUUID: "foo"}, ovsdb.UUID{GoUUID: "bar"}}}, }, }, }, @@ -1454,7 +1454,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, ru2: ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -1474,7 +1474,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, rowUpdate2: &ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -1493,7 +1493,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, ru2: ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -1512,7 +1512,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, rowUpdate2: &ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{newDatapathID}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{newDatapathID}}, }, }, }, @@ -1532,7 +1532,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, ru2: ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{}}, }, }, }, @@ -1551,7 +1551,7 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { }, rowUpdate2: &ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{}}, }, }, }, @@ -1575,8 +1575,8 @@ func TestModelUpdates_AddRowUpdate2(t *testing.T) { ru2: ovsdb.RowUpdate2{ Modify: &ovsdb.Row{ "datapath_type": "type", - "datapath_id": ovsdb.OvsSet{GoSet: []interface{}{oldDatapathID}}, - "ports": ovsdb.OvsSet{GoSet: []interface{}{}}, + "datapath_id": ovsdb.OvsDataSet{GoSet: []interface{}{oldDatapathID}}, + "ports": ovsdb.OvsDataSet{GoSet: []interface{}{}}, "external_ids": ovsdb.OvsMap{GoMap: map[interface{}]interface{}{}}, }, },