Skip to content

Commit

Permalink
Build bucket v2 migration add v2 endpoints (Part 4) (flutter#3667)
Browse files Browse the repository at this point in the history
Adding updated v2 api endpoints. These endpoints will handle the new build bucket v2 api requests. Eventually we will remove the v1 api endpoints once they are no longer processing messages.

*List which issues are fixed by this PR. You must list at least one issue.*
Part 4 of flutter/flutter#135934

*If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].*
  • Loading branch information
ricardoamador authored Apr 23, 2024
1 parent 2eeeddd commit 7216730
Show file tree
Hide file tree
Showing 27 changed files with 3,433 additions and 285 deletions.
40 changes: 22 additions & 18 deletions app_dart/bin/gae_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import 'package:cocoon_service/cocoon_service.dart';
import 'package:cocoon_service/server.dart';
import 'package:cocoon_service/src/service/build_bucket_v2_client.dart';
import 'package:cocoon_service/src/service/commit_service.dart';
// import 'package:cocoon_service/src/service/github_checks_service_v2.dart';
// import 'package:cocoon_service/src/service/luci_build_service_v2.dart';
// import 'package:cocoon_service/src/service/scheduler_v2.dart';
import 'package:cocoon_service/src/service/github_checks_service_v2.dart';
import 'package:cocoon_service/src/service/luci_build_service_v2.dart';
import 'package:cocoon_service/src/service/scheduler_v2.dart';
import 'package:gcloud/db.dart';

