-
Notifications
You must be signed in to change notification settings - Fork 219
Skip an accept-risk case on network-restricted environment #1332
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ package util | |
|
|
||
| import ( | ||
| "context" | ||
| "net/http" | ||
| "time" | ||
|
|
||
| g "github.com/onsi/ginkgo/v2" | ||
|
|
@@ -135,3 +136,27 @@ const ( | |
| // fauxinnati mocks Cincinnati Update Graph Server for OpenShift | ||
| FauxinnatiAPIURL = "https://fauxinnati-fauxinnati.apps.ota-stage.q2z4.p1.openshiftapps.com/api/upgrades_info/graph" | ||
| ) | ||
|
|
||
| func accessible(url string) bool { | ||
| client := &http.Client{ | ||
| Timeout: 5 * time.Second, | ||
| } | ||
| resp, err := client.Get(url) | ||
| defer func() { | ||
| if resp != nil && resp.Body != nil { | ||
| _ = resp.Body.Close() | ||
| } | ||
| }() | ||
| return err == nil | ||
| } | ||
|
|
||
| func NetworkRestricted() bool { | ||
| // TODO: Use a more precise method | ||
| return !accessible("http://google.com") | ||
|
Member
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. you could take an argument here, and pass through |
||
| } | ||
hongkailiu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| func SkipIfNetworkRestricted() { | ||
| if NetworkRestricted() { | ||
| g.Skip("This test is skipped because the network is restricted") | ||
| } | ||
| } | ||
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.
ocdoes a similar thing.https://github.com/openshift/oc/blob/2bd770b8f00d1f6b6a49afe8c5ee411665f2e308/test/e2e/util.go#L1008