2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-30 22:05:21 +00:00

Address requested changes

This commit is contained in:
Aravindh-Raju
2022-07-06 11:36:54 +05:30
parent 6ad28b46d4
commit 95bbbe43c9
3 changed files with 17 additions and 20 deletions

View File

@@ -33,7 +33,7 @@ import vinyldns.core.queue.MessageQueue
class BatchChangeConverter(batchChangeRepo: BatchChangeRepository, messageQueue: MessageQueue)
extends BatchChangeConverterAlgebra {
private val notExistCompletedMessage: String = " This record does not exist." +
private val notExistCompletedMessage: String = "This record does not exist." +
"No further action is required."
private val failedMessage: String = "Error queueing RecordSetChange for processing"
private val logger = LoggerFactory.getLogger(classOf[BatchChangeConverter])
@@ -70,21 +70,18 @@ class BatchChangeConverter(batchChangeRepo: BatchChangeRepository, messageQueue:
recordSetChanges: List[RecordSetChange]
): BatchResult[Unit] = {
val convertedIds = recordSetChanges.flatMap(_.singleBatchChangeIds).toSet
// Each single change has a corresponding recordset id
// If they're not equal, then there's a delete request for a record that doesn't exist. So we allow this to process
if(singleChanges.map(_.id).length != recordSetChanges.map(_.id).length && !singleChanges.map(_.typ).contains(UNKNOWN)) {
logger.info(s"Successfully converted SingleChanges [${singleChanges
.map(_.id)}] to RecordSetChanges [${recordSetChanges.map(_.id)}]")
().toRightBatchResult
}
else {
singleChanges.find(ch => !convertedIds.contains(ch.id)) match {
case Some(change) => BatchConversionError(change).toLeftBatchResult
case None =>
logger.info(s"Successfully converted SingleChanges [${singleChanges
.map(_.id)}] to RecordSetChanges [${recordSetChanges.map(_.id)}]")
().toRightBatchResult
}
singleChanges.find(ch => !convertedIds.contains(ch.id)) match {
// Each single change has a corresponding recordset id
// If they're not equal, then there's a delete request for a record that doesn't exist. So we allow this to process
case Some(_) if singleChanges.map(_.id).length != recordSetChanges.map(_.id).length && !singleChanges.map(_.typ).contains(UNKNOWN) =>
logger.info(s"Successfully converted SingleChanges [${singleChanges
.map(_.id)}] to RecordSetChanges [${recordSetChanges.map(_.id)}]")
().toRightBatchResult
case Some(change) => BatchConversionError(change).toLeftBatchResult
case None =>
logger.info(s"Successfully converted SingleChanges [${singleChanges
.map(_.id)}] to RecordSetChanges [${recordSetChanges.map(_.id)}]")
().toRightBatchResult
}
}

View File

@@ -3724,7 +3724,7 @@ def test_create_batch_with_zone_name_requiring_manual_review(shared_zone_test_co
def test_create_batch_delete_record_that_does_not_exists_completes(shared_zone_test_context):
"""
Test delete record set fails for non-existent record and non-existent record data
Test delete record set completes for non-existent record
"""
client = shared_zone_test_context.ok_vinyldns_client
ok_zone_name = shared_zone_test_context.ok_zone["name"]
@@ -3739,7 +3739,7 @@ def test_create_batch_delete_record_that_does_not_exists_completes(shared_zone_t
response = client.create_batch_change(batch_change_input, status=202)
get_batch = client.get_batch_change(response["id"])
assert_that(get_batch["changes"][0]["systemMessage"], is_(" This record does not exist." +
assert_that(get_batch["changes"][0]["systemMessage"], is_("This record does not exist." +
"No further action is required."))
assert_successful_change_in_error_response(response["changes"][0], input_name=f"delete-non-existent-record.{ok_zone_name}", record_data="1.1.1.1", change_type="DeleteRecordSet")

View File

@@ -37,7 +37,7 @@ import vinyldns.core.domain.record._
import vinyldns.core.domain.zone.Zone
class BatchChangeConverterSpec extends AnyWordSpec with Matchers with CatsHelpers {
private val notExistCompletedMessage: String = " This record does not exist." +
private val notExistCompletedMessage: String = "This record does not exist." +
"No further action is required."
private def makeSingleAddChange(
@@ -545,7 +545,7 @@ class BatchChangeConverterSpec extends AnyWordSpec with Matchers with CatsHelper
savedBatch shouldBe Some(returnedBatch)
}
"set status to complete when deleting a record that does not exists" in {
"set status to complete when deleting a record that does not exist" in {
val batchWithBadChange =
BatchChange(
okUser.id,