Skip to content

Commit

Permalink
Update tests and remove more gcs references
Browse files Browse the repository at this point in the history
  • Loading branch information
bsmartradio committed Dec 13, 2024
1 parent 97528a1 commit 78d751a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
8 changes: 4 additions & 4 deletions alertdb/bin/alertdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import uvicorn

from alertdb.server import create_server
from alertdb.storage import FileBackend, GoogleObjectStorageBackend
from alertdb.storage import FileBackend, USDFObjectStorageBackend

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -50,13 +50,13 @@ def main():
"--gcp-bucket-alerts",
type=str,
default="alert-packets",
help="when using the google-cloud backend, the name of the GCS bucket for alert packets",
help="when using the google-cloud backend, the name of the boto3 bucket for alert packets",
)
parser.add_argument(
"--gcp-bucket-schemas",
type=str,
default="alert-schemas",
help="when using the google-cloud backend, the name of the GCS bucket for alert schemas",
help="when using the google-cloud backend, the name of the boto3 bucket for alert schemas",
)
parser.add_argument("--verbose", action="store_true", help="log a bunch")
parser.add_argument("--debug", action="store_true", help="log even more")
Expand Down Expand Up @@ -99,7 +99,7 @@ def main():
logger.info("gcp_bucket_alerts: %s", args.gcp_bucket_alerts)
logger.info("gcp_bucket_schemas: %s", args.gcp_bucket_schemas)

backend = GoogleObjectStorageBackend(
backend = USDFObjectStorageBackend(
args.gcp_project, args.gcp_bucket_alerts, args.gcp_bucket_schemas
)

Expand Down
7 changes: 3 additions & 4 deletions alertdb/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import os.path

import boto3
import botocore
import google.api_core.exceptions
import google.cloud.storage as gcs

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -147,7 +144,9 @@ def __init__(
def get_alert(self, alert_id: str) -> bytes:
logger.info("retrieving alert id=%s", alert_id)
try:
alert_key = f"/alert_archive/v1/alerts/{alert_id}.avro.gz" # boto3 terminology for objects, objects live in prefixes inside of buckets
alert_key = f"/alert_archive/v1/alerts/{alert_id}.avro.gz"
# boto3 terminology for objects, objects live in prefixes inside
# of buckets
blob = self.object_store_client.get_object(
Bucket=self.packet_bucket, Key=alert_key
)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import os
import unittest

import google.cloud.storage as gcs
import boto3
import requests
from fastapi.testclient import TestClient

from alertdb.server import create_server
from alertdb.storage import GoogleObjectStorageBackend
from alertdb.storage import USDFObjectStorageBackend

logger = logging.getLogger(__name__)
logger.level = logging.DEBUG
Expand All @@ -29,7 +29,7 @@ def setUpClass(cls):
)
packet_bucket_name = "alertdb_server_integration_test_bucket_packets"
schema_bucket_name = "alertdb_server_integration_test_bucket_schemas"
client = gcs.Client(project=gcp_project)
client = boto3.client("s3", endpoint_url=gcp_project)

logger.info("creating bucket %s", packet_bucket_name)
packet_bucket = client.create_bucket(packet_bucket_name)
Expand Down Expand Up @@ -89,7 +89,7 @@ def setUp(self):
"""
Run a local instance of the server.
"""
backend = GoogleObjectStorageBackend(
backend = USDFObjectStorageBackend(
self.gcp_project, self.packet_bucket_name, self.schema_bucket_name
)
self.server = create_server(backend)
Expand Down

0 comments on commit 78d751a

Please sign in to comment.