@@ -9,6 +9,7 @@ package integration
99import (
1010 "context"
1111 "fmt"
12+ "os"
1213 "os/exec"
1314 "strings"
1415 "testing"
@@ -49,6 +50,75 @@ func TestDebLogIngestFleetManaged(t *testing.T) {
4950 agentFixture , err := define .NewFixtureFromLocalBuild (t , define .Version (), atesting .WithPackageFormat ("deb" ))
5051 require .NoError (t , err )
5152
53+ installOpts := atesting.InstallOpts {
54+ NonInteractive : true ,
55+ Force : true ,
56+ InstallServers : false ,
57+ }
58+
59+ testDebLogIngestFleetManagedWithCheck (ctx , t , agentFixture , info , installOpts ,
60+ testComponentsPresence (ctx , agentFixture ,
61+ []componentPresenceDefinition {
62+ {"agentbeat" , []string {"windows" , "linux" , "darwin" }},
63+ {"endpoint-security" , []string {"windows" , "linux" , "darwin" }},
64+ {"pf-host-agent" , []string {"linux" }},
65+ },
66+ []componentPresenceDefinition {
67+ {"cloudbeat" , []string {"linux" }},
68+ {"apm-server" , []string {"windows" , "linux" , "darwin" }},
69+ {"fleet-server" , []string {"windows" , "linux" , "darwin" }},
70+ {"pf-elastic-symbolizer" , []string {"linux" }},
71+ {"pf-elastic-collector" , []string {"linux" }},
72+ },
73+ ),
74+ )
75+ }
76+
77+ func TestDebInstallsServers (t * testing.T ) {
78+ info := define .Require (t , define.Requirements {
79+ Group : Deb ,
80+ Stack : & define.Stack {},
81+ OS : []define.OS {
82+ {
83+ Type : define .Linux ,
84+ Distro : "ubuntu" ,
85+ },
86+ },
87+ Local : false ,
88+ Sudo : true ,
89+ })
90+
91+ ctx , cancel := testcontext .WithDeadline (t , context .Background (), time .Now ().Add (10 * time .Minute ))
92+ defer cancel ()
93+
94+ agentFixture , err := define .NewFixtureFromLocalBuild (t , define .Version (), atesting .WithPackageFormat ("deb" ))
95+ require .NoError (t , err )
96+
97+ installOpts := atesting.InstallOpts {
98+ NonInteractive : true ,
99+ Force : true ,
100+ InstallServers : true ,
101+ }
102+
103+ testDebLogIngestFleetManagedWithCheck (ctx , t , agentFixture , info , installOpts ,
104+ testComponentsPresence (ctx , agentFixture ,
105+ []componentPresenceDefinition {
106+ {"agentbeat" , []string {"windows" , "linux" , "darwin" }},
107+ {"endpoint-security" , []string {"windows" , "linux" , "darwin" }},
108+ {"pf-host-agent" , []string {"linux" }},
109+ {"cloudbeat" , []string {"linux" }},
110+ {"apm-server" , []string {"windows" , "linux" , "darwin" }},
111+ {"fleet-server" , []string {"windows" , "linux" , "darwin" }},
112+ {"pf-elastic-symbolizer" , []string {"linux" }},
113+ {"pf-elastic-collector" , []string {"linux" }},
114+ },
115+ []componentPresenceDefinition {},
116+ ),
117+ )
118+ }
119+
120+ func testDebLogIngestFleetManagedWithCheck (ctx context.Context , t * testing.T , agentFixture * atesting.Fixture , info * define.Info , installOpts atesting.InstallOpts , componentCheck func (t * testing.T )) {
121+
52122 // 1. Create a policy in Fleet with monitoring enabled.
53123 // To ensure there are no conflicts with previous test runs against
54124 // the same ESS stack, we add the current time at the end of the policy
@@ -70,10 +140,12 @@ func TestDebLogIngestFleetManaged(t *testing.T) {
70140 },
71141 }
72142
73- installOpts := atesting.InstallOpts {
74- NonInteractive : true ,
75- Force : true ,
76- }
143+ // remove flavor to start fresh, in case there is some leftover.
144+ _ = os .Remove ("/var/lib/elastic-agent/.flavor" )
145+ t .Cleanup (func () {
146+ // cleanup after ourselves
147+ _ = os .Remove ("/var/lib/elastic-agent/.flavor" )
148+ })
77149
78150 // 2. Install the Elastic-Agent with the policy that
79151 // was just created.
@@ -88,6 +160,10 @@ func TestDebLogIngestFleetManaged(t *testing.T) {
88160 t .Logf ("created policy: %s" , policy .ID )
89161 check .ConnectedToFleet (ctx , t , agentFixture , 5 * time .Minute )
90162
163+ if componentCheck != nil {
164+ t .Run ("check components set" , componentCheck )
165+ }
166+
91167 t .Run ("Monitoring logs are shipped" , func (t * testing.T ) {
92168 testMonitoringLogsAreShipped (t , ctx , info , agentFixture , policy )
93169 })
0 commit comments