Skip to content

Commit

Permalink
Carl/bcda 8621 fix eoy smoke tests (#1025)
Browse files Browse the repository at this point in the history
## 🎫 Ticket

https://jira.cms.gov/browse/BCDA-8621

## 🛠 Changes

Various adjustments to postman smoke test collections to account for
changes in EOY logic/handling.

## ℹ️ Context

Earlier last year we had made a variety of changes to EOY logic/handling
to reduce dev manual processes as well as improve client experience.
Unfortunately these changes happened after the EOY window so these smoke
tests were somewhat untested.

<!-- If any of the following security implications apply, this PR must
not be merged without Stephen Walter's approval. Explain in this section
and add @SJWalter11 as a reviewer.
  - Adds a new software dependency or dependencies.
  - Modifies or invalidates one or more of our security controls.
  - Stores or transmits data that was not stored or transmitted before.
- Requires additional review of security implications for other reasons.
-->

## 🧪 Validation

Local testing and linting, also ran jenkins smoke test off of this
branch
  • Loading branch information
carlpartridge authored Jan 3, 2025
1 parent 27f1038 commit 194ffd4
Show file tree
Hide file tree
Showing 4 changed files with 298 additions and 619 deletions.
2 changes: 1 addition & 1 deletion bcda/service/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Config struct {

type RunoutConfig struct {
CutoffDurationDays int `conf:"RUNOUT_CUTOFF_DATE_DAYS" conf_default:"180"`
ClaimThruDate string `conf:"RUNOUT_CLAIM_THRU_DATE" conf_default:"2020-12-31"`
ClaimThruDate string `conf:"RUNOUT_CLAIM_THRU_DATE" conf_default:"2024-12-31"`
// Un-exported fields that are computed using the exported ones above
cutoffDuration time.Duration
claimThru time.Time
Expand Down
122 changes: 40 additions & 82 deletions test/postman_test/BCDA_PAC_Postman_Smoke_Tests.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -1142,15 +1142,12 @@
"var maintenanceMode = pm.globals.get(\"maintenanceMode\");",
"",
"var maintenanceModeEOYTest = function () {",
" pm.test(\"Status code is 202\", function () {",
" pm.response.to.have.status(202);",
" });",
"",
" pm.test(\"Has Content-Location header\", function () {",
" pm.response.to.have.header(\"Content-Location\");",
" console.log(\"EOY mode is enabled - Expect 500 due to no file attributions found\");",
" pm.test(\"Status code is 500\", function () {",
" pm.response.to.have.status(500);",
" });",
"",
" pm.environment.set(\"smokeTestGroupRunoutEOBJobUrl\", pm.response.headers.get(\"Content-Location\"));",
" pm.environment.set(\"smokeTestGroupRunoutEOBJobUrl\", \"https://bcda.cms.gov\");",
"};",
"",
"const maintenanceModeTest = function () {",
Expand Down Expand Up @@ -1217,38 +1214,45 @@
"listen": "prerequest",
"script": {
"exec": [
"const retryDelay = 5000;",
"const maxRetries = 20;",
"var maintenanceMode = pm.globals.get(\"maintenanceMode\");",
"",
"var eobJobReq = {",
" url: pm.environment.get(\"smokeTestGroupRunoutEOBJobUrl\"),",
" method: \"GET\",",
" header: \"Authorization: Bearer \" + pm.environment.get(\"token\")",
"};",
"if (maintenanceMode === \"eoy\") {",
" console.log(\"EOY mode is enabled - Skipping due to previous 500, see above test.\");",
" return;",
"} else {",
" const retryDelay = 5000;",
" const maxRetries = 20;",
"",
"function awaitExportJob(retryCount) {",
" pm.sendRequest(eobJobReq, function (err, response) {",
" if (err) {",
" console.error(err);",
" } else if (response.code == 202) {",
" pm.test(\"X-Progress header is Pending or In Progress\", function() {",
" pm.expect(/^(Pending|In Progress \\(\\d{1,3}%\\))$/.test(response.headers.get(\"X-Progress\"))).to.be.true;",
" });",
" if (retryCount < maxRetries) {",
" console.log(\"Group/runout export still in progress. Retrying...\");",
" setTimeout(function() {",
" awaitExportJob(++retryCount);",
" }, retryDelay);",
" var eobJobReq = {",
" url: pm.environment.get(\"smokeTestGroupRunoutEOBJobUrl\"),",
" method: \"GET\",",
" header: \"Authorization: Bearer \" + pm.environment.get(\"token\")",
" };",
"",
" function awaitExportJob(retryCount) {",
" pm.sendRequest(eobJobReq, function (err, response) {",
" if (err) {",
" console.error(err);",
" } else if (response.code == 202) {",
" pm.test(\"X-Progress header is Pending or In Progress\", function() {",
" pm.expect(/^(Pending|In Progress \\(\\d{1,3}%\\))$/.test(response.headers.get(\"X-Progress\"))).to.be.true;",
" });",
" if (retryCount < maxRetries) {",
" console.log(\"Group/runout export still in progress. Retrying...\");",
" setTimeout(function() {",
" awaitExportJob(++retryCount);",
" }, retryDelay);",
" } else {",
" console.log(\"Retry limit reached for Group/runout job status.\");",
" postman.setNextRequest(null);",
" }",
" } else if (response.code == 200) {",
" console.log(\"Group/runout export job complete.\");",
" } else {",
" console.log(\"Retry limit reached for Group/runout job status.\");",
" postman.setNextRequest(null);",
" console.error(\"Unexpected response from Group/runout export job: \" + response.status);",
" }",
" } else if (response.code == 200) {",
" console.log(\"Group/runout export job complete.\");",
" } else {",
" console.error(\"Unexpected response from Group/runout export job: \" + response.status);",
" }",
" });",
" });",
" }",
"}",
"",
"awaitExportJob(1);"
Expand All @@ -1267,53 +1271,7 @@
" pm.expect(pm.response.code).to.be.oneOf([202, 200]);",
" });",
"",
" if (pm.response.code === 202) {",
" pm.test(\"X-Progress header is Pending or In Progress\", function () {",
" pm.expect(/^(Pending|In Progress \\(\\d{1,3}%\\))$/.test(pm.response.headers.get(\"X-Progress\"))).to.be.true;",
" });",
" } else if (pm.response.code === 200) {",
" const schema = {",
" \"properties\": {",
" \"transactionTime\": {",
" \"type\": \"string\"",
" },",
" \"request\": {",
" \"type\": \"string\"",
" },",
" \"requiresAccessToken\": {",
" \"type\": \"boolean\"",
" },",
" \"output\": {",
" \"type\": \"array\"",
" },",
" \"error\": {",
" \"type\": \"array\"",
" }",
" }",
" };",
"",
" var respJson = pm.response.json();",
"",
" pm.test(\"Schema is valid\", function () {",
" pm.expect(tv4.validate(respJson, schema)).to.be.true;",
" });",
"",
" pm.test(\"Contains Required Resources\", () => {",
" const requiredResources = [\"ExplanationOfBenefit\"];",
" const otherResources = [\"Patient\", \"Coverage\", \"Claim\", \"ClaimResponse\"];",
" const returnedResources = respJson.output.map(r => r.type);",
"",
" for (const resource of requiredResources) {",
" pm.expect(returnedResources, resource + \" is required\").to.include(resource);",
" }",
"",
" for (const resource of otherResources) {",
" pm.expect(returnedResources, resource + \" resource type should not be returned\").to.not.include(resource);",
" }",
" });",
"",
" pm.environment.set(\"smokeTestGroupRunoutEOBDataUrl\", respJson.output[0].url);",
" }",
" pm.environment.set(\"smokeTestGroupRunoutEOBDataUrl\", \"https://bcda.cms.gov\");",
"};",
"",
"const maintenanceModeTest = function () {",
Expand Down
81 changes: 24 additions & 57 deletions test/postman_test/BCDA_Postman_Smoke_Tests.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,20 @@
"listen": "test",
"script": {
"exec": [
"const maintenanceMode = pm.globals.get(\"maintenanceMode\");",
"pm.test(\"Status code is 401\", function() {",
" pm.response.to.have.status(401);",
"});",
"",
"if (maintenanceMode === \"eoy\") {\t",
" console.log(\"EOY mode is enabled - Skipping Patient/$export request\");\t",
" pm.test(\"Status code is 400, 404, or 500\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([400, 404, 500]);",
" });",
"} else {",
" pm.test(\"Status code is 401\", function() {",
" pm.response.to.have.status(401);",
" });",
"var respJson = pm.response.json();",
"",
"pm.test(\"Resource type is OperationOutcome\", function() {",
" var respJson = pm.response.json();",
" pm.expect(respJson.resourceType).to.eql(\"OperationOutcome\")",
"});",
"",
" pm.test(\"Resource type is OperationOutcome\", function() {",
" var respJson = pm.response.json();",
" pm.expect(respJson.resourceType).to.eql(\"OperationOutcome\")",
" });",
"",
" pm.test(\"Diagnostics is Invalid Token\", function() {",
" pm.expect(respJson.issue[0].diagnostics).to.eql(\"Invalid Token\")",
" });",
"}"
"pm.test(\"Diagnostics is Invalid Token\", function() {",
" pm.expect(respJson.issue[0].diagnostics).to.eql(\"Invalid Token\")",
"});"
],
"type": "text/javascript"
}
Expand Down Expand Up @@ -223,27 +214,15 @@
"listen": "test",
"script": {
"exec": [
"const maintenanceMode = pm.globals.get(\"maintenanceMode\");",
"",
"if (maintenanceMode === \"eoy\") {\t",
" console.log(\"EOY mode is enabled - Skipping Patient/all endpoint request\");\t\t\t\t ",
" pm.environment.set(\"smokeTestPatientJobUrl\", \"https://bcda.cms.gov\");",
"",
" pm.test(\"Status code is 400, 404, or 500\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([400, 404, 500]);",
" });",
" return;",
"} else {",
" pm.test(\"Status code is 202\", function() {",
" pm.response.to.have.status(202);",
" });",
"pm.test(\"Status code is 202\", function() {",
" pm.response.to.have.status(202);",
"});",
"",
" pm.test(\"Has Content-Location header\", function() {",
" pm.response.to.have.header(\"Content-Location\");",
" });",
"pm.test(\"Has Content-Location header\", function() {",
" pm.response.to.have.header(\"Content-Location\");",
"});",
"",
" pm.environment.set(\"smokeTestPatientJobUrl\", pm.response.headers.get(\"Content-Location\"));",
"}"
"pm.environment.set(\"smokeTestPatientJobUrl\", pm.response.headers.get(\"Content-Location\"));"
],
"type": "text/javascript"
}
Expand Down Expand Up @@ -515,27 +494,15 @@
"listen": "test",
"script": {
"exec": [
"const maintenanceMode = pm.globals.get(\"maintenanceMode\");",
"",
"if (maintenanceMode === \"eoy\") {\t",
" console.log(\"EOY mode is enabled - Skipping Group/all endpoint request\");\t\t\t\t ",
" pm.environment.set(\"smokeTestGroupAllJobUrl\", \"https://bcda.cms.gov\");",
"",
" pm.test(\"Status code is 400, 404, or 500\", function() {",
" pm.expect(pm.response.code).to.be.oneOf([400, 404, 500]);",
" });",
" return;",
"} else {",
" pm.test(\"Status code is 202\", function () {",
" pm.response.to.have.status(202);",
" });",
"pm.test(\"Status code is 202\", function () {",
" pm.response.to.have.status(202);",
"});",
"",
" pm.test(\"Has Content-Location header\", function () {",
" pm.response.to.have.header(\"Content-Location\");",
" });",
"pm.test(\"Has Content-Location header\", function () {",
" pm.response.to.have.header(\"Content-Location\");",
"});",
"",
" pm.environment.set(\"smokeTestGroupAllJobUrl\", pm.response.headers.get(\"Content-Location\"));",
"}"
"pm.environment.set(\"smokeTestGroupAllJobUrl\", pm.response.headers.get(\"Content-Location\"));"
],
"type": "text/javascript"
}
Expand Down
Loading

0 comments on commit 194ffd4

Please sign in to comment.