mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
d4be5ad2a1
* add upgrade tests * fix lint issues go.mod * remove req.cnf * revert unrelated changes * make version configurable in test * fix golangci-lint ruleguard issue Related to https://github.com/go-critic/go-critic/issues/1152 Need to have github.com/quasilyte/go-ruleguard/dsl * fix lint issues * fix * clean up docker-compose.yml * fix http request * add readme * fix lint issues * address feedback * fix * add platform * address feedback * run go fmt
58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
package upgrade
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func enrollHost(t *testing.T, f *Fleet) string {
|
|
client, err := f.Client()
|
|
require.NoError(t, err)
|
|
|
|
// enroll a host
|
|
hostname, err := f.StartHost()
|
|
require.NoError(t, err)
|
|
|
|
// wait until host is enrolled and software is listed
|
|
require.Eventually(t, func() bool {
|
|
host, err := client.HostByIdentifier(hostname)
|
|
if err != nil {
|
|
t.Logf("get host: %v", err)
|
|
return false
|
|
}
|
|
|
|
if len(host.Software) == 0 {
|
|
return false
|
|
}
|
|
|
|
return true
|
|
}, 5*time.Minute, 5*time.Second)
|
|
|
|
return hostname
|
|
}
|
|
|
|
func TestUpgradeAToB(t *testing.T) {
|
|
versionA := os.Getenv("FLEET_VERSION_A")
|
|
if versionA == "" {
|
|
t.Skip("Missing environment variable FLEET_VERSION_A")
|
|
}
|
|
|
|
versionB := os.Getenv("FLEET_VERSION_B")
|
|
if versionB == "" {
|
|
t.Skip("Missing environment variable FLEET_VERSION_B")
|
|
}
|
|
|
|
f := NewFleet(t, versionA)
|
|
|
|
enrollHost(t, f)
|
|
|
|
err := f.Upgrade(versionB)
|
|
require.NoError(t, err)
|
|
|
|
// enroll another host with the new version
|
|
enrollHost(t, f)
|
|
}
|