diff --git a/BUILD.bazel b/BUILD.bazel index ffc52a32..ca41deec 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,4 +1,10 @@ load("@gazelle//:def.bzl", "gazelle") # gazelle:prefix github.com/uber/submitqueue + +# Resolve protobuf import ambiguities - use the actual protopb packages, not the proto aliases +# gazelle:resolve go github.com/uber/submitqueue/gateway/protopb //gateway/protopb +# gazelle:resolve go github.com/uber/submitqueue/orchestrator/protopb //orchestrator/protopb +# gazelle:resolve go github.com/uber/submitqueue/speculator/protopb //speculator/protopb + gazelle(name = "gazelle") diff --git a/Makefile b/Makefile index eb04cf6f..e625d90b 100644 --- a/Makefile +++ b/Makefile @@ -53,20 +53,20 @@ gazelle: # Run integration tests for a specific service (requires that service to be running) integration-test-gateway: @echo "Running Gateway integration tests..." - @$(BAZEL) test //gateway/integration_tests:integration_test --test_output=all + @$(BAZEL) test //gateway/integration_tests:integration_tests_test --test_output=all integration-test-orchestrator: @echo "Running Orchestrator integration tests..." - @$(BAZEL) test //orchestrator/integration_tests:integration_test --test_output=all + @$(BAZEL) test //orchestrator/integration_tests:integration_tests_test --test_output=all integration-test-speculator: @echo "Running Speculator integration tests..." - @$(BAZEL) test //speculator/integration_tests:integration_test --test_output=all + @$(BAZEL) test //speculator/integration_tests:integration_tests_test --test_output=all # Run all service integration tests (requires all services to be running) integration-test: @echo "Running all service integration tests..." - @$(BAZEL) test //gateway/integration_tests:integration_test //orchestrator/integration_tests:integration_test //speculator/integration_tests:integration_test --test_output=all + @$(BAZEL) test //gateway/integration_tests:integration_tests_test //orchestrator/integration_tests:integration_tests_test //speculator/integration_tests:integration_tests_test --test_output=all # Run end-to-end tests (requires all services to be running) e2e-test: diff --git a/entities/storage/BUILD.bazel b/entities/storage/BUILD.bazel new file mode 100644 index 00000000..73a70e03 --- /dev/null +++ b/entities/storage/BUILD.bazel @@ -0,0 +1,8 @@ +load("@rules_go//go:def.bzl", "go_library") + +go_library( + name = "storage", + srcs = ["land_request.go"], + importpath = "github.com/uber/submitqueue/entities/storage", + visibility = ["//visibility:public"], +) diff --git a/entities/storage/land_request.go b/entities/storage/land_request.go new file mode 100644 index 00000000..25afca6b --- /dev/null +++ b/entities/storage/land_request.go @@ -0,0 +1,5 @@ +package storage + +// LandRequest TODO: implement land request for storage +type LandRequest struct { +} diff --git a/extensions/storage/BUILD.bazel b/extensions/storage/BUILD.bazel new file mode 100644 index 00000000..675728c9 --- /dev/null +++ b/extensions/storage/BUILD.bazel @@ -0,0 +1,12 @@ +load("@rules_go//go:def.bzl", "go_library") + +go_library( + name = "storage", + srcs = [ + "factory.go", + "request_store.go", + ], + importpath = "github.com/uber/submitqueue/extensions/storage", + visibility = ["//visibility:public"], + deps = ["//entities/storage"], +) diff --git a/extensions/storage/factory.go b/extensions/storage/factory.go new file mode 100644 index 00000000..450a9d90 --- /dev/null +++ b/extensions/storage/factory.go @@ -0,0 +1,6 @@ +package storage + +// Factory is an interface that defines methods for creating different stores. +type Factory interface { + RequestStore() RequestStore +} diff --git a/extensions/storage/mysql/BUILD.bazel b/extensions/storage/mysql/BUILD.bazel new file mode 100644 index 00000000..c2a8e1f2 --- /dev/null +++ b/extensions/storage/mysql/BUILD.bazel @@ -0,0 +1,15 @@ +load("@rules_go//go:def.bzl", "go_library") + +go_library( + name = "mysql", + srcs = [ + "factory.go", + "request_store.go", + ], + importpath = "github.com/uber/submitqueue/extensions/storage/mysql", + visibility = ["//visibility:public"], + deps = [ + "//entities/storage", + "//extensions/storage", + ], +) diff --git a/extensions/storage/mysql/factory.go b/extensions/storage/mysql/factory.go new file mode 100644 index 00000000..1e7c47df --- /dev/null +++ b/extensions/storage/mysql/factory.go @@ -0,0 +1,23 @@ +package mysql + +import "github.com/uber/submitqueue/extensions/storage" + +type factory struct { + requestStore storage.RequestStore +} + +type FactoryParams struct { + requestStore storage.RequestStore +} + +// NewFactory creates a new MySQL storage factory +func NewFactory(p FactoryParams) (storage.Factory, error) { + return &factory{ + requestStore: p.requestStore, + }, nil +} + +// RequestStore returns the MySQL-backed RequestStore +func (f *factory) RequestStore() storage.RequestStore { + return f.requestStore +} diff --git a/extensions/storage/mysql/request_store.go b/extensions/storage/mysql/request_store.go new file mode 100644 index 00000000..7aab1edb --- /dev/null +++ b/extensions/storage/mysql/request_store.go @@ -0,0 +1,24 @@ +package mysql + +import ( + "context" + + entities "github.com/uber/submitqueue/entities/storage" + "github.com/uber/submitqueue/extensions/storage" +) + +type requestStore struct { +} + +type RequestParam struct { +} + +func NewRequestStore() storage.RequestStore { + return &requestStore{} +} + +// Get retrieves a land request by ID +func (r *requestStore) Get(ctx context.Context, id string) (*entities.LandRequest, error) { + // TODO: implement GET operation + panic("not implemented") +} diff --git a/extensions/storage/request_store.go b/extensions/storage/request_store.go new file mode 100644 index 00000000..70da603a --- /dev/null +++ b/extensions/storage/request_store.go @@ -0,0 +1,13 @@ +package storage + +import ( + "context" + + "github.com/uber/submitqueue/entities/storage" +) + +// RequestStore is an interface that defines methods for managing storage requests. +type RequestStore interface { + // Get retrieves a land request by ID + Get(ctx context.Context, id string) (*storage.LandRequest, error) +} diff --git a/gateway/controller/BUILD.bazel b/gateway/controller/BUILD.bazel index 32059a6f..c1b6a0b2 100644 --- a/gateway/controller/BUILD.bazel +++ b/gateway/controller/BUILD.bazel @@ -16,7 +16,5 @@ go_test( name = "controller_test", srcs = ["ping_test.go"], embed = [":controller"], - deps = [ - "//gateway/protopb", - ], + deps = ["//gateway/protopb"], ) diff --git a/gateway/integration_tests/BUILD.bazel b/gateway/integration_tests/BUILD.bazel index 10df327e..af1a53d6 100644 --- a/gateway/integration_tests/BUILD.bazel +++ b/gateway/integration_tests/BUILD.bazel @@ -1,7 +1,9 @@ +# gazelle:ignore + load("@rules_go//go:def.bzl", "go_test") go_test( - name = "integration_test", + name = "integration_tests_test", srcs = ["ping_test.go"], tags = [ "integration", diff --git a/integration_tests/BUILD.bazel b/integration_tests/BUILD.bazel index a27b7525..323e1053 100644 --- a/integration_tests/BUILD.bazel +++ b/integration_tests/BUILD.bazel @@ -1,3 +1,5 @@ +# gazelle:ignore + load("@rules_go//go:def.bzl", "go_test") go_test( diff --git a/integration_tests/README.md b/integration_tests/README.md index 4d716f92..1a35077f 100644 --- a/integration_tests/README.md +++ b/integration_tests/README.md @@ -44,12 +44,12 @@ make integration-test # All services ./tools/bazel test //integration_tests:e2e_test --test_output=all # Run individual service integration tests -./tools/bazel test //gateway:integration_test --test_output=all -./tools/bazel test //orchestrator:integration_test --test_output=all -./tools/bazel test //speculator:integration_test --test_output=all +./tools/bazel test //gateway/integration_tests:integration_tests_test --test_output=all +./tools/bazel test //orchestrator/integration_tests:integration_tests_test --test_output=all +./tools/bazel test //speculator/integration_tests:integration_tests_test --test_output=all # Run all service integration tests -./tools/bazel test //gateway:integration_test //orchestrator:integration_test //speculator:integration_test --test_output=all +./tools/bazel test //gateway/integration_tests:integration_tests_test //orchestrator/integration_tests:integration_tests_test //speculator/integration_tests:integration_tests_test --test_output=all # The tests are tagged as 'manual' so they won't run with 'bazel test //...' # This is intentional since they require servers to be running @@ -104,11 +104,11 @@ func TestNewMethod(t *testing.T) { 1. Create `newservice/integration_tests/` folder 2. Add test files like `newservice/integration_tests/ping_test.go` -3. Add `go_test` rule to `newservice/BUILD.bazel`: +3. Add `go_test` rule to `newservice/integration_tests/BUILD.bazel`: ```python go_test( - name = "integration_test", - srcs = ["integration_tests/ping_test.go"], + name = "integration_tests_test", + srcs = ["ping_test.go"], deps = [ "//newservice/protopb", "@org_golang_google_grpc//:grpc", diff --git a/orchestrator/controller/BUILD.bazel b/orchestrator/controller/BUILD.bazel index 27e47fb6..3b8e495a 100644 --- a/orchestrator/controller/BUILD.bazel +++ b/orchestrator/controller/BUILD.bazel @@ -16,7 +16,5 @@ go_test( name = "controller_test", srcs = ["ping_test.go"], embed = [":controller"], - deps = [ - "//orchestrator/protopb", - ], + deps = ["//orchestrator/protopb"], ) diff --git a/orchestrator/integration_tests/BUILD.bazel b/orchestrator/integration_tests/BUILD.bazel index 72eb8910..84a71b3f 100644 --- a/orchestrator/integration_tests/BUILD.bazel +++ b/orchestrator/integration_tests/BUILD.bazel @@ -1,7 +1,9 @@ +# gazelle:ignore + load("@rules_go//go:def.bzl", "go_test") go_test( - name = "integration_test", + name = "integration_tests_test", srcs = ["ping_test.go"], tags = [ "integration", diff --git a/speculator/controller/BUILD.bazel b/speculator/controller/BUILD.bazel index c2e0e45f..dfd8fa81 100644 --- a/speculator/controller/BUILD.bazel +++ b/speculator/controller/BUILD.bazel @@ -16,7 +16,5 @@ go_test( name = "controller_test", srcs = ["ping_test.go"], embed = [":controller"], - deps = [ - "//speculator/protopb", - ], + deps = ["//speculator/protopb"], ) diff --git a/speculator/integration_tests/BUILD.bazel b/speculator/integration_tests/BUILD.bazel index 5a188d51..7fbe31ab 100644 --- a/speculator/integration_tests/BUILD.bazel +++ b/speculator/integration_tests/BUILD.bazel @@ -1,7 +1,9 @@ +# gazelle:ignore + load("@rules_go//go:def.bzl", "go_test") go_test( - name = "integration_test", + name = "integration_tests_test", srcs = ["ping_test.go"], tags = [ "integration",