test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
// +build integration_provision
package provision
import (
"context"
2020-10-23 23:59:50 +03:00
"encoding/json"
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
"fmt"
"net"
"os"
"path/filepath"
"regexp"
2020-09-16 00:17:56 +03:00
"runtime"
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
"strings"
"time"
"github.com/stretchr/testify/suite"
2020-09-02 20:14:25 +03:00
"github.com/talos-systems/go-retry/retry"
2020-08-14 18:57:15 +03:00
talosnet "github.com/talos-systems/net"
2020-12-03 23:56:00 +03:00
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
2020-10-23 23:59:50 +03:00
corev1 "k8s.io/api/core/v1"
2020-09-07 23:36:42 +03:00
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020-10-23 23:59:50 +03:00
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/strategicpatch"
2020-08-14 18:57:15 +03:00
2020-03-20 17:38:48 -07:00
"github.com/talos-systems/talos/cmd/talosctl/pkg/mgmt/helpers"
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
"github.com/talos-systems/talos/internal/integration/base"
2020-08-12 00:05:35 +03:00
"github.com/talos-systems/talos/pkg/cluster/check"
2020-09-10 23:43:50 +03:00
"github.com/talos-systems/talos/pkg/cluster/kubernetes"
2020-09-07 23:36:42 +03:00
"github.com/talos-systems/talos/pkg/cluster/sonobuoy"
2020-09-25 07:27:20 -07:00
"github.com/talos-systems/talos/pkg/images"
2020-08-17 19:12:47 +03:00
machineapi "github.com/talos-systems/talos/pkg/machinery/api/machine"
talosclient "github.com/talos-systems/talos/pkg/machinery/client"
2020-09-07 23:36:42 +03:00
clientconfig "github.com/talos-systems/talos/pkg/machinery/client/config"
2020-08-17 19:12:47 +03:00
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1"
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1/bundle"
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1/generate"
"github.com/talos-systems/talos/pkg/machinery/config/types/v1alpha1/machine"
"github.com/talos-systems/talos/pkg/machinery/constants"
2020-08-12 00:05:35 +03:00
"github.com/talos-systems/talos/pkg/provision"
"github.com/talos-systems/talos/pkg/provision/access"
"github.com/talos-systems/talos/pkg/provision/providers/qemu"
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
)
type upgradeSpec struct {
ShortName string
SourceKernelPath string
SourceInitramfsPath string
SourceInstallerImage string
SourceVersion string
2020-09-10 23:43:50 +03:00
SourceK8sVersion string
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
TargetInstallerImage string
TargetVersion string
2020-09-07 23:36:42 +03:00
TargetK8sVersion string
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
MasterNodes int
WorkerNodes int
2020-03-24 21:20:36 +03:00
UpgradePreserve bool
2020-12-03 23:56:00 +03:00
UpgradeStage bool
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
}
const (
2020-11-18 00:30:50 +03:00
previousRelease = "v0.6.3"
2020-12-07 23:44:32 +03:00
stableRelease = "v0.7.1"
2020-09-07 23:36:42 +03:00
2020-11-18 00:30:50 +03:00
previousK8sVersion = "1.19.0"
stableK8sVersion = "1.19.4"
2020-12-09 15:56:58 +03:00
currentK8sVersion = "1.20.0"
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
)
var (
defaultNameservers = [ ] net . IP { net . ParseIP ( "8.8.8.8" ) , net . ParseIP ( "1.1.1.1" ) }
defaultCNIBinPath = [ ] string { "/opt/cni/bin" }
)
const (
defaultCNIConfDir = "/etc/cni/conf.d"
defaultCNICacheDir = "/var/lib/cni"
)
func trimVersion ( version string ) string {
// remove anything extra after semantic version core, `v0.3.2-1-abcd` -> `v0.3.2`
return regexp . MustCompile ( ` (-\d+-g[0-9a-f]+)$ ` ) . ReplaceAllString ( version , "" )
}
2020-06-30 17:25:53 +03:00
// upgradeBetweenTwoLastReleases upgrades between two last releases of Talos.
2020-05-19 00:10:38 +03:00
func upgradeBetweenTwoLastReleases ( ) upgradeSpec {
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
return upgradeSpec {
2020-11-18 00:30:50 +03:00
ShortName : fmt . Sprintf ( "%s-%s" , previousRelease , stableRelease ) ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
2020-11-18 00:30:50 +03:00
SourceKernelPath : helpers . ArtifactPath ( filepath . Join ( trimVersion ( previousRelease ) , constants . KernelAsset ) ) ,
SourceInitramfsPath : helpers . ArtifactPath ( filepath . Join ( trimVersion ( previousRelease ) , constants . InitramfsAsset ) ) ,
// TODO: update to images.DefaultInstallerImageRepository once previousRelease migrates to gchr.io
SourceInstallerImage : fmt . Sprintf ( "%s:%s" , "docker.io/autonomy/installer" , previousRelease ) ,
SourceVersion : previousRelease ,
SourceK8sVersion : previousK8sVersion ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
2020-11-18 00:30:50 +03:00
TargetInstallerImage : fmt . Sprintf ( "%s:%s" , "ghcr.io/talos-systems/installer" , stableRelease ) ,
TargetVersion : stableRelease ,
TargetK8sVersion : stableK8sVersion ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
MasterNodes : DefaultSettings . MasterNodes ,
WorkerNodes : DefaultSettings . WorkerNodes ,
}
}
2020-11-18 00:30:50 +03:00
// upgradeStableReleaseToCurrent upgrades last release to the current version of Talos.
func upgradeStableReleaseToCurrent ( ) upgradeSpec {
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
return upgradeSpec {
2020-11-18 00:30:50 +03:00
ShortName : fmt . Sprintf ( "%s-%s" , stableRelease , DefaultSettings . CurrentVersion ) ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
2020-11-18 00:30:50 +03:00
SourceKernelPath : helpers . ArtifactPath ( filepath . Join ( trimVersion ( stableRelease ) , constants . KernelAsset ) ) ,
SourceInitramfsPath : helpers . ArtifactPath ( filepath . Join ( trimVersion ( stableRelease ) , constants . InitramfsAsset ) ) ,
SourceInstallerImage : fmt . Sprintf ( "%s:%s" , "ghcr.io/talos-systems/installer" , stableRelease ) ,
SourceVersion : stableRelease ,
2020-10-23 23:59:50 +03:00
SourceK8sVersion : stableK8sVersion ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
2020-09-25 20:26:01 +03:00
TargetInstallerImage : fmt . Sprintf ( "%s/%s:%s" , DefaultSettings . TargetInstallImageRegistry , images . DefaultInstallerImageName , DefaultSettings . CurrentVersion ) ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
TargetVersion : DefaultSettings . CurrentVersion ,
2020-09-10 23:43:50 +03:00
TargetK8sVersion : currentK8sVersion ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
MasterNodes : DefaultSettings . MasterNodes ,
WorkerNodes : DefaultSettings . WorkerNodes ,
}
}
2020-05-19 00:10:38 +03:00
// upgradeSingeNodePreserve upgrade last release of Talos to the current version of Talos for single-node cluster with preserve.
2020-03-24 21:20:36 +03:00
func upgradeSingeNodePreserve ( ) upgradeSpec {
return upgradeSpec {
2020-11-18 00:30:50 +03:00
ShortName : fmt . Sprintf ( "preserve-%s-%s" , stableRelease , DefaultSettings . CurrentVersion ) ,
2020-03-24 21:20:36 +03:00
2020-11-18 00:30:50 +03:00
SourceKernelPath : helpers . ArtifactPath ( filepath . Join ( trimVersion ( stableRelease ) , constants . KernelAsset ) ) ,
SourceInitramfsPath : helpers . ArtifactPath ( filepath . Join ( trimVersion ( stableRelease ) , constants . InitramfsAsset ) ) ,
SourceInstallerImage : fmt . Sprintf ( "%s:%s" , "ghcr.io/talos-systems/installer" , stableRelease ) ,
SourceVersion : stableRelease ,
2020-10-23 23:59:50 +03:00
SourceK8sVersion : stableK8sVersion ,
2020-03-24 21:20:36 +03:00
2020-09-25 07:27:20 -07:00
TargetInstallerImage : fmt . Sprintf ( "%s/%s:%s" , DefaultSettings . TargetInstallImageRegistry , images . DefaultInstallerImageName , DefaultSettings . CurrentVersion ) ,
2020-03-24 21:20:36 +03:00
TargetVersion : DefaultSettings . CurrentVersion ,
2020-10-23 23:59:50 +03:00
TargetK8sVersion : stableK8sVersion , // TODO: looks like single-node can't upgrade k8s
2020-03-24 21:20:36 +03:00
MasterNodes : 1 ,
WorkerNodes : 0 ,
UpgradePreserve : true ,
}
}
2020-12-03 23:56:00 +03:00
// upgradeSingeNodeStage upgrade last release of Talos to the current version of Talos for single-node cluster with preserve and stage.
//
// TODO: this test should run same as upgradeSingleNodePreserve, but for now it runs between current and current version until we get a release.
func upgradeSingeNodeStage ( ) upgradeSpec {
return upgradeSpec {
ShortName : fmt . Sprintf ( "preserve-stage-%s-%s" , DefaultSettings . CurrentVersion , DefaultSettings . CurrentVersion ) ,
SourceKernelPath : helpers . ArtifactPath ( constants . KernelAssetWithArch ) ,
SourceInitramfsPath : helpers . ArtifactPath ( constants . InitramfsAssetWithArch ) ,
SourceInstallerImage : fmt . Sprintf ( "%s/%s:%s" , DefaultSettings . TargetInstallImageRegistry , images . DefaultInstallerImageName , DefaultSettings . CurrentVersion ) ,
SourceVersion : DefaultSettings . CurrentVersion ,
SourceK8sVersion : currentK8sVersion ,
TargetInstallerImage : fmt . Sprintf ( "%s/%s:%s" , DefaultSettings . TargetInstallImageRegistry , images . DefaultInstallerImageName , DefaultSettings . CurrentVersion ) ,
TargetVersion : DefaultSettings . CurrentVersion ,
TargetK8sVersion : currentK8sVersion ,
MasterNodes : 1 ,
WorkerNodes : 0 ,
UpgradePreserve : true ,
UpgradeStage : true ,
}
}
2020-10-19 21:18:25 +03:00
// UpgradeSuite ...
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
type UpgradeSuite struct {
suite . Suite
base . TalosSuite
specGen func ( ) upgradeSpec
spec upgradeSpec
2020-03-24 21:20:36 +03:00
track int
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
provisioner provision . Provisioner
configBundle * v1alpha1 . ConfigBundle
2020-11-23 18:13:17 +03:00
clusterAccess * access . Adapter
controlPlaneEndpoint string
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
ctx context . Context
ctxCancel context . CancelFunc
stateDir string
}
// SetupSuite ...
func ( suite * UpgradeSuite ) SetupSuite ( ) {
// call generate late in the flow, as it needs to pick up settings overridden by test runner
suite . spec = suite . specGen ( )
suite . T ( ) . Logf ( "upgrade spec = %v" , suite . spec )
// timeout for the whole test
suite . ctx , suite . ctxCancel = context . WithTimeout ( context . Background ( ) , 30 * time . Minute )
var err error
2020-07-30 21:44:10 +03:00
suite . provisioner , err = qemu . NewProvisioner ( suite . ctx )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
suite . Require ( ) . NoError ( err )
}
// TearDownSuite ...
func ( suite * UpgradeSuite ) TearDownSuite ( ) {
2020-10-23 23:59:50 +03:00
if suite . T ( ) . Failed ( ) && DefaultSettings . CrashdumpEnabled && suite . Cluster != nil {
2020-02-21 21:58:30 +03:00
// for failed tests, produce crash dump for easier debugging,
// as cluster is going to be torn down below
suite . provisioner . CrashDump ( suite . ctx , suite . Cluster , os . Stderr )
2020-03-24 21:20:36 +03:00
if suite . clusterAccess != nil {
suite . clusterAccess . CrashDump ( suite . ctx , os . Stderr )
}
2020-02-21 21:58:30 +03:00
}
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
if suite . clusterAccess != nil {
suite . Assert ( ) . NoError ( suite . clusterAccess . Close ( ) )
}
if suite . Cluster != nil {
suite . Assert ( ) . NoError ( suite . provisioner . Destroy ( suite . ctx , suite . Cluster ) )
}
suite . ctxCancel ( )
if suite . stateDir != "" {
suite . Assert ( ) . NoError ( os . RemoveAll ( suite . stateDir ) )
}
if suite . provisioner != nil {
suite . Assert ( ) . NoError ( suite . provisioner . Close ( ) )
}
}
2020-06-30 17:25:53 +03:00
// setupCluster provisions source clusters and waits for health.
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
func ( suite * UpgradeSuite ) setupCluster ( ) {
2020-10-23 23:59:50 +03:00
defaultStateDir , err := clientconfig . GetTalosDirectory ( )
suite . Require ( ) . NoError ( err )
suite . stateDir = filepath . Join ( defaultStateDir , "clusters" )
clusterName := suite . spec . ShortName
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
_ , cidr , err := net . ParseCIDR ( DefaultSettings . CIDR )
suite . Require ( ) . NoError ( err )
var gatewayIP net . IP
gatewayIP , err = talosnet . NthIPInNetwork ( cidr , 1 )
suite . Require ( ) . NoError ( err )
ips := make ( [ ] net . IP , suite . spec . MasterNodes + suite . spec . WorkerNodes )
for i := range ips {
ips [ i ] , err = talosnet . NthIPInNetwork ( cidr , i + 2 )
suite . Require ( ) . NoError ( err )
}
2020-10-19 21:18:25 +03:00
suite . T ( ) . Logf ( "initializing provisioner with cluster name %q, state directory %q" , clusterName , suite . stateDir )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
request := provision . ClusterRequest {
Name : clusterName ,
Network : provision . NetworkRequest {
Name : clusterName ,
CIDR : * cidr ,
GatewayAddr : gatewayIP ,
MTU : DefaultSettings . MTU ,
Nameservers : defaultNameservers ,
CNI : provision . CNIConfig {
BinPath : defaultCNIBinPath ,
ConfDir : defaultCNIConfDir ,
CacheDir : defaultCNICacheDir ,
} ,
} ,
KernelPath : suite . spec . SourceKernelPath ,
InitramfsPath : suite . spec . SourceInitramfsPath ,
2020-03-24 21:20:36 +03:00
SelfExecutable : suite . TalosctlPath ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
StateDirectory : suite . stateDir ,
}
2020-07-08 21:33:19 +03:00
defaultInternalLB , _ := suite . provisioner . GetLoadBalancers ( request . Network )
2020-11-23 18:13:17 +03:00
suite . controlPlaneEndpoint = fmt . Sprintf ( "https://%s:%d" , defaultInternalLB , constants . DefaultControlPlanePort )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
genOptions := suite . provisioner . GenOptions ( request . Network )
for _ , registryMirror := range DefaultSettings . RegistryMirrors {
parts := strings . SplitN ( registryMirror , "=" , 2 )
suite . Require ( ) . Len ( parts , 2 )
genOptions = append ( genOptions , generate . WithRegistryMirror ( parts [ 0 ] , parts [ 1 ] ) )
}
2020-07-08 21:33:19 +03:00
masterEndpoints := make ( [ ] string , suite . spec . MasterNodes )
for i := range masterEndpoints {
masterEndpoints [ i ] = ips [ i ] . String ( )
}
2020-09-07 23:36:42 +03:00
if DefaultSettings . CustomCNIURL != "" {
genOptions = append ( genOptions , generate . WithClusterCNIConfig ( & v1alpha1 . CNIConfig {
CNIName : "custom" ,
CNIUrls : [ ] string { DefaultSettings . CustomCNIURL } ,
} ) )
}
2020-07-28 21:48:26 +03:00
suite . configBundle , err = bundle . NewConfigBundle ( bundle . WithInputOptions (
& bundle . InputOptions {
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
ClusterName : clusterName ,
2020-11-23 18:13:17 +03:00
Endpoint : suite . controlPlaneEndpoint ,
2020-06-25 23:39:20 +03:00
KubeVersion : "" , // keep empty so that default version is used per Talos version
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
GenOptions : append (
genOptions ,
2020-07-08 21:33:19 +03:00
generate . WithEndpointList ( masterEndpoints ) ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
generate . WithInstallImage ( suite . spec . SourceInstallerImage ) ,
2020-09-07 23:36:42 +03:00
generate . WithDNSDomain ( "cluster.local" ) ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
) ,
} ) )
suite . Require ( ) . NoError ( err )
for i := 0 ; i < suite . spec . MasterNodes ; i ++ {
request . Nodes = append ( request . Nodes ,
provision . NodeRequest {
Name : fmt . Sprintf ( "master-%d" , i + 1 ) ,
2020-11-09 23:10:19 +03:00
Type : machine . TypeControlPlane ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
IP : ips [ i ] ,
Memory : DefaultSettings . MemMB * 1024 * 1024 ,
NanoCPUs : DefaultSettings . CPUs * 1000 * 1000 * 1000 ,
2020-10-29 19:19:31 +03:00
Disks : [ ] * provision . Disk {
{
Size : DefaultSettings . DiskGB * 1024 * 1024 * 1024 ,
} ,
} ,
Config : suite . configBundle . ControlPlane ( ) ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
} )
}
for i := 1 ; i <= suite . spec . WorkerNodes ; i ++ {
request . Nodes = append ( request . Nodes ,
provision . NodeRequest {
Name : fmt . Sprintf ( "worker-%d" , i ) ,
2020-11-09 23:10:19 +03:00
Type : machine . TypeJoin ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
IP : ips [ suite . spec . MasterNodes + i - 1 ] ,
Memory : DefaultSettings . MemMB * 1024 * 1024 ,
NanoCPUs : DefaultSettings . CPUs * 1000 * 1000 * 1000 ,
2020-10-29 19:19:31 +03:00
Disks : [ ] * provision . Disk {
{
Size : DefaultSettings . DiskGB * 1024 * 1024 * 1024 ,
} ,
} ,
Config : suite . configBundle . Join ( ) ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
} )
}
2020-07-29 19:39:47 +03:00
suite . Cluster , err = suite . provisioner . Create ( suite . ctx , request , provision . WithBootlader ( true ) , provision . WithTalosConfig ( suite . configBundle . TalosConfig ( ) ) )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
suite . Require ( ) . NoError ( err )
2020-09-07 23:36:42 +03:00
defaultTalosConfig , err := clientconfig . GetDefaultPath ( )
suite . Require ( ) . NoError ( err )
c , err := clientconfig . Open ( defaultTalosConfig )
suite . Require ( ) . NoError ( err )
c . Merge ( suite . configBundle . TalosConfig ( ) )
suite . Require ( ) . NoError ( c . Save ( defaultTalosConfig ) )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
suite . clusterAccess = access . NewAdapter ( suite . Cluster , provision . WithTalosConfig ( suite . configBundle . TalosConfig ( ) ) )
2020-10-23 23:59:50 +03:00
suite . Require ( ) . NoError ( suite . clusterAccess . Bootstrap ( suite . ctx , os . Stdout ) )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
suite . waitForClusterHealth ( )
}
2020-06-30 17:25:53 +03:00
// waitForClusterHealth asserts cluster health after any change.
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
func ( suite * UpgradeSuite ) waitForClusterHealth ( ) {
checkCtx , checkCtxCancel := context . WithTimeout ( suite . ctx , 10 * time . Minute )
defer checkCtxCancel ( )
suite . Require ( ) . NoError ( check . Wait ( checkCtx , suite . clusterAccess , check . DefaultClusterChecks ( ) , check . StderrReporter ( ) ) )
}
2020-09-07 23:36:42 +03:00
// runE2E runs e2e test on the cluster.
func ( suite * UpgradeSuite ) runE2E ( k8sVersion string ) {
2020-10-23 23:59:50 +03:00
if suite . spec . WorkerNodes == 0 {
// no worker nodes, should make masters schedulable
suite . untaint ( "master-1" )
}
2020-09-07 23:36:42 +03:00
options := sonobuoy . DefaultOptions ( )
options . KubernetesVersion = k8sVersion
suite . Assert ( ) . NoError ( sonobuoy . Run ( suite . ctx , suite . clusterAccess , options ) )
}
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
func ( suite * UpgradeSuite ) assertSameVersionCluster ( client * talosclient . Client , expectedVersion string ) {
nodes := make ( [ ] string , len ( suite . Cluster . Info ( ) . Nodes ) )
for i , node := range suite . Cluster . Info ( ) . Nodes {
nodes [ i ] = node . PrivateIP . String ( )
}
ctx := talosclient . WithNodes ( suite . ctx , nodes ... )
var v * machineapi . VersionResponse
err := retry . Constant (
time . Minute ,
) . Retry ( func ( ) error {
var e error
v , e = client . Version ( ctx )
return retry . ExpectedError ( e )
} )
suite . Require ( ) . NoError ( err )
suite . Require ( ) . Len ( v . Messages , len ( nodes ) )
for _ , version := range v . Messages {
suite . Assert ( ) . Equal ( expectedVersion , version . Version . Tag )
}
}
2020-10-19 21:18:25 +03:00
func ( suite * UpgradeSuite ) readVersion ( nodeCtx context . Context , client * talosclient . Client ) ( version string , err error ) {
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
var v * machineapi . VersionResponse
v , err = client . Version ( nodeCtx )
if err != nil {
return
}
version = v . Messages [ 0 ] . Version . Tag
return
}
func ( suite * UpgradeSuite ) upgradeNode ( client * talosclient . Client , node provision . NodeInfo ) {
suite . T ( ) . Logf ( "upgrading node %s" , node . PrivateIP )
nodeCtx := talosclient . WithNodes ( suite . ctx , node . PrivateIP . String ( ) )
2020-12-03 23:56:00 +03:00
resp , err := client . Upgrade ( nodeCtx , suite . spec . TargetInstallerImage , suite . spec . UpgradePreserve , suite . spec . UpgradeStage )
if err != nil {
if s , ok := status . FromError ( err ) ; ok && s . Code ( ) == codes . Unavailable {
// ignore errors if reboot happens before response is fully received
err = nil
}
}
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
suite . Require ( ) . NoError ( err )
2020-12-03 23:56:00 +03:00
if resp != nil {
suite . Require ( ) . Equal ( "Upgrade request received" , resp . Messages [ 0 ] . Ack )
}
// wait for the upgrade to be kicked off
time . Sleep ( 10 * time . Second )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
// wait for the version to be equal to target version
2020-07-30 22:59:13 +03:00
suite . Require ( ) . NoError ( retry . Constant ( 10 * time . Minute ) . Retry ( func ( ) error {
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
var version string
2020-10-19 21:18:25 +03:00
version , err = suite . readVersion ( nodeCtx , client )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
if err != nil {
// API might be unresponsive during upgrade
return retry . ExpectedError ( err )
}
if version != suite . spec . TargetVersion {
// upgrade not finished yet
return retry . ExpectedError ( fmt . Errorf ( "node %q version doesn't match expected: expected %q, got %q" , node . PrivateIP . String ( ) , suite . spec . TargetVersion , version ) )
}
return nil
} ) )
suite . waitForClusterHealth ( )
}
2020-09-10 23:43:50 +03:00
func ( suite * UpgradeSuite ) upgradeKubernetes ( fromVersion , toVersion string ) {
if fromVersion == toVersion {
suite . T ( ) . Logf ( "skipping Kubernetes upgrade, as versions are equal %q -> %q" , fromVersion , toVersion )
return
}
suite . T ( ) . Logf ( "upgrading Kubernetes: %q -> %q" , fromVersion , toVersion )
2020-11-23 18:13:17 +03:00
suite . Require ( ) . NoError ( kubernetes . Upgrade ( suite . ctx , suite . clusterAccess , kubernetes . UpgradeOptions {
FromVersion : fromVersion ,
ToVersion : toVersion ,
Architecture : runtime . GOARCH ,
ControlPlaneEndpoint : suite . controlPlaneEndpoint ,
} ) )
2020-09-10 23:43:50 +03:00
}
2020-10-23 23:59:50 +03:00
func ( suite * UpgradeSuite ) untaint ( name string ) {
client , err := suite . clusterAccess . K8sClient ( suite . ctx )
suite . Require ( ) . NoError ( err )
n , err := client . CoreV1 ( ) . Nodes ( ) . Get ( suite . ctx , name , metav1 . GetOptions { } )
suite . Require ( ) . NoError ( err )
oldData , err := json . Marshal ( n )
suite . Require ( ) . NoError ( err )
k := 0
for _ , taint := range n . Spec . Taints {
if taint . Key != constants . LabelNodeRoleMaster {
n . Spec . Taints [ k ] = taint
k ++
}
}
n . Spec . Taints = n . Spec . Taints [ : k ]
newData , err := json . Marshal ( n )
suite . Require ( ) . NoError ( err )
patchBytes , err := strategicpatch . CreateTwoWayMergePatch ( oldData , newData , corev1 . Node { } )
suite . Require ( ) . NoError ( err )
_ , err = client . CoreV1 ( ) . Nodes ( ) . Patch ( suite . ctx , n . Name , types . StrategicMergePatchType , patchBytes , metav1 . PatchOptions { } )
suite . Require ( ) . NoError ( err )
}
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
// TestRolling performs rolling upgrade starting with master nodes.
func ( suite * UpgradeSuite ) TestRolling ( ) {
suite . setupCluster ( )
client , err := suite . clusterAccess . Client ( )
suite . Require ( ) . NoError ( err )
// verify initial cluster version
suite . assertSameVersionCluster ( client , suite . spec . SourceVersion )
2020-09-10 23:43:50 +03:00
// upgrade Kubernetes if required
suite . upgradeKubernetes ( suite . spec . SourceK8sVersion , suite . spec . TargetK8sVersion )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
// upgrade master nodes
for _ , node := range suite . Cluster . Info ( ) . Nodes {
2020-07-28 21:48:26 +03:00
if node . Type == machine . TypeInit || node . Type == machine . TypeControlPlane {
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
suite . upgradeNode ( client , node )
}
}
// upgrade worker nodes
for _ , node := range suite . Cluster . Info ( ) . Nodes {
2020-07-28 21:48:26 +03:00
if node . Type == machine . TypeJoin {
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
suite . upgradeNode ( client , node )
}
}
// verify final cluster version
suite . assertSameVersionCluster ( client , suite . spec . TargetVersion )
2020-09-07 23:36:42 +03:00
// run e2e test
suite . runE2E ( suite . spec . TargetK8sVersion )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
}
// SuiteName ...
func ( suite * UpgradeSuite ) SuiteName ( ) string {
if suite . spec . ShortName == "" {
suite . spec = suite . specGen ( )
}
2020-03-24 21:20:36 +03:00
return fmt . Sprintf ( "provision.UpgradeSuite.%s-TR%d" , suite . spec . ShortName , suite . track )
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
}
func init ( ) {
allSuites = append ( allSuites ,
2020-05-19 00:10:38 +03:00
& UpgradeSuite { specGen : upgradeBetweenTwoLastReleases , track : 0 } ,
2020-11-18 00:30:50 +03:00
& UpgradeSuite { specGen : upgradeStableReleaseToCurrent , track : 1 } ,
2020-10-23 23:59:50 +03:00
& UpgradeSuite { specGen : upgradeSingeNodePreserve , track : 0 } ,
2020-12-03 23:56:00 +03:00
& UpgradeSuite { specGen : upgradeSingeNodeStage , track : 1 } ,
test: implement new class of tests: provision tests (upgrades)
This class of tests is included/excluded by build tags, but as it is
pretty different from other integration tests, we build it as separate
executable. Provision tests provision cluster for the test run, perform
some actions and verify results (could be upgrade, reset, scale up/down,
etc.)
There's now framework to implement upgrade tests, first of the tests
tests upgrade from latest 0.3 (0.3.2 at the moment) to current version
of Talos (being built in CI). Tests starts by booting with 0.3
kernel/initramfs, runs 0.3 installer to install 0.3.2 cluster, wait for
bootstrap, followed by upgrade to 0.4 in rolling fashion. As Firecracker
supports bootloader, this boots 0.4 system from boot disk (as installed
by installer).
Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-02-18 01:00:51 +03:00
)
}