| Index: server/logdog/storage/bigtable/bigtable_test.go
|
| diff --git a/server/logdog/storage/bigtable/bigtable_test.go b/server/logdog/storage/bigtable/bigtable_test.go
|
| index dbdb711004951bdb1c973a3f158c5b4592c85d96..89b50efc630af05b4bed2fb41ab1369dfe06cc41 100644
|
| --- a/server/logdog/storage/bigtable/bigtable_test.go
|
| +++ b/server/logdog/storage/bigtable/bigtable_test.go
|
| @@ -6,15 +6,89 @@ package bigtable
|
|
|
| import (
|
| "testing"
|
| + "time"
|
|
|
| "github.com/luci/luci-go/common/errors"
|
| "github.com/luci/luci-go/common/grpcutil"
|
| + "github.com/luci/luci-go/server/logdog/storage"
|
| + "golang.org/x/net/context"
|
| + "google.golang.org/cloud/bigtable"
|
| +
|
| . "github.com/smartystreets/goconvey/convey"
|
| )
|
|
|
| func TestBigTable(t *testing.T) {
|
| t.Parallel()
|
|
|
| + Convey(`Testing BigTable internal functions`, t, func() {
|
| + var bt btTableTest
|
| + defer bt.close()
|
| +
|
| + s := newBTStorage(context.Background(), Options{
|
| + Project: "test-project",
|
| + Zone: "test-zone",
|
| + Cluster: "test-cluster",
|
| + LogTable: "test-log-table",
|
| + }, nil, nil)
|
| +
|
| + s.raw = &bt
|
| + defer s.Close()
|
| +
|
| + Convey(`Given a fake BigTable row`, func() {
|
| + fakeRow := bigtable.Row{
|
| + "log": []bigtable.ReadItem{
|
| + {
|
| + Row: "testrow",
|
| + Column: logColName,
|
| + Value: []byte("here is my data"),
|
| + },
|
| + },
|
| + }
|
| +
|
| + Convey(`Can extract log data.`, func() {
|
| + d, err := getLogRowData(fakeRow)
|
| + So(err, ShouldBeNil)
|
| + So(d, ShouldResemble, []byte("here is my data"))
|
| + })
|
| +
|
| + Convey(`Will fail to extract if the column is missing.`, func() {
|
| + fakeRow["log"][0].Column = "not-data"
|
| +
|
| + _, err := getLogRowData(fakeRow)
|
| + So(err, ShouldEqual, storage.ErrDoesNotExist)
|
| + })
|
| +
|
| + Convey(`Will fail to extract if the family does not exist.`, func() {
|
| + So(getReadItem(fakeRow, "invalid", "invalid"), ShouldBeNil)
|
| + })
|
| +
|
| + Convey(`Will fail to extract if the column does not exist.`, func() {
|
| + So(getReadItem(fakeRow, "log", "invalid"), ShouldBeNil)
|
| + })
|
| + })
|
| +
|
| + Convey(`When pushing a configuration`, func() {
|
| + cfg := storage.Config{
|
| + MaxLogAge: 1 * time.Hour,
|
| + }
|
| +
|
| + Convey(`Can successfully apply configuration.`, func() {
|
| + So(s.Config(cfg), ShouldBeNil)
|
| + So(bt.maxLogAge, ShouldEqual, cfg.MaxLogAge)
|
| + })
|
| +
|
| + Convey(`With return an error if the configuration fails to apply.`, func() {
|
| + bt.err = errors.New("test error")
|
| +
|
| + So(s.Config(cfg), ShouldEqual, bt.err)
|
| + })
|
| + })
|
| + })
|
| +}
|
| +
|
| +func TestBigTableErrors(t *testing.T) {
|
| + t.Parallel()
|
| +
|
| Convey(`A nil error is not marked transient.`, t, func() {
|
| So(wrapTransient(nil), ShouldBeNil)
|
| })
|
|
|