-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(batch-exports): Do not allow backfills in the future (#24517)
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1d7949e
commit dcf38bb
Showing
4 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
import datetime as dt | ||
|
||
import pytest | ||
from django.test.client import Client as HttpClient | ||
from freezegun import freeze_time | ||
from rest_framework import status | ||
|
||
from posthog.api.test.batch_exports.conftest import start_test_worker | ||
|
@@ -97,6 +100,48 @@ def test_batch_export_backfill_with_non_isoformatted_dates(client: HttpClient): | |
assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json() | ||
|
||
|
||
def test_batch_export_backfill_with_end_at_in_the_future(client: HttpClient): | ||
"""Test a BatchExport backfill fails if we pass malformed dates.""" | ||
temporal = sync_connect() | ||
|
||
destination_data = { | ||
"type": "S3", | ||
"config": { | ||
"bucket_name": "my-production-s3-bucket", | ||
"region": "us-east-1", | ||
"prefix": "posthog-events/", | ||
"aws_access_key_id": "abc123", | ||
"aws_secret_access_key": "secret", | ||
}, | ||
} | ||
batch_export_data = { | ||
"name": "my-production-s3-bucket-destination", | ||
"destination": destination_data, | ||
"interval": "hour", | ||
} | ||
|
||
organization = create_organization("Test Org") | ||
team = create_team(organization) | ||
user = create_user("[email protected]", "Test User", organization) | ||
test_time = dt.datetime.now(dt.UTC) | ||
client.force_login(user) | ||
|
||
with start_test_worker(temporal): | ||
batch_export = create_batch_export_ok(client, team.pk, batch_export_data) | ||
|
||
batch_export_id = batch_export["id"] | ||
|
||
with freeze_time(test_time): | ||
response = backfill_batch_export( | ||
client, | ||
team.pk, | ||
batch_export_id, | ||
test_time.isoformat(), | ||
(test_time + dt.timedelta(hours=1, seconds=1)).isoformat(), | ||
) | ||
assert response.status_code == status.HTTP_400_BAD_REQUEST, response.json() | ||
|
||
|
||
def test_batch_export_backfill_with_naive_bounds(client: HttpClient): | ||
"""Test a BatchExport backfill fails if we naive dates.""" | ||
temporal = sync_connect() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters