github.com/kyma-project/kyma-environment-broker@v0.0.1/cmd/broker/orchestration_test.go (about)

     1  package main
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/kyma-project/kyma-environment-broker/common/orchestration"
     8  )
     9  
    10  func TestKymaUpgrade_OneRuntimeHappyPath(t *testing.T) {
    11  	// given
    12  
    13  	suite := NewOrchestrationSuite(t, nil)
    14  	runtimeID := suite.CreateProvisionedRuntime(RuntimeOptions{})
    15  	otherRuntimeID := suite.CreateProvisionedRuntime(RuntimeOptions{})
    16  	orchestrationParams := fixOrchestrationParams(runtimeID)
    17  	orchestrationID := suite.CreateUpgradeKymaOrchestration(orchestrationParams)
    18  
    19  	suite.WaitForOrchestrationState(orchestrationID, orchestration.InProgress)
    20  
    21  	// when
    22  	suite.FinishUpgradeOperationByReconciler(runtimeID)
    23  
    24  	// then
    25  	suite.WaitForOrchestrationState(orchestrationID, orchestration.Succeeded)
    26  
    27  	suite.AssertRuntimeUpgraded(runtimeID, defaultKymaVer)
    28  	suite.AssertRuntimeNotUpgraded(otherRuntimeID)
    29  }
    30  
    31  func TestKymaUpgrade_VersionParameter(t *testing.T) {
    32  	// given
    33  	givenVersion := "2.0.0-rc5"
    34  	suite := NewOrchestrationSuite(t, []string{givenVersion})
    35  	runtimeID := suite.CreateProvisionedRuntime(RuntimeOptions{})
    36  	otherRuntimeID := suite.CreateProvisionedRuntime(RuntimeOptions{})
    37  	orchestrationParams := fixOrchestrationParams(runtimeID)
    38  	orchestrationParams.Kyma.Version = givenVersion
    39  	orchestrationID := suite.CreateUpgradeKymaOrchestration(orchestrationParams)
    40  
    41  	suite.WaitForOrchestrationState(orchestrationID, orchestration.InProgress)
    42  
    43  	// when
    44  	suite.FinishUpgradeOperationByReconciler(runtimeID)
    45  
    46  	// then
    47  	suite.WaitForOrchestrationState(orchestrationID, orchestration.Succeeded)
    48  
    49  	suite.AssertRuntimeUpgraded(runtimeID, givenVersion)
    50  	suite.AssertRuntimeNotUpgraded(otherRuntimeID)
    51  }
    52  
    53  func TestClusterUpgrade_OneRuntimeHappyPath(t *testing.T) {
    54  	// given
    55  	suite := NewOrchestrationSuite(t, nil)
    56  	runtimeID := suite.CreateProvisionedRuntime(RuntimeOptions{})
    57  	otherRuntimeID := suite.CreateProvisionedRuntime(RuntimeOptions{})
    58  	orchestrationParams := fixOrchestrationParams(runtimeID)
    59  	orchestrationID := suite.CreateUpgradeClusterOrchestration(orchestrationParams)
    60  
    61  	suite.WaitForOrchestrationState(orchestrationID, orchestration.InProgress)
    62  
    63  	// when
    64  	suite.FinishUpgradeShootOperationByProvisioner(runtimeID)
    65  
    66  	// then
    67  	suite.WaitForOrchestrationState(orchestrationID, orchestration.Succeeded)
    68  
    69  	suite.AssertShootUpgraded(runtimeID)
    70  	suite.AssertShootNotUpgraded(otherRuntimeID)
    71  }
    72  
    73  func fixOrchestrationParams(runtimeID string) orchestration.Parameters {
    74  	return orchestration.Parameters{
    75  		Targets: orchestration.TargetSpec{
    76  			Include: []orchestration.RuntimeTarget{
    77  				{RuntimeID: runtimeID},
    78  			},
    79  		},
    80  		Strategy: orchestration.StrategySpec{
    81  			Type:     orchestration.ParallelStrategy,
    82  			Schedule: time.Now().Format(time.RFC3339),
    83  			Parallel: orchestration.ParallelStrategySpec{Workers: 1},
    84  		},
    85  		DryRun:     false,
    86  		Kubernetes: &orchestration.KubernetesParameters{KubernetesVersion: ""},
    87  		Kyma:       &orchestration.KymaParameters{Version: ""},
    88  	}
    89  }