Future<void> main() async {
Expand Down Expand Up @@ -40,21 +40,21 @@ Future<void> main() async {
pubsub: const PubSub(),
);

// final LuciBuildServiceV2 luciBuildServiceV2 = LuciBuildServiceV2(
// config: config,
// cache: cache,
// buildBucketV2Client: buildBucketV2Client,
// pubsub: const PubSub(),
// );
final LuciBuildServiceV2 luciBuildServiceV2 = LuciBuildServiceV2(
config: config,
cache: cache,
buildBucketV2Client: buildBucketV2Client,
pubsub: const PubSub(),
);

/// Github checks api service used to provide luci test execution status on the Github UI.
final GithubChecksService githubChecksService = GithubChecksService(
config,
);

// final GithubChecksServiceV2 githubChecksServiceV2 = GithubChecksServiceV2(
// config,
// );
final GithubChecksServiceV2 githubChecksServiceV2 = GithubChecksServiceV2(
config,
);

// Gerrit service class to communicate with GoB.
final GerritService gerritService = GerritService(config: config);
Expand All @@ -67,12 +67,12 @@ Future<void> main() async {
luciBuildService: luciBuildService,
);

// final SchedulerV2 schedulerV2 = SchedulerV2(
// cache: cache,
// config: config,
// githubChecksService: githubChecksServiceV2,
// luciBuildService: luciBuildServiceV2,
// );
final SchedulerV2 schedulerV2 = SchedulerV2(
cache: cache,
config: config,
githubChecksService: githubChecksServiceV2,
luciBuildService: luciBuildServiceV2,
);

final BranchService branchService = BranchService(
config: config,
Expand All @@ -87,10 +87,14 @@ Future<void> main() async {
authProvider: authProvider,
branchService: branchService,
buildBucketClient: buildBucketClient,
buildBucketV2Client: buildBucketV2Client,
gerritService: gerritService,
scheduler: scheduler,
schedulerV2: schedulerV2,
luciBuildService: luciBuildService,
luciBuildServiceV2: luciBuildServiceV2,
githubChecksService: githubChecksService,
githubChecksServiceV2: githubChecksServiceV2,
commitService: commitService,
swarmingAuthProvider: swarmingAuthProvider,
);
Expand Down
40 changes: 22 additions & 18 deletions app_dart/bin/local_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import 'package:cocoon_service/src/model/appengine/cocoon_config.dart';
import 'package:cocoon_service/src/service/build_bucket_v2_client.dart';
import 'package:cocoon_service/src/service/commit_service.dart';
import 'package:cocoon_service/src/service/datastore.dart';
// import 'package:cocoon_service/src/service/github_checks_service_v2.dart';
// import 'package:cocoon_service/src/service/luci_build_service_v2.dart';
// import 'package:cocoon_service/src/service/scheduler_v2.dart';
import 'package:cocoon_service/src/service/github_checks_service_v2.dart';
import 'package:cocoon_service/src/service/luci_build_service_v2.dart';
import 'package:cocoon_service/src/service/scheduler_v2.dart';
import 'package:gcloud/db.dart';

import '../test/src/datastore/fake_datastore.dart';
Expand Down Expand Up @@ -47,21 +47,21 @@ Future<void> main() async {
pubsub: const PubSub(),
);

// final LuciBuildServiceV2 luciBuildServiceV2 = LuciBuildServiceV2(
// config: config,
// cache: cache,
// buildBucketV2Client: buildBucketV2Client,
// pubsub: const PubSub(),
// );
final LuciBuildServiceV2 luciBuildServiceV2 = LuciBuildServiceV2(
config: config,
cache: cache,
buildBucketV2Client: buildBucketV2Client,
pubsub: const PubSub(),
);

/// Github checks api service used to provide luci test execution status on the Github UI.
final GithubChecksService githubChecksService = GithubChecksService(
config,
);

// final GithubChecksServiceV2 githubChecksServiceV2 = GithubChecksServiceV2(
// config,
// );
final GithubChecksServiceV2 githubChecksServiceV2 = GithubChecksServiceV2(
config,
);

// Gerrit service class to communicate with GoB.
final GerritService gerritService = GerritService(config: config);
Expand All @@ -74,12 +74,12 @@ Future<void> main() async {
luciBuildService: luciBuildService,
);

// final SchedulerV2 schedulerV2 = SchedulerV2(
// cache: cache,
// config: config,
// githubChecksService: githubChecksServiceV2,
// luciBuildService: luciBuildServiceV2,
// );
final SchedulerV2 schedulerV2 = SchedulerV2(
cache: cache,
config: config,
githubChecksService: githubChecksServiceV2,
luciBuildService: luciBuildServiceV2,
);

final BranchService branchService = BranchService(
config: config,
Expand All @@ -94,10 +94,14 @@ Future<void> main() async {
authProvider: authProvider,
branchService: branchService,
buildBucketClient: buildBucketClient,
buildBucketV2Client: buildBucketV2Client,
gerritService: gerritService,
scheduler: scheduler,
schedulerV2: schedulerV2,
luciBuildService: luciBuildService,
luciBuildServiceV2: luciBuildServiceV2,
githubChecksService: githubChecksService,
githubChecksServiceV2: githubChecksServiceV2,
commitService: commitService,
swarmingAuthProvider: swarmingAuthProvider,
);
Expand Down
59 changes: 56 additions & 3 deletions app_dart/lib/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ import 'dart:io';
import 'dart:math';

import 'package:cocoon_service/cocoon_service.dart';
import 'package:cocoon_service/src/request_handlers/postsubmit_luci_subscription_v2.dart';
import 'package:cocoon_service/src/request_handlers/presubmit_luci_subscription_v2.dart';
import 'package:cocoon_service/src/request_handlers/reset_prod_task_v2.dart';
import 'package:cocoon_service/src/request_handlers/reset_try_task_v2.dart';
import 'package:cocoon_service/src/request_handlers/scheduler/batch_backfiller_v2.dart';
import 'package:cocoon_service/src/request_handlers/scheduler/scheduler_request_subscription.dart';
import 'package:cocoon_service/src/request_handlers/vacuum_github_commits_v2.dart';
import 'package:cocoon_service/src/service/build_bucket_v2_client.dart';
import 'package:cocoon_service/src/service/commit_service.dart';
import 'package:cocoon_service/src/service/github_checks_service_v2.dart';
import 'package:cocoon_service/src/service/luci_build_service_v2.dart';
import 'package:cocoon_service/src/service/scheduler_v2.dart';

typedef Server = Future<void> Function(HttpRequest);

Expand All @@ -18,11 +29,15 @@ Server createServer({
required AuthenticationProvider swarmingAuthProvider,
required BranchService branchService,
required BuildBucketClient buildBucketClient,
required BuildBucketV2Client buildBucketV2Client,
required LuciBuildService luciBuildService,
required LuciBuildServiceV2 luciBuildServiceV2,
required GithubChecksService githubChecksService,
required GithubChecksServiceV2 githubChecksServiceV2,
required CommitService commitService,
required GerritService gerritService,
required Scheduler scheduler,
required SchedulerV2 schedulerV2,
}) {
final Map<String, RequestHandler<dynamic>> handlers = <String, RequestHandler<dynamic>>{
'/api/check_flaky_builders': CheckFlakyBuilders(
Expand All @@ -37,7 +52,7 @@ Server createServer({
'/api/dart-internal-subscription': DartInternalSubscription(
cache: cache,
config: config,
buildBucketClient: buildBucketClient,
buildBucketV2Client: buildBucketV2Client,
),
'/api/file_flaky_issue_and_pr': FileFlakyIssueAndPR(
config: config,
Expand Down Expand Up @@ -65,24 +80,36 @@ Server createServer({
config: config,
cache: cache,
gerritService: gerritService,
githubChecksService: githubChecksService,
scheduler: scheduler,
schedulerV2: schedulerV2,
commitService: commitService,
),
'/api/presubmit-luci-subscription': PresubmitLuciSubscription(
cache: cache,
config: config,
buildBucketClient: buildBucketClient,
luciBuildService: luciBuildService,
githubChecksService: githubChecksService,
scheduler: scheduler,
),
'/api/v2/presubmit-luci-subscription': PresubmitLuciSubscriptionV2(
cache: cache,
config: config,
luciBuildService: luciBuildServiceV2,
githubChecksService: githubChecksServiceV2,
scheduler: schedulerV2,
),
'/api/postsubmit-luci-subscription': PostsubmitLuciSubscription(
cache: cache,
config: config,
scheduler: scheduler,
githubChecksService: githubChecksService,
),
'/api/v2/postsubmit-luci-subscription': PostsubmitLuciSubscriptionV2(
cache: cache,
config: config,
scheduler: schedulerV2,
githubChecksService: githubChecksServiceV2,
),
'/api/push-build-status-to-github': PushBuildStatusToGithub(
config: config,
authenticationProvider: authProvider,
Expand All @@ -91,26 +118,47 @@ Server createServer({
config: config,
authenticationProvider: authProvider,
),
// I do not believe these recieve a build message.
'/api/reset-prod-task': ResetProdTask(
config: config,
authenticationProvider: authProvider,
luciBuildService: luciBuildService,
scheduler: scheduler,
),
'/api/v2/reset-prod-task': ResetProdTaskV2(
config: config,
authenticationProvider: authProvider,
luciBuildService: luciBuildServiceV2,
scheduler: schedulerV2,
),
'/api/reset-try-task': ResetTryTask(
config: config,
authenticationProvider: authProvider,
scheduler: scheduler,
),
'/api/v2/reset-try-task': ResetTryTaskV2(
config: config,
authenticationProvider: authProvider,
scheduler: schedulerV2,
),
'/api/scheduler/batch-backfiller': BatchBackfiller(
config: config,
scheduler: scheduler,
),
'/api/v2/scheduler/batch-backfiller': BatchBackfillerV2(
config: config,
scheduler: schedulerV2,
),
'/api/scheduler/batch-request-subscription': SchedulerRequestSubscription(
cache: cache,
config: config,
buildBucketClient: buildBucketClient,
),
'/api/v2/scheduler/batch-request-subscription': SchedulerRequestSubscriptionV2(
cache: cache,
config: config,
buildBucketClient: buildBucketV2Client,
),
'/api/scheduler/vacuum-stale-tasks': VacuumStaleTasks(
config: config,
),
Expand Down Expand Up @@ -144,6 +192,11 @@ Server createServer({
authenticationProvider: authProvider,
scheduler: scheduler,
),
'/api/v2/vacuum-github-commits': VacuumGithubCommitsV2(
config: config,
authenticationProvider: authProvider,
scheduler: schedulerV2,
),

/// Returns status of the framework tree.
///
Expand Down
Loading

0 comments on commit 7216730

Please sign in to comment.