Use these commands to verify everything is working correctly:
gcloud run services describe agent4good --region us-central1 --format="value(status.url,status.conditions)"Expected: Service URL and status "Ready"
gcloud run services describe bigquery-worker --region us-central1 --format="value(status.url,status.conditions)"Expected: Service URL and status "Ready"
gcloud run services describe agent4good --region us-central1 --format="value(spec.template.spec.containers[0].env)" | findstr USE_PUBSUBExpected: 'name': 'USE_PUBSUB', 'value': 'true'
gcloud run services describe bigquery-worker --region us-central1 --format="value(spec.template.spec.containers[0].env)"Expected: GOOGLE_CLOUD_PROJECT, SUBSCRIPTION_NAME, BIGQUERY_DATASET, BIGQUERY_TABLE_REPORTS
curl https://bigquery-worker-776464277441.us-central1.run.app/healthExpected: {"status":"healthy","messages_processed":N}
gcloud logging read "resource.type=cloud_run_revision AND resource.labels.service_name=bigquery-worker" --limit 10 --format="table(timestamp,textPayload)"Expected: Logs showing worker is listening and processing messages
gcloud pubsub topics describe community-reports-submittedExpected: Topic details without errors
gcloud pubsub subscriptions describe bigquery-writer-subExpected: Subscription details, connected to topic
gcloud projects get-iam-policy qwiklabs-gcp-00-4a7d408c735c --flatten="bindings[].members" --filter="bindings.members:776464277441-compute@developer.gserviceaccount.com" --format="table(bindings.role)"Expected: Should include:
roles/pubsub.publisherroles/pubsub.subscriberroles/bigquery.dataEditor
Create a test script:
# test_e2e.py
from google.cloud import pubsub_v1
import json
PROJECT_ID = "qwiklabs-gcp-00-4a7d408c735c"
TOPIC_NAME = "community-reports-submitted"
test_data = {
"report_id": f"verify-{int(time.time())}",
"report_type": "Air Quality",
"timestamp": "2025-11-09T12:00:00Z",
"city": "San Francisco",
"state": "CA",
"severity": "Low",
"description": "Verification test",
"is_anonymous": False,
"media_count": 0,
"status": "pending"
}
publisher = pubsub_v1.PublisherClient()
topic_path = publisher.topic_path(PROJECT_ID, TOPIC_NAME)
future = publisher.publish(topic_path, json.dumps(test_data).encode('utf-8'))
print(f"Published: {future.result()}")Then check logs:
gcloud logging read "resource.type=cloud_run_revision AND resource.labels.service_name=bigquery-worker AND textPayload:verify-" --limit 5In Cloud Console:
- Go to BigQuery
- Navigate to
qwiklabs-gcp-00-4a7d408c735c.CrowdsourceData.CrowdSourceData - Run query:
SELECT report_id, timestamp, city, state, description
FROM `qwiklabs-gcp-00-4a7d408c735c.CrowdsourceData.CrowdSourceData`
WHERE report_id LIKE 'test-pubsub%'
ORDER BY timestamp DESC
LIMIT 5Expected: Should see test-pubsub-002 (and test-pubsub-001 if retried)
gcloud run services update agent4good --region us-central1 --update-env-vars="USE_PUBSUB=false"gcloud run services update bigquery-worker --region us-central1 --min-instances=0 --max-instances=0gcloud run services update bigquery-worker --region us-central1 --min-instances=1 --max-instances=10- Cloud Run Services: https://console.cloud.google.com/run?project=qwiklabs-gcp-00-4a7d408c735c
- Pub/Sub Topics: https://console.cloud.google.com/cloudpubsub/topic/list?project=qwiklabs-gcp-00-4a7d408c735c
- BigQuery: https://console.cloud.google.com/bigquery?project=qwiklabs-gcp-00-4a7d408c735c
- Logs Explorer: https://console.cloud.google.com/logs/query?project=qwiklabs-gcp-00-4a7d408c735c
All checks should pass:
- Main service is running with USE_PUBSUB=true
- Worker is healthy and listening
- Pub/Sub topic and subscription exist
- IAM permissions are correct
- Test message was processed successfully
- Data appears in BigQuery
- No errors in logs
If all criteria pass, the integration is working correctly! ✅