mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 17:08:53 +00:00
Fixing flaky software tests. (#19069)
Attempt to fix the flaky software tests. Because the insert order of software is now not deterministic.
This commit is contained in:
parent
185ec23ee2
commit
f87906b1d1
3 changed files with 40 additions and 16 deletions
|
|
@ -8689,8 +8689,11 @@ func testHostHealth(t *testing.T, ds *Datastore) {
|
|||
require.NoError(t, ds.LoadHostSoftware(context.Background(), h, false))
|
||||
|
||||
soft1 := h.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = h.Software[1]
|
||||
for _, item := range h.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
cpes := []fleet.SoftwareCPE{{SoftwareID: soft1.ID, CPE: "somecpe"}}
|
||||
|
|
@ -8700,8 +8703,11 @@ func testHostHealth(t *testing.T, ds *Datastore) {
|
|||
// Reload software so that 'GeneratedCPEID is set.
|
||||
require.NoError(t, ds.LoadHostSoftware(context.Background(), h, false))
|
||||
soft1 = h.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = h.Software[1]
|
||||
for _, item := range h.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
inserted, err := ds.InsertSoftwareVulnerability(
|
||||
|
|
|
|||
|
|
@ -725,8 +725,11 @@ func (s *integrationTestSuite) TestVulnerableSoftware() {
|
|||
require.NoError(t, s.ds.LoadHostSoftware(context.Background(), host, false))
|
||||
|
||||
soft1 := host.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = host.Software[1]
|
||||
for _, item := range host.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
cpes := []fleet.SoftwareCPE{{SoftwareID: soft1.ID, CPE: "somecpe"}}
|
||||
|
|
@ -736,8 +739,11 @@ func (s *integrationTestSuite) TestVulnerableSoftware() {
|
|||
// Reload software so that 'GeneratedCPEID is set.
|
||||
require.NoError(t, s.ds.LoadHostSoftware(context.Background(), host, false))
|
||||
soft1 = host.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = host.Software[1]
|
||||
for _, item := range host.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
inserted, err := s.ds.InsertSoftwareVulnerability(
|
||||
|
|
@ -10862,8 +10868,11 @@ func (s *integrationTestSuite) TestHostHealth() {
|
|||
require.NoError(t, s.ds.LoadHostSoftware(context.Background(), host, false))
|
||||
|
||||
soft1 := host.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = host.Software[1]
|
||||
for _, item := range host.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
cpes := []fleet.SoftwareCPE{{SoftwareID: soft1.ID, CPE: "somecpe"}}
|
||||
|
|
@ -10873,8 +10882,11 @@ func (s *integrationTestSuite) TestHostHealth() {
|
|||
// Reload software so that 'GeneratedCPEID is set.
|
||||
require.NoError(t, s.ds.LoadHostSoftware(context.Background(), host, false))
|
||||
soft1 = host.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = host.Software[1]
|
||||
for _, item := range host.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
inserted, err := s.ds.InsertSoftwareVulnerability(
|
||||
|
|
|
|||
|
|
@ -7054,8 +7054,11 @@ func (s *integrationEnterpriseTestSuite) TestAllSoftwareTitles() {
|
|||
require.NoError(t, s.ds.LoadHostSoftware(context.Background(), host, false))
|
||||
|
||||
soft1 := host.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = host.Software[1]
|
||||
for _, item := range host.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
cpes := []fleet.SoftwareCPE{{SoftwareID: soft1.ID, CPE: "somecpe"}}
|
||||
|
|
@ -7065,8 +7068,11 @@ func (s *integrationEnterpriseTestSuite) TestAllSoftwareTitles() {
|
|||
// Reload software so that 'GeneratedCPEID is set.
|
||||
require.NoError(t, s.ds.LoadHostSoftware(context.Background(), host, false))
|
||||
soft1 = host.Software[0]
|
||||
if soft1.Name != "bar" {
|
||||
soft1 = host.Software[1]
|
||||
for _, item := range host.Software {
|
||||
if item.Name == "bar" {
|
||||
soft1 = item
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
inserted, err := s.ds.InsertSoftwareVulnerability(
|
||||
|
|
|
|||
Loading…
Reference in a new issue