Skip to content

Commit 3318669

Browse files
committed
Make cfgmgmt_actions diagnostics less picky
Signed-off-by: Daniel DeLeo <dan@chef.io>
1 parent 2d277d4 commit 3318669

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

components/automate-cli/pkg/diagnostics/integration/cfgmgmt_actions.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,17 @@ func CreateCfgmgmtActionsDiagnostic() diagnostics.Diagnostic {
123123
maxTries := 5
124124

125125
for _, entity := range loaded.CreatedEntities {
126-
reqPath := fmt.Sprintf("/api/v0/eventfeed?collapse=true&page_size=100&start=%d&end=%d", entity.RecordedAtMillis-1, entity.RecordedAtMillis+1)
126+
reqPath := fmt.Sprintf("/api/v0/eventfeed?collapse=true&page_size=100&start=%d&end=%d", entity.RecordedAtMillis-1000, entity.RecordedAtMillis+1000)
127127
found := false
128+
129+
type eventsFeedResp struct {
130+
Events []struct {
131+
EntityName string `json:"entity_name"`
132+
} `json:"events"`
133+
}
134+
135+
respUnmarshalled := eventsFeedResp{}
136+
128137
RETRY_LOOP:
129138
for {
130139
resp, err := tstCtx.DoLBRequest(reqPath)
@@ -137,13 +146,7 @@ func CreateCfgmgmtActionsDiagnostic() diagnostics.Diagnostic {
137146
// We wont retry a flakey backend. It should always return 200
138147
require.Equal(tstCtx, 200, resp.StatusCode, "Failed to GET %s", reqPath)
139148

140-
type eventsFeedResp struct {
141-
Events []struct {
142-
EntityName string `json:"entity_name"`
143-
} `json:"events"`
144-
}
145-
146-
respUnmarshalled := eventsFeedResp{}
149+
respUnmarshalled = eventsFeedResp{}
147150
err = json.NewDecoder(resp.Body).Decode(&respUnmarshalled)
148151
// We should always get valid json
149152
require.NoError(tstCtx, err, "Failed to decode body of GET %s", reqPath)
@@ -158,9 +161,9 @@ func CreateCfgmgmtActionsDiagnostic() diagnostics.Diagnostic {
158161
if tries >= maxTries {
159162
break RETRY_LOOP
160163
}
161-
time.Sleep(2 * time.Duration(tries) * time.Second)
164+
time.Sleep(5 * time.Duration(tries) * time.Second)
162165
}
163-
assert.True(tstCtx, found, "Could not find entity %s in GET %s", entity.EntityName, reqPath)
166+
assert.True(tstCtx, found, "Could not find entity %s in GET %s; did get %+v", entity.EntityName, reqPath, respUnmarshalled)
164167
}
165168

166169
},

0 commit comments

Comments
 (0)