From 9cd51af0222ae87fc3f2a0b4d09538d0726c800c Mon Sep 17 00:00:00 2001 From: Roberto Dip Date: Tue, 25 Apr 2023 10:05:57 -0300 Subject: [PATCH] fix flaky TestIntegrationsMDM/TestDEPProfileAssignment (#11304) This test was failing because we can send other commands when a DEP device is enrolling (eg: to install a bootstrap package) and the test was assuming that the first command we'll always get is the command to install `fleetd`. We have discussed in the past (@gillespi314 suggested that is important) increasing the accuracy of the timestamps in the `nano_commadns` table, which is the proper fix for this. --- server/service/integration_mdm_test.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/server/service/integration_mdm_test.go b/server/service/integration_mdm_test.go index 291ec0e7b8..588976e7a5 100644 --- a/server/service/integration_mdm_test.go +++ b/server/service/integration_mdm_test.go @@ -558,14 +558,18 @@ func (s *integrationMDMTestSuite) TestDEPProfileAssignment() { d.mdmEnroll(s) // make sure the host gets a request to install fleetd + var fleetdCmd *micromdm.CommandPayload cmd := d.idle() - require.NotNil(t, cmd) - require.NotNil(t, cmd.Command) - require.Equal(t, "InstallEnterpriseApplication", cmd.Command.RequestType) - require.NotNil(t, cmd.Command.InstallEnterpriseApplication) - // TODO: this seems flaky? - // require.NotNil(t, cmd.Command.InstallEnterpriseApplication.ManifestURL) - // require.Contains(t, *cmd.Command.InstallEnterpriseApplication.ManifestURL, apple_mdm.FleetdPublicManifestURL) + for cmd != nil { + if cmd.Command.RequestType == "InstallEnterpriseApplication" && + cmd.Command.InstallEnterpriseApplication.ManifestURL != nil && + strings.Contains(*cmd.Command.InstallEnterpriseApplication.ManifestURL, apple_mdm.FleetdPublicManifestURL) { + fleetdCmd = cmd + } + cmd = d.acknowledge(cmd.CommandUUID) + } + require.NotNil(t, fleetdCmd) + require.NotNil(t, fleetdCmd.Command) // only one shows up as pending listHostsRes = listHostsResponse{}