2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-31 06:15:49 +00:00

Adding scheduled time to all the things (#756)

Add scheduled time field to prepare for scheduled batch changes.

* `create_batch_change_test.py` - add a test that ensures posting and retrieving using the scheduled time field works as expected
* `BatchChangeProtocol.scala` - add scheduledTime field to `BatchChangeInput`
* `BatchChangeService.scala` - modify the `buildResonse` method, it does some logic to produce the resulting `BatchChange` entity, and we need to ensure that the `scheduledTime` field propagates through that logic
* `BatchChangeJsonProtocol.scala` - make sure that `BatchChangeInputSerializer` takes in `scheduledTime`, make sure that `BatchChangeSerializer` converts `scheduledTime` to json
* `BatchChange.scala` - add `scheduledTime` field
* `BatchChangeSummary.scala` - add `scheduledTime` field
* `V3.18__ScheduledChange.sql` - add a `scheduled_time` field to the `batch_change` table; add an index on `scheduled_time` as well to support querying by scheduled time
* `MySqlBatchChangeRepository` - make sure that save and get methods support `scheduledTime`
This commit is contained in:
Paul Cleary
2019-07-22 17:17:09 -04:00
committed by GitHub
parent 85af4f25eb
commit a520bcca4d
13 changed files with 275 additions and 99 deletions

View File

@@ -1,5 +1,6 @@
from hamcrest import *
from utils import *
import datetime
def does_not_contain(x):
is_not(contains(x))
@@ -269,6 +270,55 @@ def test_create_batch_change_with_adds_success(shared_zone_test_context):
clear_zoneid_rsid_tuple_list(to_delete, client)
def test_create_batch_change_with_scheduled_time_succeeds(shared_zone_test_context):
"""
Test successfully creating a batch change with scheduled time set
"""
client = shared_zone_test_context.ok_vinyldns_client
dt = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
batch_change_input = {
"comments": "this is optional",
"changes": [
get_change_A_AAAA_json("parent.com.", address="4.5.6.7"),
],
"scheduledTime": dt
}
to_delete = []
try:
result = client.create_batch_change(batch_change_input, status=202)
completed_batch = client.wait_until_batch_change_completed(result)
record_set_list = [(change['zoneId'], change['recordSetId']) for change in completed_batch['changes']]
to_delete = set(record_set_list)
assert_that(completed_batch['scheduledTime'], dt)
finally:
clear_zoneid_rsid_tuple_list(to_delete, client)
def test_create_batch_change_without_scheduled_time_succeeds(shared_zone_test_context):
"""
Test successfully creating a batch change without scheduled time set
"""
client = shared_zone_test_context.ok_vinyldns_client
batch_change_input = {
"comments": "this is optional",
"changes": [
get_change_A_AAAA_json("parent.com.", address="4.5.6.7"),
]
}
to_delete = []
try:
result = client.create_batch_change(batch_change_input, status=202)
completed_batch = client.wait_until_batch_change_completed(result)
record_set_list = [(change['zoneId'], change['recordSetId']) for change in completed_batch['changes']]
to_delete = set(record_set_list)
assert_that(completed_batch, is_not(has_key('scheduledTime')))
finally:
clear_zoneid_rsid_tuple_list(to_delete, client)
def test_create_batch_change_with_updates_deletes_success(shared_zone_test_context):
"""
Test successfully creating a batch change with updates and deletes