use incremental API for envoy xDS (#1732)

* use incremental API

* add test

* use backoff v4

* remove panic, add comment to exponential try, add test for HashProto

* merge master

* fix missing import
This commit is contained in:
Caleb Doxsey 2021-01-05 12:45:55 -07:00 committed by GitHub
parent a07d85b174
commit 3524697f6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 511 additions and 238 deletions

View file

@ -8,6 +8,9 @@ import (
"io/ioutil"
"os"
"testing"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/types/known/structpb"
)
func TestPasswordHashing(t *testing.T) {
@ -79,3 +82,25 @@ func ExampleHash() {
fmt.Println(hex.EncodeToString(digest))
// Output: 9f4c795d8ae5c207f19184ccebee6a606c1fdfe509c793614066d613580f03e1
}
func TestHashProto(t *testing.T) {
// This test will hash a protobuf message that has a map 1000 times
// each attempt should result in the same hash if the output is
// deterministic.
var cur []byte
for i := 0; i < 1000; i++ {
s, err := structpb.NewStruct(map[string]interface{}{
"1": "a", "2": "b", "3": "c", "4": "d",
"5": "e", "6": "f", "7": "g", "8": "h",
})
assert.NoError(t, err)
if i == 0 {
cur = HashProto(s)
} else {
nxt := HashProto(s)
if !assert.Equal(t, cur, nxt) {
return
}
}
}
}