Skip to content

Commit

Permalink
Reenable TestFhirIO.* on GHA (#28435)
Browse files Browse the repository at this point in the history
* Reenable TestFhirIO.* on GHA

* Propogate last error

* temporarily only look at failing test and better error

* temporarily only look at failing test and better error

* temporarily only look at failing test and better error

* Restore integration.go
  • Loading branch information
damccorm authored Oct 9, 2023
1 parent 9eac030 commit 4ead788
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
6 changes: 0 additions & 6 deletions sdks/go/test/integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,6 @@ func CheckFilters(t *testing.T) {
panic("ptest.Main() has not been called: please override TestMain to ensure that the integration test runs properly.")
}

// TODO(https://github.com/apache/beam/issues/28227): Grant github-actions service account permission to healthcare.fhirStores.create.
var user = os.Getenv("USER")
if user == "github-actions" {
dataflowFilters = append(dataflowFilters, "TestFhirIO.*")
}

// Check for sickbaying first.
n := t.Name()
for _, f := range sickbay {
Expand Down
19 changes: 14 additions & 5 deletions sdks/go/test/integration/io/fhirio/fhirio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ func setupFhirStore(t *testing.T, shouldPopulateStore bool) (fhirStoreInfo, func

var resourcePaths [][]byte
if shouldPopulateStore {
resourcePaths = populateStore(createdFhirStorePath)
if len(resourcePaths) == 0 {
t.Fatal("No data got populated to test")
resourcePaths, err = populateStore(createdFhirStorePath)
if err != nil {
t.Fatal(err)
}
}

Expand Down Expand Up @@ -127,11 +127,13 @@ func deleteStore(storePath string) (*healthcare.Empty, error) {

// Populates fhir store with data. Note that failure to populate some data is not
// detrimental to the tests, so it is fine to ignore.
func populateStore(storePath string) [][]byte {
func populateStore(storePath string) ([][]byte, error) {
resourcePaths := make([][]byte, 0)
bufferedErrors := make([]string, 0)
for _, bundle := range readPrettyBundles() {
response, err := storeService.ExecuteBundle(storePath, strings.NewReader(bundle)).Do()
if err != nil {
bufferedErrors = append(bufferedErrors, err.Error())
continue
}

Expand All @@ -145,23 +147,30 @@ func populateStore(storePath string) [][]byte {
}
err = json.NewDecoder(response.Body).Decode(&body)
if err != nil {
bufferedErrors = append(bufferedErrors, err.Error())
continue
}

for _, entry := range body.Entry {
bundleFailedToBeCreated := !strings.Contains(entry.Response.Status, "201")
if bundleFailedToBeCreated {
bufferedErrors = append(bufferedErrors, fmt.Sprintf("Bundle creation failed with: %v", entry.Response))
continue
}

resourcePath, err := extractResourcePathFrom(entry.Response.Location)
if err != nil {
bufferedErrors = append(bufferedErrors, err.Error())
continue
}
resourcePaths = append(resourcePaths, resourcePath)
}
}
return resourcePaths
if len(resourcePaths) == 0 {
return nil, fmt.Errorf("failed to populate fhir store with any data. Errors with requests: %s", bufferedErrors)
}

return resourcePaths, nil
}

func readPrettyBundles() []string {
Expand Down

0 comments on commit 4ead788

Please sign in to comment.