-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change CRD map entries to named object lists (#154)
Co-authored-by: Paolo Ambrosio <paolo.ambrosio2@sky.uk> Co-authored-by: EdwardCuiPeacock <Edward.Cui@nbcuni.com> Co-authored-by: Alex Georgousis <alex.georgousis@outlook.com>
- Loading branch information
1 parent
a5d98cf
commit cfa724c
Showing
132 changed files
with
3,266 additions
and
1,034 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 4 additions & 5 deletions
9
.../config/v1alpha2/zz_generated.deepcopy.go → .../config/v1alpha3/zz_generated.deepcopy.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
//go:build unit | ||
// +build unit | ||
|
||
package pipelines | ||
|
||
import ( | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/sky-uk/kfp-operator/apis" | ||
) | ||
|
||
var _ = Context("ObjectHasher", func() { | ||
var _ = Describe("WriteStringField", func() { | ||
Specify("Adjacent string fields should be considered separate", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteStringField("ab") | ||
oh1.WriteStringField("c") | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteStringField("a") | ||
oh2.WriteStringField("bc") | ||
|
||
Expect(oh1.Sum()).NotTo(Equal(oh2.Sum())) | ||
}) | ||
}) | ||
|
||
var _ = Describe("WriteNamedValueListField", func() { | ||
Specify("Adjacent NamedValue list fields should be considered separate", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "1"}, | ||
{Name: "b", Value: "2"}, | ||
}) | ||
oh1.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "c", Value: "3"}, | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "1"}, | ||
}) | ||
oh2.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "b", Value: "2"}, | ||
{Name: "c", Value: "3"}, | ||
}) | ||
|
||
Expect(oh1.Sum()).NotTo(Equal(oh2.Sum())) | ||
}) | ||
|
||
Specify("NamedValue list key and values should be considered separate", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "ab", Value: "c"}, | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "bc"}, | ||
}) | ||
|
||
Expect(oh1.Sum()).NotTo(Equal(oh2.Sum())) | ||
}) | ||
|
||
Specify("NamedValue list fields should be considered separate", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "bc"}, | ||
{Name: "d", Value: "e"}, | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "b"}, | ||
{Name: "cd", Value: "e"}, | ||
}) | ||
|
||
Expect(oh1.Sum()).NotTo(Equal(oh2.Sum())) | ||
}) | ||
|
||
Specify("NamedValue list field hash should be consistent if the order of entries is changed", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "1"}, | ||
{Name: "b", Value: "2"}, | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "b", Value: "2"}, | ||
{Name: "a", Value: "1"}, | ||
}) | ||
|
||
Expect(oh1.Sum()).To(Equal(oh2.Sum())) | ||
}) | ||
|
||
Specify("NamedValue list field hash should be consistent if the order of multi-entries is changed", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "1"}, | ||
{Name: "a", Value: "2"}, | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteNamedValueListField([]apis.NamedValue{ | ||
{Name: "a", Value: "2"}, | ||
{Name: "a", Value: "1"}, | ||
}) | ||
|
||
Expect(oh1.Sum()).To(Equal(oh2.Sum())) | ||
}) | ||
}) | ||
|
||
var _ = Describe("WriteMapField", func() { | ||
|
||
Specify("Adjacent map fields should be considered separate", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteMapField(map[string]string{ | ||
"a": "1", | ||
"b": "2", | ||
}) | ||
oh1.WriteMapField(map[string]string{ | ||
"c": "3", | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteMapField(map[string]string{ | ||
"a": "1", | ||
}) | ||
oh2.WriteMapField(map[string]string{ | ||
"b": "2", | ||
"c": "3", | ||
}) | ||
|
||
Expect(oh1.Sum()).NotTo(Equal(oh2.Sum())) | ||
}) | ||
|
||
Specify("Map key and values should be considered separate", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteMapField(map[string]string{ | ||
"ab": "c", | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteMapField(map[string]string{ | ||
"a": "bc", | ||
}) | ||
|
||
Expect(oh1.Sum()).NotTo(Equal(oh2.Sum())) | ||
}) | ||
|
||
Specify("Map fields should be considered separate", func() { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteMapField(map[string]string{ | ||
"a": "bc", | ||
"d": "e", | ||
}) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteMapField(map[string]string{ | ||
"a": "b", | ||
"cd": "e", | ||
}) | ||
|
||
Expect(oh1.Sum()).NotTo(Equal(oh2.Sum())) | ||
}) | ||
|
||
Specify("Map field hash should be consistent", func() { | ||
// Map iterators start from a random point. The chance of | ||
// a false positive is {map len}^-{iterations} | ||
iterations := 10 | ||
sameMap := map[string]string{ | ||
"a": "1", | ||
"b": "2", | ||
} | ||
|
||
for i := 0; i < iterations; i++ { | ||
oh1 := NewObjectHasher() | ||
oh1.WriteMapField(sameMap) | ||
|
||
oh2 := NewObjectHasher() | ||
oh2.WriteMapField(sameMap) | ||
|
||
Expect(oh1.Sum()).To(Equal(oh2.Sum())) | ||
} | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.