@@ -26,6 +26,7 @@ import (
26
26
27
27
"github.com/elastic/elastic-agent/internal/pkg/agent/application/paths"
28
28
"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/details"
29
+ "github.com/elastic/elastic-agent/internal/pkg/agent/install"
29
30
"github.com/elastic/elastic-agent/pkg/component"
30
31
"github.com/elastic/elastic-agent/pkg/control"
31
32
"github.com/elastic/elastic-agent/pkg/control/v2/client"
@@ -1209,7 +1210,7 @@ func createTempDir(t *testing.T) string {
1209
1210
1210
1211
cleanup := func () {
1211
1212
if ! t .Failed () {
1212
- if err := removeAll (tempDir ); err != nil {
1213
+ if err := install . RemovePath (tempDir ); err != nil {
1213
1214
t .Errorf ("could not remove temp dir '%s': %s" , tempDir , err )
1214
1215
}
1215
1216
} else {
@@ -1221,37 +1222,6 @@ func createTempDir(t *testing.T) string {
1221
1222
return tempDir
1222
1223
}
1223
1224
1224
- // removeAll tries to remove path, if it fails and the error
1225
- // is retry able (only on Windows), it will keep retrying with an exponential
1226
- // backoff up to 3 seconds.
1227
- func removeAll (path string ) error {
1228
- maxBackoffTime := 3 * time .Second
1229
- myyBackoff := backoff .NewExponentialBackOff (
1230
- backoff .WithMaxElapsedTime (maxBackoffTime ),
1231
- backoff .WithInitialInterval (time .Millisecond ))
1232
-
1233
- myyBackoff .Reset ()
1234
- for {
1235
- err := os .RemoveAll (path )
1236
- if err == nil {
1237
- break
1238
- }
1239
-
1240
- if ! isWindowsRetryable (err ) {
1241
- return fmt .Errorf ("could not remove temp dir '%s': %s" , path , err )
1242
- }
1243
-
1244
- interval := myyBackoff .NextBackOff ()
1245
- if interval == backoff .Stop {
1246
- return fmt .Errorf ("could not remove '%s' after waiting for %s: %w" , path , maxBackoffTime , err )
1247
- }
1248
-
1249
- time .Sleep (interval )
1250
- }
1251
-
1252
- return nil
1253
- }
1254
-
1255
1225
type AgentStatusOutput struct {
1256
1226
Info struct {
1257
1227
ID string `json:"id"`
0 commit comments