raystack / guardian

Guardian is universal data access management tool with automated access workflows and security controls across data stores, analytical systems, and cloud products.
https://guardian.vercel.app/
Apache License 2.0
137 stars 21 forks source link

bigquery get activities test case is flaky #344

Closed bsushmith closed 1 year ago

bsushmith commented 1 year ago

Description bigquery GetActivities test case is flaky. this is due to the go routines which are used to create the permission array. These permissions can be in any order but the test case expects them to be in a given specific order

            provider_test.go:1151: 
                    Error Trace:    /home/runner/work/guardian/guardian/plugins/providers/bigquery/provider_test.go:1151
                                                /home/runner/work/guardian/guardian/plugins/providers/bigquery/suite.go:91
                    Error:          Not equal: 
                                    expected: []*domain.Activity{(*domain.Activity)(0xc0001480f0)}
                                    actual  : []*domain.Activity{(*domain.Activity)(0xc00035e000)}

                                    Diff:
                                    --- Expected
                                    +++ Actual
                                    @@ -42,4 +42,4 @@
                                       RelatedPermissions: ([]string) (len=2) {
                                    -   (string) (len=6) "READER",
                                    -   (string) (len=6) "WRITER"
                                    +   (string) (len=6) "WRITER",
                                    +   (string) (len=6) "READER"
                                       },
                    Test:           TestBigQueryProvider/TestGetActivities_Success/should_map_bigquery_logging_entries_to_guardian_activities
FAIL

Expected behavior Test case should not be flaky.

Additional context We can either sort in code itself so that the values are in expected order always or we can sort in the test case and then do assert