-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(securitycenter): issues related to flaky tests in SHA & ETD #5090
Open
vijaykanthm
wants to merge
15
commits into
GoogleCloudPlatform:main
Choose a base branch
from
vijaykanthm:fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-issue
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+331
−276
Open
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
6bd5d1d
fix(securitycenter): issues related to flaky tests in SHA & ETD
vijaykanthm ecd1bd1
fix lint by updating mod
vijaykanthm 191b08c
Merge branch 'main' into fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-…
vijaykanthm 5ea9b14
comment the mutex
vijaykanthm b7da5a8
Merge branch 'fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-issue' of g…
vijaykanthm 6248287
Merge branch 'main' into fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-…
telpirion eee4318
Remove commented code and fix lint
vijaykanthm f394b7a
Merge branch 'fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-issue' of g…
vijaykanthm 9c7cc0b
Merge branch 'main' into fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-…
vijaykanthm f4f210e
Refactor the module creation and clean up
vijaykanthm 50cd35c
Merge branch 'fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-issue' of g…
vijaykanthm c0f0c0e
Merge branch 'main' into fix-scc-mgt-api-sha-etd-cust-mod-test-flaky-…
vijaykanthm c263e15
fix the mod changes
vijaykanthm fa7578e
Replace hypen with underscores for uuid in etd display names
vijaykanthm a025e93
Add regex import to the test
vijaykanthm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,10 @@ import ( | |
"context" | ||
"fmt" | ||
"io" | ||
"math/rand" | ||
"time" | ||
|
||
securitycentermanagement "cloud.google.com/go/securitycentermanagement/apiv1" | ||
securitycentermanagementpb "cloud.google.com/go/securitycentermanagement/apiv1/securitycentermanagementpb" | ||
"github.com/google/uuid" | ||
"google.golang.org/protobuf/types/known/structpb" | ||
) | ||
|
||
|
@@ -42,10 +41,7 @@ func createEventThreatDetectionCustomModule(w io.Writer, parent string) error { | |
} | ||
defer client.Close() | ||
|
||
// Seed the random number generator | ||
rand.Seed(time.Now().UnixNano()) | ||
// Generate a unique suffix | ||
uniqueSuffix := fmt.Sprintf("%d-%d", time.Now().Unix(), rand.Intn(1000)) | ||
uniqueSuffix := uuid.New().String() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding logic to handle potential UUID collisions, similar to what's done in 44: uniqueSuffix := uuid.New().String()
45:
46: // Remove invalid characters (anything that isn't alphanumeric or an underscore)
47: re := regexp.MustCompile(`[^a-zA-Z0-9_]`)
48: uniqueSuffix = re.ReplaceAllString(uniqueSuffix, "_") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed. |
||
// Create unique display name | ||
displayName := fmt.Sprintf("go_sample_etd_custom_module_%s", uniqueSuffix) | ||
|
||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good practice to precompile the regex for better performance.