Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita8fbe71

Browse files
authored
chore(cli): increase healthcheck timeout in TestSupportbundle (#17291)
Fixescoder/internal#272* Increases healthcheck timeout in tests. This seems to be the mostusual cause of test failures.* Adds a non-nilness check before caching a healthcheck report.* Modifies the HTTP response code to 503 (was 404) when no healthcheckreport is available. 503 seems to be a better indicator of the serverstate in this case, whereas 404 could be misinterpreted as a typo in thehealthcheck URL.
1 parent8d122aa commita8fbe71

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

‎cli/support_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ func TestSupportBundle(t *testing.T) {
5050
secretValue:=uuid.NewString()
5151
seedSecretDeploymentOptions(t,&dc,secretValue)
5252
client,db:=coderdtest.NewWithDatabase(t,&coderdtest.Options{
53-
DeploymentValues:dc.Values,
53+
DeploymentValues:dc.Values,
54+
HealthcheckTimeout:testutil.WaitSuperLong,
5455
})
5556
owner:=coderdtest.CreateFirstUser(t,client)
5657
r:=dbfake.WorkspaceBuild(t,db, database.WorkspaceTable{
@@ -113,7 +114,8 @@ func TestSupportBundle(t *testing.T) {
113114
secretValue:=uuid.NewString()
114115
seedSecretDeploymentOptions(t,&dc,secretValue)
115116
client:=coderdtest.New(t,&coderdtest.Options{
116-
DeploymentValues:dc.Values,
117+
DeploymentValues:dc.Values,
118+
HealthcheckTimeout:testutil.WaitSuperLong,
117119
})
118120
_=coderdtest.CreateFirstUser(t,client)
119121

@@ -133,7 +135,8 @@ func TestSupportBundle(t *testing.T) {
133135
secretValue:=uuid.NewString()
134136
seedSecretDeploymentOptions(t,&dc,secretValue)
135137
client,db:=coderdtest.NewWithDatabase(t,&coderdtest.Options{
136-
DeploymentValues:dc.Values,
138+
DeploymentValues:dc.Values,
139+
HealthcheckTimeout:testutil.WaitSuperLong,
137140
})
138141
admin:=coderdtest.CreateFirstUser(t,client)
139142
r:=dbfake.WorkspaceBuild(t,db, database.WorkspaceTable{

‎coderd/debug.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,15 @@ func (api *API) debugDeploymentHealth(rw http.ResponseWriter, r *http.Request) {
8484
defercancel()
8585

8686
report:=api.HealthcheckFunc(ctx,apiKey)
87-
api.healthCheckCache.Store(report)
87+
ifreport!=nil {// Only store non-nil reports.
88+
api.healthCheckCache.Store(report)
89+
}
8890
returnreport,nil
8991
})
9092

9193
select {
9294
case<-ctx.Done():
93-
httpapi.Write(ctx,rw,http.StatusNotFound, codersdk.Response{
95+
httpapi.Write(ctx,rw,http.StatusServiceUnavailable, codersdk.Response{
9496
Message:"Healthcheck is in progress and did not complete in time. Try again in a few seconds.",
9597
})
9698
return

‎coderd/debug_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestDebugHealth(t *testing.T) {
117117
require.NoError(t,err)
118118
deferres.Body.Close()
119119
_,_=io.ReadAll(res.Body)
120-
require.Equal(t,http.StatusNotFound,res.StatusCode)
120+
require.Equal(t,http.StatusServiceUnavailable,res.StatusCode)
121121
})
122122

123123
t.Run("Refresh",func(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp