Skip to content

Commit

Permalink
Merge pull request #16231 from CDCgov/deployment/2024-10-15
Browse files Browse the repository at this point in the history
Deployment of 2024-10-15
  • Loading branch information
oslynn authored Oct 15, 2024
2 parents 43659d8 + 031c752 commit ac069f6
Show file tree
Hide file tree
Showing 14 changed files with 418 additions and 81 deletions.
69 changes: 69 additions & 0 deletions .github/ISSUE_TEMPLATE/DevSecOps-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
name: DevSecOps ticket
about: For new DevSecOps tickets on the board.
labels: ['DevSecOps', 'reportstream']
---
# DevSecOps Issue

## Summary

Context and description

## Environment

- [ ] Local
- [ ] Dev
- [ ] Stage
- [ ] Prod

## Priority

- [ ] **Critical** - affecting prod systems
- [ ] **Major** - blocking major functionality, deployment, etc
- [ ] **Minor** - improvements, bug fixes
- [ ] **Nice-to-have** - feature request

### Blocks the following

- List any blockers
- Link any Github relevant issues

### Blocked by the following

- Link to any tickets that add context, etc

## Contact

**Team**:

**Slack Team Channel**:

**Slack Contact (Full Name):**

**Technical Team Lead:**

## How to Reproduce

### Screenshots, links, etc. for context

## How to Test

## Definition of Done

- [ ]

## Context Links

**Git Repo:**

**Relevant Code Links:**

**Azure**:

**Site URL**:

**Other**:

## Notes

-
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ test.describe(
);
});

