@@ -9,6 +9,8 @@ package integration
9
9
import (
10
10
"bytes"
11
11
"context"
12
+ "encoding/json"
13
+ "fmt"
12
14
"os"
13
15
"os/exec"
14
16
"path/filepath"
@@ -48,7 +50,7 @@ func TestPackageVersion(t *testing.T) {
48
50
// run the agent and check the daemon version as well
49
51
t .Run ("check package version while the agent is running" , testVersionWithRunningAgent (ctx , f ))
50
52
51
- // Destructive/mutating tests ahead! If you need to do a normal test on a healthy install of agent, put it before the tests below
53
+ // Destructive/mutating tests ahead! If you need to do a normal test on a healthy installation of agent, put it before the tests below
52
54
53
55
// change the version in the version file and verify that the agent returns the new value
54
56
t .Run ("check package version after updating file" , testVersionAfterUpdatingFile (ctx , f ))
@@ -64,10 +66,6 @@ func TestComponentBuildHashInDiagnostics(t *testing.T) {
64
66
Local : false , // requires Agent installation
65
67
Sudo : true , // requires Agent installation
66
68
})
67
- if runtime .GOOS == "windows" {
68
- t .Skip ("flaky on windows: https://github.com/elastic/elastic-agent/issues/4215" )
69
- }
70
-
71
69
ctx := context .Background ()
72
70
73
71
f , err := define .NewFixture (t , define .Version ())
@@ -93,21 +91,38 @@ func TestComponentBuildHashInDiagnostics(t *testing.T) {
93
91
"failed to install start agent [output: %s]" , string (output ))
94
92
95
93
stateBuff := bytes.Buffer {}
96
- isHealth := func () bool {
94
+ allHealthy := func () bool {
97
95
stateBuff .Reset ()
98
96
99
- err := f .IsHealthy (ctx )
97
+ status , err := f .ExecStatus (ctx )
100
98
if err != nil {
101
- stateBuff .WriteString (err .Error ())
99
+ stateBuff .WriteString (fmt .Sprintf ("failed to get agent status: %v" ,
100
+ err ))
102
101
return false
103
102
}
104
103
104
+ for _ , c := range status .Components {
105
+ state := client .State (c .State )
106
+ if state != client .Healthy {
107
+ bs , err := json .MarshalIndent (status , "" , " " )
108
+ if err != nil {
109
+ stateBuff .WriteString (fmt .Sprintf ("%s not health, could not marshal status outptu: %v" ,
110
+ c .Name , err ))
111
+ return false
112
+ }
113
+
114
+ stateBuff .WriteString (fmt .Sprintf ("%s not health, agent status output: %s" ,
115
+ c .Name , bs ))
116
+ return false
117
+ }
118
+ }
119
+
105
120
return true
106
121
}
107
122
require .Eventuallyf (t ,
108
- isHealth ,
109
- 1 * time .Minute , 10 * time .Second ,
110
- "agent did not became health . Last status: %v" , & stateBuff )
123
+ allHealthy ,
124
+ 5 * time .Minute , 10 * time .Second ,
125
+ "agent never became healthy . Last status: %v" , & stateBuff )
111
126
112
127
filebeat := "filebeat"
113
128
if runtime .GOOS == "windows" {
0 commit comments