mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
apiserver: update tests to use sub-benchmarks (aes_test.go)
This commit is contained in:
parent
99ebcd94c9
commit
19026bf962
@ -149,14 +149,41 @@ func TestCBCKeyRotation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkGCMRead_16_1024(b *testing.B) { benchmarkGCMRead(b, 16, 1024, false) }
|
func BenchmarkGCMRead(b *testing.B) {
|
||||||
func BenchmarkGCMRead_32_1024(b *testing.B) { benchmarkGCMRead(b, 32, 1024, false) }
|
tests := []struct {
|
||||||
func BenchmarkGCMRead_32_16384(b *testing.B) { benchmarkGCMRead(b, 32, 16384, false) }
|
keyLength int
|
||||||
func BenchmarkGCMRead_32_16384_Stale(b *testing.B) { benchmarkGCMRead(b, 32, 16384, true) }
|
valueLength int
|
||||||
|
expectStale bool
|
||||||
|
}{
|
||||||
|
{keyLength: 16, valueLength: 1024, expectStale: false},
|
||||||
|
{keyLength: 32, valueLength: 1024, expectStale: false},
|
||||||
|
{keyLength: 32, valueLength: 16384, expectStale: false},
|
||||||
|
{keyLength: 32, valueLength: 16384, expectStale: true},
|
||||||
|
}
|
||||||
|
for _, t := range tests {
|
||||||
|
name := fmt.Sprintf("%vKeyLength/%vValueLength/%vExpectStale", t.keyLength, t.valueLength, t.expectStale)
|
||||||
|
b.Run(name, func(b *testing.B) {
|
||||||
|
benchmarkGCMRead(b, t.keyLength, t.valueLength, t.expectStale)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkGCMWrite_16_1024(b *testing.B) { benchmarkGCMWrite(b, 16, 1024) }
|
func BenchmarkGCMWrite(b *testing.B) {
|
||||||
func BenchmarkGCMWrite_32_1024(b *testing.B) { benchmarkGCMWrite(b, 32, 1024) }
|
tests := []struct {
|
||||||
func BenchmarkGCMWrite_32_16384(b *testing.B) { benchmarkGCMWrite(b, 32, 16384) }
|
keyLength int
|
||||||
|
valueLength int
|
||||||
|
}{
|
||||||
|
{keyLength: 16, valueLength: 1024},
|
||||||
|
{keyLength: 32, valueLength: 1024},
|
||||||
|
{keyLength: 32, valueLength: 16384},
|
||||||
|
}
|
||||||
|
for _, t := range tests {
|
||||||
|
name := fmt.Sprintf("%vKeyLength/%vValueLength", t.keyLength, t.valueLength)
|
||||||
|
b.Run(name, func(b *testing.B) {
|
||||||
|
benchmarkGCMWrite(b, t.keyLength, t.valueLength)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func benchmarkGCMRead(b *testing.B, keyLength int, valueLength int, expectStale bool) {
|
func benchmarkGCMRead(b *testing.B, keyLength int, valueLength int, expectStale bool) {
|
||||||
block1, err := aes.NewCipher(bytes.Repeat([]byte("a"), keyLength))
|
block1, err := aes.NewCipher(bytes.Repeat([]byte("a"), keyLength))
|
||||||
@ -227,12 +254,39 @@ func benchmarkGCMWrite(b *testing.B, keyLength int, valueLength int) {
|
|||||||
b.StopTimer()
|
b.StopTimer()
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkCBCRead_32_1024(b *testing.B) { benchmarkCBCRead(b, 32, 1024, false) }
|
func BenchmarkCBCRead(b *testing.B) {
|
||||||
func BenchmarkCBCRead_32_16384(b *testing.B) { benchmarkCBCRead(b, 32, 16384, false) }
|
tests := []struct {
|
||||||
func BenchmarkCBCRead_32_16384_Stale(b *testing.B) { benchmarkCBCRead(b, 32, 16384, true) }
|
keyLength int
|
||||||
|
valueLength int
|
||||||
|
expectStale bool
|
||||||
|
}{
|
||||||
|
{keyLength: 32, valueLength: 1024, expectStale: false},
|
||||||
|
{keyLength: 32, valueLength: 16384, expectStale: false},
|
||||||
|
{keyLength: 32, valueLength: 16384, expectStale: true},
|
||||||
|
}
|
||||||
|
for _, t := range tests {
|
||||||
|
name := fmt.Sprintf("%vKeyLength/%vValueLength/%vExpectStale", t.keyLength, t.valueLength, t.expectStale)
|
||||||
|
b.Run(name, func(b *testing.B) {
|
||||||
|
benchmarkCBCRead(b, t.keyLength, t.valueLength, t.expectStale)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkCBCWrite_32_1024(b *testing.B) { benchmarkCBCWrite(b, 32, 1024) }
|
func BenchmarkCBCWrite(b *testing.B) {
|
||||||
func BenchmarkCBCWrite_32_16384(b *testing.B) { benchmarkCBCWrite(b, 32, 16384) }
|
tests := []struct {
|
||||||
|
keyLength int
|
||||||
|
valueLength int
|
||||||
|
}{
|
||||||
|
{keyLength: 32, valueLength: 1024},
|
||||||
|
{keyLength: 32, valueLength: 16384},
|
||||||
|
}
|
||||||
|
for _, t := range tests {
|
||||||
|
name := fmt.Sprintf("%vKeyLength/%vValueLength", t.keyLength, t.valueLength)
|
||||||
|
b.Run(name, func(b *testing.B) {
|
||||||
|
benchmarkCBCWrite(b, t.keyLength, t.valueLength)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func benchmarkCBCRead(b *testing.B, keyLength int, valueLength int, expectStale bool) {
|
func benchmarkCBCRead(b *testing.B, keyLength int, valueLength int, expectStale bool) {
|
||||||
block1, err := aes.NewCipher(bytes.Repeat([]byte("a"), keyLength))
|
block1, err := aes.NewCipher(bytes.Repeat([]byte("a"), keyLength))
|
||||||
|
Loading…
Reference in New Issue
Block a user