test.skip("clears 'Report ID'", async ({ dailyDataPage }) => {
test("clears 'Report ID'", async ({ dailyDataPage }) => {
// Search by Report ID
const reportId = await tableDataCellValue(dailyDataPage.page, 0, 0);
await searchInput(dailyDataPage.page).fill(reportId);
Expand Down Expand Up @@ -289,7 +289,7 @@ test.describe(
expect(await tableDataCellValue(dailyDataPage.page, 0, 0)).toEqual(reportId);
});

test.skip("returns match for Filename", async ({ dailyDataPage }) => {
test("returns match for Filename", async ({ dailyDataPage }) => {
// Filename search is currently broken and being tracked
// in ticket #15644
const fileName = await tableDataCellValue(dailyDataPage.page, 0, 4);
Expand All @@ -302,7 +302,8 @@ test.describe(

// Check filter status lists receiver value
const filterStatusText = filterStatus([fileName]);
await expect(dailyDataPage.page.getByTestId("filter-status")).toContainText(filterStatusText);
const actualText = await dailyDataPage.page.getByTestId("filter-status").textContent();
expect(filterStatusText).toContain(actualText);

//Check table data matches search
expect(await tableDataCellValue(dailyDataPage.page, 0, 4)).toEqual(fileName);
Expand Down
16 changes: 16 additions & 0 deletions prime-router/src/main/kotlin/azure/ActionHistory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,22 @@ class ActionHistory(
}
}

/**
* Allows tracking of an empty report regardless of where it is generated in the pipeline
* @param report the details of the report
*/
fun trackEmptyReport(report: Report) {
generatingEmptyReport = true
val reportFile = ReportFile()
reportFile.reportId = report.id
reportFile.schemaTopic = report.schema.topic
reportFile.schemaName = "None"
reportFile.itemCount = 0
reportFile.bodyFormat = report.bodyFormat.toString()
reportFile.nextAction = TaskAction.none
reportsOut[reportFile.reportId] = reportFile
}

/**
* Use this to record history info about a newly generated empty [report] for sending to [receiver] that
* has requested an empty batch. The [event] will be batch or send.
Expand Down
33 changes: 3 additions & 30 deletions prime-router/src/main/kotlin/fhirengine/engine/FHIRConverter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import gov.cdc.prime.router.azure.LookupTableConditionMapper
import gov.cdc.prime.router.azure.ProcessEvent
import gov.cdc.prime.router.azure.db.Tables
import gov.cdc.prime.router.azure.db.enums.TaskAction
import gov.cdc.prime.router.azure.db.tables.pojos.ItemLineage
import gov.cdc.prime.router.azure.observability.bundleDigest.BundleDigestExtractor
import gov.cdc.prime.router.azure.observability.bundleDigest.FhirPathBundleDigestLabResultExtractorStrategy
import gov.cdc.prime.router.azure.observability.context.MDCUtils
Expand Down Expand Up @@ -277,41 +276,15 @@ class FHIRConverter(
}.collect(Collectors.toList()).filterNotNull()
}
} else {
val nextEvent = ProcessEvent(
Event.EventAction.NONE,
queueMessage.reportId,
Options.None,
emptyMap(),
emptyList()
)

// TODO: https://github.com/CDCgov/prime-reportstream/issues/15223
val report = Report(
MimeFormat.FHIR,
format,
emptyList(),
1,
0,
metadata = this.metadata,
topic = queueMessage.topic,
nextAction = TaskAction.none
)

// create item lineage
report.itemLineages = listOf(
ItemLineage(
null,
queueMessage.reportId,
1,
report.id,
1,
null,
null,
null,
report.getItemHashForRow(1)
)
)

// ensure tracking is set
actionHistory.trackCreatedReport(nextEvent, report)
actionHistory.trackEmptyReport(report)
reportEventService.sendReportProcessingError(
ReportStreamEventName.REPORT_NOT_PROCESSABLE,
report,
Expand Down
24 changes: 24 additions & 0 deletions prime-router/src/main/kotlin/history/DeliveryHistory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.annotation.JsonPropertyOrder
import gov.cdc.prime.router.Receiver
import gov.cdc.prime.router.Topic
import gov.cdc.prime.router.azure.db.tables.pojos.Action
import gov.cdc.prime.router.azure.db.tables.pojos.ReportFile
import java.time.OffsetDateTime

/**
Expand Down Expand Up @@ -65,6 +67,28 @@ class DeliveryHistory(
schema_topic,
itemCount
) {

companion object {
fun createDeliveryHistoryFromReportAndAction(
reportFile: ReportFile,
action: Action,
): DeliveryHistory {
return DeliveryHistory(
actionId = action.actionId,
createdAt = action.createdAt,
receivingOrg = reportFile.receivingOrg,
receivingOrgSvc = reportFile.receivingOrgSvc,
externalName = action.externalName,
reportId = reportFile.reportId.toString(),
schema_topic = reportFile.schemaTopic,
itemCount = reportFile.itemCount,
bodyUrl = reportFile.bodyUrl,
schemaName = reportFile.schemaName,
bodyFormat = reportFile.bodyFormat
)
}
}

@JsonIgnore
private val DAYS_TO_SHOW = 30L

Expand Down
29 changes: 23 additions & 6 deletions prime-router/src/main/kotlin/history/azure/DeliveryFacade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.util.*
*/
class DeliveryFacade(
private val dbDeliveryAccess: DatabaseDeliveryAccess = DatabaseDeliveryAccess(),
dbAccess: DatabaseAccess = BaseEngine.databaseAccessSingleton,
private val dbAccess: DatabaseAccess = BaseEngine.databaseAccessSingleton,
val reportService: ReportService = ReportService(),
) : ReportFileFacade(
dbAccess
Expand Down Expand Up @@ -91,17 +91,34 @@ class DeliveryFacade(
/**
* Get expanded details for a single report
*
* @param id either a report id (UUID) or action id (Long)
* @param deliveryId id for the delivery being used
* @return Report details
*/
fun findDetailedDeliveryHistory(
id: String,
deliveryId: Long,
): DeliveryHistory? {
val deliveryHistory = dbDeliveryAccess.fetchAction(
deliveryId,
orgName = null,
DeliveryHistory::class.java
)
// This functionality is handling the fact that the calling function supports loading the history either
// by the action id or report id
val reportFileId = try {
UUID.fromString(id)
} catch (ex: IllegalArgumentException) {
null
}

val deliveryHistory = if (reportFileId != null) {
val action = dbAccess.fetchAction(deliveryId)
val reportFile = dbAccess.fetchReportFile(reportFileId)
DeliveryHistory.createDeliveryHistoryFromReportAndAction(reportFile, action!!)
} else {
dbDeliveryAccess.fetchAction(
deliveryId,
orgName = null,
DeliveryHistory::class.java
)
}

val reportId = deliveryHistory?.reportId
if (reportId != null) {
val roots = reportService.getRootReports(UUID.fromString(reportId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class DeliveryFunction(
* @return
*/
override fun singleDetailedHistory(id: String, txn: DataAccessTransaction, action: Action): DeliveryHistory? {
return deliveryFacade.findDetailedDeliveryHistory(action.actionId)
return deliveryFacade.findDetailedDeliveryHistory(id, action.actionId)
}

@FunctionName("getDeliveriesV1")
Expand Down
18 changes: 3 additions & 15 deletions prime-router/src/test/kotlin/common/ReportNodeBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ReportGraphBuilder {
private lateinit var theTopic: Topic
private lateinit var theFormat: MimeFormat
private lateinit var theSender: Sender
private lateinit var theNextAction: TaskAction
private var theNextAction: TaskAction? = null

fun topic(topic: Topic) {
this.theTopic = topic
Expand Down Expand Up @@ -85,13 +85,7 @@ class ReportGraphBuilder {
.setItemCount(theSubmission.theItemCount)
.setExternalName("test-external-name")
.setBodyUrl(theSubmission.theReportBlobUrl)
.setNextAction(
if (::theNextAction.isInitialized) {
theNextAction
} else {
theSubmission.reportGraphNodes.firstOrNull()?.theAction
}
)
.setNextAction(theNextAction ?: theSubmission.reportGraphNodes.firstOrNull()?.theAction)
.setCreatedAt(OffsetDateTime.now())
dbAccess.insertReportFile(
reportFile, txn, action
Expand Down Expand Up @@ -142,13 +136,7 @@ class ReportGraphBuilder {
.setExternalName("test-external-name")
.setBodyUrl(node.theReportBlobUrl)
.setTransportResult(node.theTransportResult)
.setNextAction(
if (node.theNextAction != null) {
node.theNextAction
} else {
node.reportGraphNodes.firstOrNull()?.theAction
}
)
.setNextAction(node.theNextAction ?: node.reportGraphNodes.firstOrNull()?.theAction)
.setCreatedAt(graph.node.createdAt.plusMinutes(1))

if (node.receiver != null) {
Expand Down
Loading

0 comments on commit ac069f6

Please sign in to comment.