#724 Enable URL liveness check for release builds#729
Conversation
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
42868dd to
b98d700
Compare
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
2555475 to
1e68fd2
Compare
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
1e68fd2 to
45e70e3
Compare
…b CI Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
7584b83 to
13c3757
Compare
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
| @@ -49,27 +53,78 @@ func requiredIfBit0Set(fl validator.FieldLevel) bool { | |||
| } | |||
|
|
|||
| func isValidHttpOrHttpsUrl(fl validator.FieldLevel) bool { //nolint:stylecheck | |||
There was a problem hiding this comment.
Reachability checks cannot be implemented here, because it's part of ValidateBasic function which is part of the static validation, see https://csa-matter.slack.com/archives/C025PQ6RMRA/p1777291064854469.
Please implement reachability checks in separate dedicated functions which should be called only within CLI directly, as described in the original ticket.
There was a problem hiding this comment.
Update, but it is called(should be called) before the broadcasting txn to the DCLD nodes(before tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) call)
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
| var allowed4XXStatusCodes = []int{ | ||
| http.StatusUnauthorized, | ||
| http.StatusForbidden, | ||
| http.StatusUnavailableForLegalReasons, |
There was a problem hiding this comment.
Do we want to include also 405 Method Not Allowed — server rejects HEAD specifically?
Another option can be to treat any status beside 404 (and 5xx?) as reachable.
There was a problem hiding this comment.
Added 405. For the second option, as I know, when the server is down, it should return a 5xx code even requested page does not exist
There was a problem hiding this comment.
Yes, if the server is down - you only get server codes, not resource.
| specificationVersion, | ||
| ) | ||
|
|
||
| if releaseNotesURL != "" && !cli.IsLiveURL(releaseNotesURL) { |
| schemaVersion, | ||
| ) | ||
|
|
||
| if releaseNotesURL != "" && !cli.IsLiveURL(releaseNotesURL) { |
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
| env: | ||
| GH_TOKEN: ${{ secrets.GH_TOKEN }} | ||
| GOCOVER_MODE: set # Ensure integration tests use the same mode as unit tests | ||
| GOCOVER_MODE: set # Ensure integration tests use the same mode as unit tests\ |
There was a problem hiding this comment.
| GOCOVER_MODE: set # Ensure integration tests use the same mode as unit tests\ | |
| GOCOVER_MODE: set # Ensure integration tests use the same mode as unit tests |
| var httpClient = &http.Client{Timeout: livenessCheckTimeout} | ||
|
|
||
| func IsLiveURL(u string) bool { | ||
| if config.DisableURLLivenessCheck { |
There was a problem hiding this comment.
Let's rename it to URLLivenessCheckEnabled.
- Mark it as a boolean flag because
Disablelooks more like function name than boolean flag. - Change negative to positive. It is easier to read
URLLivenessCheckEnabledthus!URLLivenessCheckEnabledthanURLLivenessCheckDisabled.
There was a problem hiding this comment.
Renamed to URLLivenessCheckEnabled
| var allowed4XXStatusCodes = []int{ | ||
| http.StatusUnauthorized, | ||
| http.StatusForbidden, | ||
| http.StatusUnavailableForLegalReasons, |
There was a problem hiding this comment.
Yes, if the server is down - you only get server codes, not resource.
| // Empty strings are skipped. | ||
| // | ||
| // Returns an empty string if all non-empty URLs are reachable. | ||
| func FirstUnreachableURL(urls ...string) string { |
There was a problem hiding this comment.
As far as I understand - reason of having this function is to throw error if ANY of given urls are not reachable.
It would be more UX friendly if we can give info on ALL unreachable urls in one check.
Worst case for both scenarios - timeout.
Best case for FirstUnreachableURL - when any of calls gives error.
Best case for CheckURLsForReachability - when all calls are completed.
@ashcherbakov what do you think?
There was a problem hiding this comment.
I think it makes sense to provide a list of all unreachable URLs at the same time for better UX.
| test: | ||
| go test -v $(PACKAGES) | ||
| go test -tags=dev -v $(PACKAGES) | ||
| go test -v utils/cli/url_liveness.go utils/cli/url_liveness_test.go |
There was a problem hiding this comment.
Can we move these files into variable just like PACKAGES?
There was a problem hiding this comment.
No, because url_liveness_test.go should be executed without dev tag
Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com>
Closes #724