Skip to content

Remove tasks from post-test verifications. #8424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 35 additions & 17 deletions app/lib/tool/neat_task/pub_dev_tasks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:io';

import 'package:gcloud/service_scope.dart' as ss;
import 'package:logging/logging.dart';
import 'package:meta/meta.dart';
import 'package:neat_periodic_task/neat_periodic_task.dart';
import 'package:pub_dev/service/download_counts/computations.dart';

Expand Down Expand Up @@ -43,7 +44,9 @@ void setupPeriodTaskSchedulers() {
}

/// List of periodic task schedulers.
List<NeatPeriodicTaskScheduler> createPeriodicTaskSchedulers() {
List<NeatPeriodicTaskScheduler> createPeriodicTaskSchedulers({
@visibleForTesting bool isPostTestVerification = false,
}) {
return [
// Tries to send pending outgoing emails.
_15mins(
Expand Down Expand Up @@ -177,19 +180,30 @@ List<NeatPeriodicTaskScheduler> createPeriodicTaskSchedulers() {
),

// Delete very old instances that have been abandoned
_daily(
name: 'garbage-collect-old-instances',
isRuntimeVersioned: false,
task: () async => await deleteAbandonedInstances(
project: activeConfiguration.taskWorkerProject!,
//
// NOTE: This task will use Google Cloud API to remove worker instances.
// The client is not configured for fake environment, we should skip
// this task in post-test verifications.
// TODO: Write fake cloud abstractions to improve code coverage here.
if (!isPostTestVerification)
_daily(
name: 'garbage-collect-old-instances',
isRuntimeVersioned: false,
task: () async => await deleteAbandonedInstances(
project: activeConfiguration.taskWorkerProject!,
),
),
),

_daily(
name: 'sync-download-counts',
isRuntimeVersioned: false,
task: syncDownloadCounts,
),
// Syncs download counts from storage bucket.
//
// NOTE: This task reports missing files in the logs.
// TODO: Provide fake download data so that the task does not fail here.
if (!isPostTestVerification)
_daily(
name: 'sync-download-counts',
isRuntimeVersioned: false,
task: syncDownloadCounts,
),

_daily(
name: 'compute-download-counts-30-days-totals',
Expand All @@ -203,11 +217,15 @@ List<NeatPeriodicTaskScheduler> createPeriodicTaskSchedulers() {
task: countTopics,
),

_daily(
name: 'sync-security-advisories',
isRuntimeVersioned: false,
task: syncSecurityAdvisories,
),
// NOTE: This task will fetch the advisories from a public endpoint,
// running it on every test is not worth it.
// TODO: Consider injecting a fake data source for unit test.
if (!isPostTestVerification)
_daily(
name: 'sync-security-advisories',
isRuntimeVersioned: false,
task: syncSecurityAdvisories,
),

// Checks the Datastore integrity of the model objects.
_weekly(
Expand Down
3 changes: 2 additions & 1 deletion app/test/shared/test_services.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ Future<void> _postTestVerification({
}

// run all background tasks here
for (final scheduler in createPeriodicTaskSchedulers()) {
final schedulers = createPeriodicTaskSchedulers(isPostTestVerification: true);
for (final scheduler in schedulers) {
await scheduler.trigger();
}

Expand Down
Loading