fix: properly set up provider for autoprovision tests
Some checks are pending
default / default (push) Waiting to run
default / e2e-backups (push) Blocked by required conditions
default / e2e-forced-removal (push) Blocked by required conditions
default / e2e-scaling (push) Blocked by required conditions
default / e2e-short (push) Blocked by required conditions
default / e2e-short-secureboot (push) Blocked by required conditions
default / e2e-templates (push) Blocked by required conditions
default / e2e-upgrades (push) Blocked by required conditions
default / e2e-workload-proxy (push) Blocked by required conditions

The change which introduced multiple infra provider configs support in
the tests has broken the case when there's auto provisioning without
pre-allocated machines.

Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
This commit is contained in:
Artem Chernyshev 2024-11-12 20:28:22 +03:00
parent 05ab993d3d
commit e4586f4a34
No known key found for this signature in database
GPG Key ID: E084A2DF1143C14D
2 changed files with 14 additions and 5 deletions

View File

@ -57,8 +57,7 @@ var rootCmd = &cobra.Command{
ScalingTimeout: rootCmdFlags.scalingTimeout,
}
switch {
case rootCmdFlags.provisionConfigFile != "":
if rootCmdFlags.provisionConfigFile != "" {
f, err := os.Open(rootCmdFlags.provisionConfigFile)
if err != nil {
return fmt.Errorf("failed to open provision config file %q: %w", rootCmdFlags.provisionConfigFile, err)
@ -79,7 +78,7 @@ var rootCmd = &cobra.Command{
testOptions.ProvisionConfigs = append(testOptions.ProvisionConfigs, cfg)
}
case rootCmdFlags.provisionMachinesCount != 0:
} else {
testOptions.ProvisionConfigs = append(testOptions.ProvisionConfigs,
tests.MachineProvisionConfig{
MachineCount: rootCmdFlags.provisionMachinesCount,

View File

@ -88,6 +88,16 @@ func (o Options) defaultProviderData() string {
return o.ProvisionConfigs[0].Provider.Data
}
func (o Options) provisionMachines() bool {
var totalMachineCount int
for _, cfg := range o.ProvisionConfigs {
totalMachineCount += cfg.MachineCount
}
return totalMachineCount > 0
}
// MachineProvisionConfig tells the test to provision machines from the infra provider.
type MachineProvisionConfig struct {
Provider MachineProviderConfig `yaml:"provider"`
@ -1362,7 +1372,7 @@ Test flow of cluster creation and scaling using cluster templates.`,
preRunTests := []testing.InternalTest{}
if len(options.ProvisionConfigs) != 0 {
if options.provisionMachines() {
for i, cfg := range options.ProvisionConfigs {
preRunTests = append(preRunTests, testing.InternalTest{
Name: "AssertMachinesShouldBeProvisioned",
@ -1385,7 +1395,7 @@ Test flow of cluster creation and scaling using cluster templates.`,
postRunTests := []testing.InternalTest{}
if len(options.ProvisionConfigs) != 0 {
if options.provisionMachines() {
for i := range options.ProvisionConfigs {
postRunTests = append(postRunTests, testing.InternalTest{
Name: "AssertMachinesShouldBeDeprovisioned",