vendor: update all dependencies

This commit is contained in:
Nick Craig-Wood
2017-07-23 08:51:42 +01:00
parent 0b6fba34a3
commit eb87cf6f12
2008 changed files with 352617 additions and 1004734 deletions
+29 -53
View File
@@ -31,7 +31,6 @@ import (
cinternal "cloud.google.com/go/internal"
"cloud.google.com/go/internal/testutil"
"cloud.google.com/go/logging"
"cloud.google.com/go/logging/internal"
ltesting "cloud.google.com/go/logging/internal/testing"
"cloud.google.com/go/logging/logadmin"
"golang.org/x/net/context"
@@ -44,6 +43,8 @@ import (
const testLogIDPrefix = "GO-LOGGING-CLIENT/TEST-LOG"
var uids = testutil.NewUIDSpace(testLogIDPrefix)
var (
client *logging.Client
aclient *logadmin.Client
@@ -142,10 +143,9 @@ func TestMain(m *testing.M) {
}
func initLogs(ctx context.Context) {
testLogID = ltesting.UniqueID(testLogIDPrefix)
testLogID = uids.New()
testFilter = fmt.Sprintf(`logName = "projects/%s/logs/%s"`, testProjectID,
strings.Replace(testLogID, "/", "%2F", -1))
// TODO(jba): Clean up from previous aborted tests by deleting old logs; requires ListLogs RPC.
}
// Testing of Logger.Log is done in logadmin_test.go, TestEntries.
@@ -247,10 +247,9 @@ func compareEntry(got, want *logging.Entry) bool {
return false
}
if !reflect.DeepEqual(got.Payload, want.Payload) {
if !ltesting.PayloadEqual(got.Payload, want.Payload) {
return false
}
if !reflect.DeepEqual(got.Labels, want.Labels) {
return false
}
@@ -396,11 +395,10 @@ loop:
// Try to log something that can't be JSON-marshalled.
lg := client.Logger(testLogID)
lg.Log(logging.Entry{Payload: func() {}})
// Expect an error.
select {
case <-errorc: // pass
case <-time.After(100 * time.Millisecond):
t.Fatal("expected an error but timed out")
// Expect an error from Flush.
err := lg.Flush()
if err == nil {
t.Fatal("expected error, got nil")
}
}
@@ -447,53 +445,31 @@ func TestPing(t *testing.T) {
}
}
func TestDeleteLog(t *testing.T) {
initLogs(ctx) // Generate new testLogID
// Write some log entries.
func TestLogsAndDelete(t *testing.T) {
// This function tests both the Logs and DeleteLog methods. We only try to
// delete those logs that we can observe and that were generated by this
// test. This may not include the logs generated from the current test run,
// because the logging service is only eventually consistent. It's
// therefore possible that on some runs, this test will do nothing.
ctx := context.Background()
payloads := []string{"p1", "p2"}
lg := client.Logger(testLogID)
for _, p := range payloads {
// Use the insert ID to guarantee iteration order.
lg.Log(logging.Entry{Payload: p, InsertID: p})
}
lg.Flush()
var got []*logging.Entry
ok := waitFor(func() bool {
var err error
got, err = allTestLogEntries(ctx)
it := aclient.Logs(ctx)
nDeleted := 0
for {
logID, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
t.Log("fetching log entries: ", err)
return false
t.Fatal(err)
}
if strings.HasPrefix(logID, testLogIDPrefix) {
if err := aclient.DeleteLog(ctx, logID); err != nil {
t.Fatalf("deleting %q: %v", logID, err)
}
nDeleted++
}
return len(got) == 2
})
if !ok {
t.Fatalf("timed out; got: %d, want: %d\n", len(got), 2)
}
// Sleep.
// Write timestamp uses client-provided timestamp, delete uses server
// timestamp. We sleep to reduce the possibility that the logs are never
// "deleted" because of clock skew.
// This is the recommended approach by Stackdriver team.
time.Sleep(3 * time.Second)
// Delete the log
err := aclient.DeleteLog(ctx, testLogID)
if err != nil {
log.Fatalf("error deleting log: %v", err)
}
// DeleteLog can take some time to happen, so we wait for the log to
// disappear. There is no direct way to determine if a log exists, so we
// just wait until there are no log entries associated with the ID.
filter := fmt.Sprintf(`logName = "%s"`, internal.LogPath("projects/"+testProjectID, testLogID))
ok = waitFor(func() bool { return countLogEntries(ctx, filter) == 0 })
if !ok {
t.Fatalf("timed out waiting for log entries to be deleted")
}
t.Logf("deleted %d logs", nDeleted)
}
// waitFor calls f repeatedly with exponential backoff, blocking until it returns true.