[gold] Delete unused tjstore and sqltjstore Go packages.
Change-Id: If348cf39cc61372bf960a3e4eb093d476ca618ba
Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/566096
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Kevin Lubick <kjlubick@google.com>
Auto-Submit: Leandro Lovisolo <lovisolo@google.com>
diff --git a/golden/go/tjstore/BUILD.bazel b/golden/go/tjstore/BUILD.bazel
deleted file mode 100644
index cdd14f0..0000000
--- a/golden/go/tjstore/BUILD.bazel
+++ /dev/null
@@ -1,24 +0,0 @@
-load("//bazel/go:go_test.bzl", "go_test")
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
- name = "tjstore",
- srcs = ["tjstore.go"],
- importpath = "go.skia.org/infra/golden/go/tjstore",
- visibility = ["//visibility:public"],
- deps = [
- "//go/paramtools",
- "//golden/go/continuous_integration",
- "//golden/go/types",
- ],
-)
-
-go_test(
- name = "tjstore_test",
- srcs = ["tjstore_test.go"],
- embed = [":tjstore"],
- deps = [
- "//go/testutils/unittest",
- "@com_github_stretchr_testify//assert",
- ],
-)
diff --git a/golden/go/tjstore/mocks/BUILD.bazel b/golden/go/tjstore/mocks/BUILD.bazel
deleted file mode 100644
index 674ad5d..0000000
--- a/golden/go/tjstore/mocks/BUILD.bazel
+++ /dev/null
@@ -1,16 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-
-go_library(
- name = "mocks",
- srcs = [
- "Store.go",
- "generate.go",
- ],
- importpath = "go.skia.org/infra/golden/go/tjstore/mocks",
- visibility = ["//visibility:public"],
- deps = [
- "//golden/go/continuous_integration",
- "//golden/go/tjstore",
- "@com_github_stretchr_testify//mock",
- ],
-)
diff --git a/golden/go/tjstore/mocks/Store.go b/golden/go/tjstore/mocks/Store.go
deleted file mode 100644
index 0b65c5c..0000000
--- a/golden/go/tjstore/mocks/Store.go
+++ /dev/null
@@ -1,97 +0,0 @@
-// Code generated by mockery v0.0.0-dev. DO NOT EDIT.
-
-package mocks
-
-import (
- context "context"
-
- mock "github.com/stretchr/testify/mock"
- continuous_integration "go.skia.org/infra/golden/go/continuous_integration"
-
- testing "testing"
-
- time "time"
-
- tjstore "go.skia.org/infra/golden/go/tjstore"
-)
-
-// Store is an autogenerated mock type for the Store type
-type Store struct {
- mock.Mock
-}
-
-// GetResults provides a mock function with given fields: ctx, psID, updatedAfter
-func (_m *Store) GetResults(ctx context.Context, psID tjstore.CombinedPSID, updatedAfter time.Time) ([]tjstore.TryJobResult, error) {
- ret := _m.Called(ctx, psID, updatedAfter)
-
- var r0 []tjstore.TryJobResult
- if rf, ok := ret.Get(0).(func(context.Context, tjstore.CombinedPSID, time.Time) []tjstore.TryJobResult); ok {
- r0 = rf(ctx, psID, updatedAfter)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]tjstore.TryJobResult)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, tjstore.CombinedPSID, time.Time) error); ok {
- r1 = rf(ctx, psID, updatedAfter)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// GetTryJob provides a mock function with given fields: ctx, id, cisName
-func (_m *Store) GetTryJob(ctx context.Context, id string, cisName string) (continuous_integration.TryJob, error) {
- ret := _m.Called(ctx, id, cisName)
-
- var r0 continuous_integration.TryJob
- if rf, ok := ret.Get(0).(func(context.Context, string, string) continuous_integration.TryJob); ok {
- r0 = rf(ctx, id, cisName)
- } else {
- r0 = ret.Get(0).(continuous_integration.TryJob)
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok {
- r1 = rf(ctx, id, cisName)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// GetTryJobs provides a mock function with given fields: ctx, psID
-func (_m *Store) GetTryJobs(ctx context.Context, psID tjstore.CombinedPSID) ([]continuous_integration.TryJob, error) {
- ret := _m.Called(ctx, psID)
-
- var r0 []continuous_integration.TryJob
- if rf, ok := ret.Get(0).(func(context.Context, tjstore.CombinedPSID) []continuous_integration.TryJob); ok {
- r0 = rf(ctx, psID)
- } else {
- if ret.Get(0) != nil {
- r0 = ret.Get(0).([]continuous_integration.TryJob)
- }
- }
-
- var r1 error
- if rf, ok := ret.Get(1).(func(context.Context, tjstore.CombinedPSID) error); ok {
- r1 = rf(ctx, psID)
- } else {
- r1 = ret.Error(1)
- }
-
- return r0, r1
-}
-
-// NewStore creates a new instance of Store. It also registers a cleanup function to assert the mocks expectations.
-func NewStore(t testing.TB) *Store {
- mock := &Store{}
-
- t.Cleanup(func() { mock.AssertExpectations(t) })
-
- return mock
-}
diff --git a/golden/go/tjstore/mocks/generate.go b/golden/go/tjstore/mocks/generate.go
deleted file mode 100644
index 37404f1..0000000
--- a/golden/go/tjstore/mocks/generate.go
+++ /dev/null
@@ -1,3 +0,0 @@
-package mocks
-
-//go:generate bazelisk run //:mockery -- --name Store --srcpkg=go.skia.org/infra/golden/go/tjstore --output ${PWD}
diff --git a/golden/go/tjstore/sqltjstore/BUILD.bazel b/golden/go/tjstore/sqltjstore/BUILD.bazel
deleted file mode 100644
index c10e62d..0000000
--- a/golden/go/tjstore/sqltjstore/BUILD.bazel
+++ /dev/null
@@ -1,38 +0,0 @@
-load("@io_bazel_rules_go//go:def.bzl", "go_library")
-load("//bazel/go:go_test.bzl", "go_test")
-
-go_library(
- name = "sqltjstore",
- srcs = ["sqltjstore.go"],
- importpath = "go.skia.org/infra/golden/go/tjstore/sqltjstore",
- visibility = ["//visibility:public"],
- deps = [
- "//go/skerr",
- "//golden/go/continuous_integration",
- "//golden/go/sql",
- "//golden/go/sql/schema",
- "//golden/go/tjstore",
- "//golden/go/types",
- "@com_github_jackc_pgtype//:pgtype",
- "@com_github_jackc_pgx_v4//:pgx",
- "@com_github_jackc_pgx_v4//pgxpool",
- "@io_opencensus_go//trace",
- ],
-)
-
-go_test(
- name = "sqltjstore_test",
- srcs = ["sqltjstore_test.go"],
- embed = [":sqltjstore"],
- deps = [
- "//go/paramtools",
- "//go/testutils/unittest",
- "//golden/go/continuous_integration",
- "//golden/go/sql/datakitchensink",
- "//golden/go/sql/sqltest",
- "//golden/go/tjstore",
- "//golden/go/types",
- "@com_github_stretchr_testify//assert",
- "@com_github_stretchr_testify//require",
- ],
-)
diff --git a/golden/go/tjstore/sqltjstore/sqltjstore.go b/golden/go/tjstore/sqltjstore/sqltjstore.go
deleted file mode 100644
index a35e10f..0000000
--- a/golden/go/tjstore/sqltjstore/sqltjstore.go
+++ /dev/null
@@ -1,145 +0,0 @@
-package sqltjstore
-
-import (
- "context"
- "encoding/hex"
- "strings"
- "time"
-
- "github.com/jackc/pgtype"
- "github.com/jackc/pgx/v4"
- "github.com/jackc/pgx/v4/pgxpool"
- "go.opencensus.io/trace"
-
- "go.skia.org/infra/go/skerr"
- ci "go.skia.org/infra/golden/go/continuous_integration"
- "go.skia.org/infra/golden/go/sql"
- "go.skia.org/infra/golden/go/sql/schema"
- "go.skia.org/infra/golden/go/tjstore"
- "go.skia.org/infra/golden/go/types"
-)
-
-type StoreImpl struct {
- db *pgxpool.Pool
-}
-
-// New returns a SQL-backed tjstore.Store.
-func New(db *pgxpool.Pool) *StoreImpl {
- return &StoreImpl{
- db: db,
- }
-}
-
-// GetTryJobs implements the tjstore.Store interface.
-func (s *StoreImpl) GetTryJobs(ctx context.Context, cID tjstore.CombinedPSID) ([]ci.TryJob, error) {
- clID := sql.Qualify(cID.CRS, cID.CL)
- psID := sql.Qualify(cID.CRS, cID.PS)
- rows, err := s.db.Query(ctx, `
-SELECT tryjob_id, system, display_name, last_ingested_data FROM Tryjobs
-WHERE changelist_id = $1 AND patchset_id = $2
-ORDER by display_name`, clID, psID)
- if err != nil {
- return nil, skerr.Wrapf(err, "fetching tryjobs for %#v", cID)
- }
- defer rows.Close()
- var rv []ci.TryJob
- for rows.Next() {
- var row schema.TryjobRow
- err := rows.Scan(&row.TryjobID, &row.System, &row.DisplayName, &row.LastIngestedData)
- if err != nil {
- return nil, skerr.Wrapf(err, "when fetching tryjobs for %#v", cID)
- }
- rv = append(rv, ci.TryJob{
- SystemID: sql.Unqualify(row.TryjobID),
- System: row.System,
- DisplayName: row.DisplayName,
- Updated: row.LastIngestedData.UTC(),
- })
- }
- return rv, nil
-}
-
-// GetTryJob implements the tjstore.Store interface.
-func (s *StoreImpl) GetTryJob(ctx context.Context, id, cisName string) (ci.TryJob, error) {
- qID := sql.Qualify(cisName, id)
- row := s.db.QueryRow(ctx, `
-SELECT display_name, last_ingested_data FROM Tryjobs WHERE tryjob_id = $1`, qID)
- var r schema.TryjobRow
- err := row.Scan(&r.DisplayName, &r.LastIngestedData)
- if err != nil {
- if err == pgx.ErrNoRows {
- return ci.TryJob{}, tjstore.ErrNotFound
- }
- return ci.TryJob{}, skerr.Wrapf(err, "querying for id %s", qID)
- }
- return ci.TryJob{
- SystemID: id,
- System: cisName,
- DisplayName: r.DisplayName,
- Updated: r.LastIngestedData.UTC(),
- }, nil
-}
-
-// A possible optimization for RAM usage / network would be to request the option ids only
-// and then run a followup request to fetch those and re-use the maps. This is the simplest
-// possible query that might work.
-const resultNoTime = `SELECT Traces.keys, digest, Options.keys, SecondaryBranchValues.tryjob_id FROM
-SecondaryBranchValues JOIN Traces
-ON SecondaryBranchValues.secondary_branch_trace_id = Traces.trace_id
-JOIN Options
-ON SecondaryBranchValues.options_id = Options.options_id
-WHERE branch_name = $1 AND version_name = $2`
-
-const resultWithTime = `
-SELECT Traces.keys, digest, Options.keys, SecondaryBranchValues.tryjob_id FROM
-SecondaryBranchValues JOIN Traces
-ON SecondaryBranchValues.secondary_branch_trace_id = Traces.trace_id
-JOIN Options
-ON SecondaryBranchValues.options_id = Options.options_id
-JOIN Tryjobs
-ON SecondaryBranchValues.tryjob_id = Tryjobs.tryjob_id
-WHERE branch_name = $1 AND version_name = $2 and last_ingested_data > $3`
-
-// GetResults implements the tjstore.Store interface. Of note, it always returns a nil GroupParams
-// because the way the data is stored, there is no way to know which params were ingested together.
-func (s *StoreImpl) GetResults(ctx context.Context, cID tjstore.CombinedPSID, updatedAfter time.Time) ([]tjstore.TryJobResult, error) {
- ctx, span := trace.StartSpan(ctx, "sqltjstore_GetResults")
- defer span.End()
- clID := sql.Qualify(cID.CRS, cID.CL)
- psID := sql.Qualify(cID.CRS, cID.PS)
-
- statement := resultNoTime
- arguments := []interface{}{clID, psID}
- if !updatedAfter.IsZero() {
- statement = resultWithTime
- arguments = append(arguments, updatedAfter)
- }
- rows, err := s.db.Query(ctx, statement, arguments...)
- if err != nil {
- return nil, skerr.Wrapf(err, "getting values for tryjobs on %#v", cID)
- }
- defer rows.Close()
- var rv []tjstore.TryJobResult
- for rows.Next() {
- var digestBytes schema.DigestBytes
- var result tjstore.TryJobResult
- var qualifiedTryjobID pgtype.Text
- err := rows.Scan(&result.ResultParams, &digestBytes, &result.Options, &qualifiedTryjobID)
- if err != nil {
- return nil, skerr.Wrapf(err, "scanning values for tryjobs %#v", cID)
- }
- result.Digest = types.Digest(hex.EncodeToString(digestBytes))
-
- if qualifiedTryjobID.Status == pgtype.Present {
- parts := strings.SplitN(qualifiedTryjobID.String, "_", 2)
- result.System = parts[0]
- result.TryjobID = parts[1]
- }
-
- rv = append(rv, result)
- }
- return rv, nil
-}
-
-// Make sure StoreImpl fulfills the tjstore.Store interface.
-var _ tjstore.Store = (*StoreImpl)(nil)
diff --git a/golden/go/tjstore/sqltjstore/sqltjstore_test.go b/golden/go/tjstore/sqltjstore/sqltjstore_test.go
deleted file mode 100644
index 16234de..0000000
--- a/golden/go/tjstore/sqltjstore/sqltjstore_test.go
+++ /dev/null
@@ -1,327 +0,0 @@
-package sqltjstore
-
-import (
- "context"
- "testing"
- "time"
-
- "github.com/stretchr/testify/assert"
- "github.com/stretchr/testify/require"
-
- "go.skia.org/infra/go/paramtools"
- "go.skia.org/infra/go/testutils/unittest"
- ci "go.skia.org/infra/golden/go/continuous_integration"
- "go.skia.org/infra/golden/go/sql/datakitchensink"
- "go.skia.org/infra/golden/go/sql/sqltest"
- "go.skia.org/infra/golden/go/tjstore"
- "go.skia.org/infra/golden/go/types"
-)
-
-func TestGetTryJob_Success(t *testing.T) {
- unittest.LargeTest(t)
-
- ctx := context.Background()
- db := sqltest.NewCockroachDBForTestsWithProductionSchema(ctx, t)
- require.NoError(t, sqltest.BulkInsertDataTables(ctx, db, datakitchensink.Build()))
-
- store := New(db)
-
- actual, err := store.GetTryJob(ctx, datakitchensink.Tryjob02IPad, datakitchensink.BuildBucketCIS)
- require.NoError(t, err)
- assert.Equal(t, ci.TryJob{
- SystemID: datakitchensink.Tryjob02IPad,
- System: datakitchensink.BuildBucketCIS,
- DisplayName: "Test-iPad-ALL",
- Updated: time.Date(2020, time.December, 10, 3, 2, 1, 0, time.UTC),
- }, actual)
-}
-
-func TestGetTryJobs_ValidID_Success(t *testing.T) {
- unittest.LargeTest(t)
-
- ctx := context.Background()
- db := sqltest.NewCockroachDBForTestsWithProductionSchema(ctx, t)
- require.NoError(t, sqltest.BulkInsertDataTables(ctx, db, datakitchensink.Build()))
- store := New(db)
-
- actual, err := store.GetTryJobs(ctx, tjstore.CombinedPSID{
- CL: datakitchensink.ChangelistIDThatAttemptsToFixIOS,
- CRS: datakitchensink.GerritCRS,
- PS: datakitchensink.PatchSetIDFixesIPadButNotIPhone,
- })
- require.NoError(t, err)
- // As per the Tryjob Store API, we sort them by display name
- assert.Equal(t, []ci.TryJob{{
- SystemID: datakitchensink.Tryjob02IPad,
- System: datakitchensink.BuildBucketCIS,
- DisplayName: "Test-iPad-ALL",
- Updated: datakitchensink.Tryjob02LastIngested,
- }, {
- SystemID: datakitchensink.Tryjob01IPhoneRGB,
- System: datakitchensink.BuildBucketCIS,
- DisplayName: "Test-iPhone-RGB",
- Updated: datakitchensink.Tryjob01LastIngested,
- }, {
- SystemID: datakitchensink.Tryjob03TaimenRGB,
- System: datakitchensink.BuildBucketCIS,
- DisplayName: "Test-taimen-RGB",
- Updated: datakitchensink.Tryjob03LastIngested,
- }}, actual)
-}
-
-func TestGetTryJobs_InvalidID_ReturnsNoResults(t *testing.T) {
- unittest.LargeTest(t)
-
- ctx := context.Background()
- db := sqltest.NewCockroachDBForTestsWithProductionSchema(ctx, t)
- require.NoError(t, sqltest.BulkInsertDataTables(ctx, db, datakitchensink.Build()))
- store := New(db)
-
- actual, err := store.GetTryJobs(ctx, tjstore.CombinedPSID{
- CL: datakitchensink.ChangelistIDThatAttemptsToFixIOS,
- CRS: datakitchensink.GerritCRS,
- PS: "Patchset does not exist",
- })
- require.NoError(t, err)
- assert.Empty(t, actual)
-}
-
-func TestGetResults_ValidID_Success(t *testing.T) {
- unittest.LargeTest(t)
-
- ctx := context.Background()
- db := sqltest.NewCockroachDBForTestsWithProductionSchema(ctx, t)
- require.NoError(t, sqltest.BulkInsertDataTables(ctx, db, datakitchensink.Build()))
- store := New(db)
-
- results, err := store.GetResults(ctx, tjstore.CombinedPSID{
- CL: datakitchensink.ChangelistIDThatAttemptsToFixIOS,
- CRS: datakitchensink.GerritCRS,
- PS: datakitchensink.PatchSetIDFixesIPadButNotIPhone,
- }, time.Time{})
- require.NoError(t, err)
-
- assert.ElementsMatch(t, []tjstore.TryJobResult{{
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob02IPad,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPadDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.SquareTest,
- datakitchensink.ColorModeKey: datakitchensink.GreyColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestA02Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob02IPad,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPadDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.TriangleTest,
- datakitchensink.ColorModeKey: datakitchensink.GreyColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestB02Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob02IPad,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPadDevice,
- types.CorpusField: datakitchensink.RoundCorpus,
- types.PrimaryKeyField: datakitchensink.CircleTest,
- datakitchensink.ColorModeKey: datakitchensink.GreyColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestC02Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob02IPad,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPadDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.SquareTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestA01Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob02IPad,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPadDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.TriangleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestB01Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob02IPad,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPadDevice,
- types.CorpusField: datakitchensink.RoundCorpus,
- types.PrimaryKeyField: datakitchensink.CircleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestC06Pos_CL,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob01IPhoneRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPhoneDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.SquareTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestA01Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob01IPhoneRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPhoneDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.TriangleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestB01Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob01IPhoneRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPhoneDevice,
- types.CorpusField: datakitchensink.RoundCorpus,
- types.PrimaryKeyField: datakitchensink.CircleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestC07Unt_CL,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob03TaimenRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.AndroidOS,
- datakitchensink.DeviceKey: datakitchensink.TaimenDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.SquareTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestA09Neg,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob03TaimenRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.AndroidOS,
- datakitchensink.DeviceKey: datakitchensink.TaimenDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.TriangleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestB01Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob03TaimenRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.AndroidOS,
- datakitchensink.DeviceKey: datakitchensink.TaimenDevice,
- types.CorpusField: datakitchensink.RoundCorpus,
- types.PrimaryKeyField: datakitchensink.CircleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestC05Unt,
- }}, results)
-}
-
-func TestGetResults_TimeIncludesOneTryjob_Success(t *testing.T) {
- unittest.LargeTest(t)
-
- ctx := context.Background()
- db := sqltest.NewCockroachDBForTestsWithProductionSchema(ctx, t)
- require.NoError(t, sqltest.BulkInsertDataTables(ctx, db, datakitchensink.Build()))
- store := New(db)
-
- // PatchSetIDFixesIPadButNotIPhone has data from 3 TryJobs. Of the three, the last one to be
- // ingested was Tryjob01, so we set the time cutoff before that to see that we only get the
- // results from that Tryjob (the iphone results)
- ts := datakitchensink.Tryjob01LastIngested.Add(-time.Second)
- results, err := store.GetResults(ctx, tjstore.CombinedPSID{
- CL: datakitchensink.ChangelistIDThatAttemptsToFixIOS,
- CRS: datakitchensink.GerritCRS,
- PS: datakitchensink.PatchSetIDFixesIPadButNotIPhone,
- }, ts)
- require.NoError(t, err)
-
- assert.ElementsMatch(t, []tjstore.TryJobResult{{
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob01IPhoneRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPhoneDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.SquareTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestA01Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob01IPhoneRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPhoneDevice,
- types.CorpusField: datakitchensink.CornersCorpus,
- types.PrimaryKeyField: datakitchensink.TriangleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestB01Pos,
- }, {
- System: datakitchensink.BuildBucketCIS,
- TryjobID: datakitchensink.Tryjob01IPhoneRGB,
- ResultParams: paramtools.Params{
- datakitchensink.OSKey: datakitchensink.IOS,
- datakitchensink.DeviceKey: datakitchensink.IPhoneDevice,
- types.CorpusField: datakitchensink.RoundCorpus,
- types.PrimaryKeyField: datakitchensink.CircleTest,
- datakitchensink.ColorModeKey: datakitchensink.RGBColorMode,
- },
- Options: paramtools.Params{"ext": "png"},
- Digest: datakitchensink.DigestC07Unt_CL,
- }}, results)
-}
-
-func TestGetResults_TimeIncludesNoTryjobs_ReturnsEmptyResults(t *testing.T) {
- unittest.LargeTest(t)
-
- ctx := context.Background()
- db := sqltest.NewCockroachDBForTestsWithProductionSchema(ctx, t)
- require.NoError(t, sqltest.BulkInsertDataTables(ctx, db, datakitchensink.Build()))
- store := New(db)
-
- // PatchSetIDFixesIPadButNotIPhone has data from 3 TryJobs. Of the three, the last one to be
- // ingested was Tryjob01, so if we put the time cutoff after this, there should be no data.
- ts := datakitchensink.Tryjob01LastIngested.Add(time.Second)
- results, err := store.GetResults(ctx, tjstore.CombinedPSID{
- CL: datakitchensink.ChangelistIDThatAttemptsToFixIOS,
- CRS: datakitchensink.GerritCRS,
- PS: datakitchensink.PatchSetIDFixesIPadButNotIPhone,
- }, ts)
- require.NoError(t, err)
- assert.Empty(t, results)
-}
diff --git a/golden/go/tjstore/tjstore.go b/golden/go/tjstore/tjstore.go
deleted file mode 100644
index 3abaf21..0000000
--- a/golden/go/tjstore/tjstore.go
+++ /dev/null
@@ -1,92 +0,0 @@
-// Package tjstore defines an interface for storing TryJob-related data
-// as needed for operating Gold.
-package tjstore
-
-import (
- "context"
- "errors"
- "fmt"
- "time"
-
- "go.skia.org/infra/go/paramtools"
- ci "go.skia.org/infra/golden/go/continuous_integration"
- "go.skia.org/infra/golden/go/types"
-)
-
-// Store (sometimes called TryJobStore) is an interface around a database
-// for storing TryJobs and TryJobResults. Of note, we will only store data for
-// TryJobs which uploaded data to Gold (e.g. via ingestion); the purpose of
-// this interface is not to store data about every TryJob.
-type Store interface {
- // GetTryJob returns the TryJob corresponding to the given id.
- // Returns NotFound if it doesn't exist.
- GetTryJob(ctx context.Context, id, cisName string) (ci.TryJob, error)
-
- // GetTryJobs returns all TryJobs associated with a given Changelist and Patchset.
- // The returned slice could be empty if the CL or PS don't exist.
- // TryJobs should be sorted by DisplayName.
- GetTryJobs(ctx context.Context, psID CombinedPSID) ([]ci.TryJob, error)
-
- // GetResults returns any TryJobResults for a given Changelist and Patchset.
- // The returned slice could be empty and is not sorted. If updatedAfter is not
- // a zero time, it will be used to return the subset of results created on or after
- // the given time.
- GetResults(ctx context.Context, psID CombinedPSID, updatedAfter time.Time) ([]TryJobResult, error)
-}
-
-var ErrNotFound = errors.New("not found")
-
-type TryJobResult struct {
- // GroupParams describe the general configuration that produced
- // the digest/image. This includes things like the model of device
- // that drew the image. GroupParams are likely to be shared among
- // many, if not all, the TryJobResults for a single TryJob, and
- // by making them a separate parameter, the map can be shared rather
- // than copied. Clients should treat this as read-only and not modify
- // it, as it could be shared by multiple different TryJobResults.
- GroupParams paramtools.Params
-
- // ResultParams describe the specialized configuration that
- // produced the digest/image. This includes the test name and corpus,
- // things that change for each result. This map is safe to be written
- // to by the client.
- // In the event of conflict, ResultParams should override Options which
- // override GroupParams.
- ResultParams paramtools.Params
-
- // Options give extra details about this result. This includes things
- // like the file format. Skia uses this for things like gamma_correctness.
- // Clients should treat this as read-only and not modify it, as it could
- // be shared by multiple different TryJobResults.
- Options paramtools.Params
-
- // Digest references the image that was generated by the test.
- Digest types.Digest
-
- // TryjobID represents the tryjob that produced this result.
- TryjobID string
- // System represents the CI System that the Tryjob belonged to.
- System string
-}
-
-// CombinedPSID represents an identifier that uniquely refers to a Patchset.
-type CombinedPSID struct {
- CL string
- CRS string
- PS string
-}
-
-// Key creates a probably unique id for a given
-// Patchset using the id of the Changelist it belongs to and the
-// ChangeReviewSystem it is a part of. We say "probably unique" because
-// a malicious person could try to control the clID and the psID to make
-// two different inputs make the same result, but that is unlikely for
-// ids that are valid (i.e. exist on a system like Gerrit).
-func (c CombinedPSID) Key() string {
- return fmt.Sprintf("%s__%s__%s", c.CL, c.CRS, c.PS)
-}
-
-// Equal returns true if the IDs are identical, false otherwise.
-func (c CombinedPSID) Equal(other CombinedPSID) bool {
- return c.CL == other.CL && c.PS == other.PS && c.CRS == other.CRS
-}
diff --git a/golden/go/tjstore/tjstore_test.go b/golden/go/tjstore/tjstore_test.go
deleted file mode 100644
index 96bacd1..0000000
--- a/golden/go/tjstore/tjstore_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package tjstore
-
-import (
- "testing"
-
- "github.com/stretchr/testify/assert"
- "go.skia.org/infra/go/testutils/unittest"
-)
-
-func TestCombinedPSID_Equal(t *testing.T) {
- unittest.SmallTest(t)
- assert.True(t, CombinedPSID{
- CL: "alpha",
- CRS: "beta",
- PS: "gamma",
- }.Equal(CombinedPSID{
- CL: "alpha",
- CRS: "beta",
- PS: "gamma",
- }))
-
- assert.False(t, CombinedPSID{
- CL: "alpha",
- CRS: "beta",
- PS: "alabama",
- }.Equal(CombinedPSID{
- CL: "alpha",
- CRS: "beta",
- PS: "gamma",
- }))
- assert.False(t, CombinedPSID{
- CL: "alpha",
- CRS: "beta",
- PS: "alabama",
- }.Equal(CombinedPSID{}))
-}