Skip to content

Commit

Permalink
e2e: add gRPC gateway Lease tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hexfusion committed Mar 20, 2018
1 parent c22afc2 commit 46979c0
Show file tree
Hide file tree
Showing 2 changed files with 386 additions and 0 deletions.
26 changes: 26 additions & 0 deletions e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
package e2e

import (
"encoding/json"
"fmt"
"math/rand"
"path"
"strings"
"time"

Expand Down Expand Up @@ -77,6 +80,29 @@ func spawnWithExpectLines(args []string, xs ...string) ([]string, error) {
return lines, perr
}

func cURLWithExpected(cx ctlCtx, tests []v3cURLTest) error {
p := cx.apiPrefix
for _, t := range tests {
value := fmt.Sprintf("%v", t.value)
if err := cURLPost(cx.epc, cURLReq{endpoint: path.Join(p, t.endpoint), value: value, expected: t.expected}); err != nil {
return fmt.Errorf("prefix (%s) endpoint (%s): error (%v), wanted %v", p, t.endpoint, err, t.expected)
}
}
return nil
}

func randomLeaseID() int64 {
return rand.New(rand.NewSource(time.Now().UnixNano())).Int63()
}

func dataMarshal(data interface{}) (pbm string, e error) {
m, err := json.Marshal(data)
if err != nil {
return "", err
}
return string(m), nil
}

func closeWithTimeout(p *expect.ExpectProcess, d time.Duration) error {
errc := make(chan error, 1)
go func() { errc <- p.Close() }()
Expand Down
Loading

0 comments on commit 46979c0

Please sign in to comment.