From fe75f58770a326c465c3fba8b543aae3c6a2776d Mon Sep 17 00:00:00 2001 From: Trey West Date: Tue, 21 May 2024 12:41:29 -0400 Subject: [PATCH] Add unit tests for agentclusterinstall --- pkg/assisted/agentclusterinstall.go | 46 +- pkg/assisted/agentclusterinstall_test.go | 1191 ++++++++++++++++++++++ pkg/assisted/testdata/aci_events.json | 525 ++++++++++ pkg/clients/clients.go | 2 + 4 files changed, 1750 insertions(+), 14 deletions(-) create mode 100644 pkg/assisted/agentclusterinstall_test.go create mode 100644 pkg/assisted/testdata/aci_events.json diff --git a/pkg/assisted/agentclusterinstall.go b/pkg/assisted/agentclusterinstall.go index 725dad2e2..08ef5ea32 100644 --- a/pkg/assisted/agentclusterinstall.go +++ b/pkg/assisted/agentclusterinstall.go @@ -23,6 +23,10 @@ import ( goclient "sigs.k8s.io/controller-runtime/pkg/client" ) +var ( + eventsTransport http.RoundTripper +) + // AgentClusterInstallBuilder provides struct for the agentclusterinstall object containing connection to // the cluster and the agentclusterinstall definitions. type AgentClusterInstallBuilder struct { @@ -204,6 +208,10 @@ func (builder *AgentClusterInstallBuilder) WithControlPlaneAgents(agentCount int return builder } + if agentCount <= 0 { + builder.errorMsg = "agentclusterinstall controlplane agents must be greater than 0" + } + builder.Definition.Spec.ProvisionRequirements.ControlPlaneAgents = agentCount return builder @@ -215,6 +223,10 @@ func (builder *AgentClusterInstallBuilder) WithWorkerAgents(agentCount int) *Age return builder } + if agentCount < 0 { + builder.errorMsg = "agentclusterinstall worker agents cannot be less that 0" + } + builder.Definition.Spec.ProvisionRequirements.WorkerAgents = agentCount return builder @@ -264,7 +276,13 @@ func (builder *AgentClusterInstallBuilder) WithAdditionalClusterNetwork( if _, _, err := net.ParseCIDR(cidr); err != nil { glog.V(100).Infof("The agentclusterinstall passed invalid clusterNetwork cidr: %s", cidr) - builder.errorMsg = "Got invalid cidr for clusternetwork" + builder.errorMsg = "agentclusterinstall contains invalid clusterNetwork cidr" + } + + if prefix <= 0 { + glog.V(100).Infof("Agentclusterinstall passed invalid clusterNetwork prefix: %s", cidr) + + builder.errorMsg = "agentclusterinstall contains invalid clusterNetwork prefix" } if builder.errorMsg != "" { @@ -287,7 +305,7 @@ func (builder *AgentClusterInstallBuilder) WithAdditionalServiceNetwork(cidr str if _, _, err := net.ParseCIDR(cidr); err != nil { glog.V(100).Infof("The agentclusterinstall passed invalid serviceNetwork cidr: %s", cidr) - builder.errorMsg = "Got invalid cidr for servicenetwork" + builder.errorMsg = "agentclusterinstall contains invalid serviceNetwork cidr" } if builder.errorMsg != "" { @@ -385,7 +403,7 @@ func (builder *AgentClusterInstallBuilder) WithOptions( func (builder *AgentClusterInstallBuilder) WaitForConditionMessage( conditionType, message string, timeout time.Duration) error { return wait.PollUntilContextTimeout( - context.TODO(), retryInterval, timeout, false, func(ctx context.Context) (bool, error) { + context.TODO(), retryInterval, timeout, true, func(ctx context.Context) (bool, error) { condition, err := builder.getCondition(conditionType) if err != nil { return false, err @@ -399,7 +417,7 @@ func (builder *AgentClusterInstallBuilder) WaitForConditionMessage( func (builder *AgentClusterInstallBuilder) WaitForConditionStatus( conditionType string, status corev1.ConditionStatus, timeout time.Duration) error { return wait.PollUntilContextTimeout( - context.TODO(), retryInterval, timeout, false, func(ctx context.Context) (bool, error) { + context.TODO(), retryInterval, timeout, true, func(ctx context.Context) (bool, error) { condition, err := builder.getCondition(conditionType) if err != nil { return false, err @@ -436,9 +454,13 @@ func (builder *AgentClusterInstallBuilder) GetEvents(skipCertVerify bool) (model return nil, fmt.Errorf("cannot get events from non-existent agentclusterinstall") } - client := http.Client{Transport: &http.Transport{ - TLSClientConfig: &tls.Config{ - InsecureSkipVerify: skipCertVerify}}} + if eventsTransport == nil { + eventsTransport = &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: skipCertVerify}} + } + + client := http.Client{Transport: eventsTransport} glog.V(100).Infof("Getting events from url: %s", builder.Object.Status.DebugInfo.EventsURL) @@ -512,13 +534,13 @@ func PullAgentClusterInstall(apiClient *clients.Settings, name, nsname string) ( if name == "" { glog.V(100).Infof("The name of the agentclusterinstall is empty") - builder.errorMsg = "agentclusterinstall 'name' cannot be empty" + return nil, fmt.Errorf("agentclusterinstall 'name' cannot be empty") } if nsname == "" { glog.V(100).Infof("The namespace of the agentclusterinstall is empty") - builder.errorMsg = "agentclusterinstall 'namespace' cannot be empty" + return nil, fmt.Errorf("agentclusterinstall 'namespace' cannot be empty") } if !builder.Exists() { @@ -560,11 +582,7 @@ func (builder *AgentClusterInstallBuilder) Update(force bool) (*AgentClusterInst builder.Definition.Name, builder.Definition.Namespace) if !builder.Exists() { - builder.errorMsg = "Cannot update non-existent agentclusterinstall" - } - - if builder.errorMsg != "" { - return nil, fmt.Errorf(builder.errorMsg) + return nil, fmt.Errorf("cannot update non-existent agentclusterinstall") } err := builder.apiClient.Update(context.TODO(), builder.Definition) diff --git a/pkg/assisted/agentclusterinstall_test.go b/pkg/assisted/agentclusterinstall_test.go new file mode 100644 index 000000000..e0d353916 --- /dev/null +++ b/pkg/assisted/agentclusterinstall_test.go @@ -0,0 +1,1191 @@ +package assisted + +import ( + "errors" + "fmt" + "net/http" + "os" + "testing" + "time" + + "github.com/openshift-kni/eco-goinfra/pkg/clients" + hiveextV1Beta1 "github.com/openshift/assisted-service/api/hiveextension/v1beta1" + v1 "github.com/openshift/hive/apis/hive/v1" + "github.com/stretchr/testify/assert" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + fakeRuntimeClient "sigs.k8s.io/controller-runtime/pkg/client/fake" +) + +const ( + aciTestName = "aci-test-name" + aciTestNamespace = "aci-test-namespace" +) + +func TestNewAgentClusterInstallBuilder(t *testing.T) { + testCases := []struct { + name string + namespace string + clusterDeployment string + masterCount int + workerCount int + network hiveextV1Beta1.Networking + client bool + expectedError string + }{ + { + name: aciTestName, + namespace: aciTestNamespace, + clusterDeployment: "aci-test-clusterdeployment", + masterCount: 3, + workerCount: 2, + network: dummyTestNetwork(), + client: true, + expectedError: "", + }, + { + name: "", + namespace: aciTestNamespace, + clusterDeployment: "aci-test-clusterdeployment", + masterCount: 3, + workerCount: 2, + network: dummyTestNetwork(), + client: true, + expectedError: "agentclusterinstall 'name' cannot be empty", + }, + { + name: aciTestName, + namespace: "", + clusterDeployment: "aci-test-clusterdeployment", + masterCount: 3, + workerCount: 2, + network: dummyTestNetwork(), + client: true, + expectedError: "agentclusterinstall 'namespace' cannot be empty", + }, + { + name: aciTestName, + namespace: aciTestNamespace, + clusterDeployment: "", + masterCount: 3, + workerCount: 2, + network: dummyTestNetwork(), + client: true, + expectedError: "agentclusterinstall 'clusterDeployment' cannot be empty", + }, + { + name: aciTestName, + namespace: aciTestNamespace, + clusterDeployment: "aci-test-clusterdeployment", + masterCount: 3, + workerCount: 2, + network: dummyTestNetwork(), + client: false, + expectedError: "", + }, + } + + for _, testcase := range testCases { + var testSettings *clients.Settings + if testcase.client { + testSettings = clients.GetTestClients(clients.TestClientParams{}) + } + + testBuilder := NewAgentClusterInstallBuilder( + testSettings, testcase.name, testcase.namespace, testcase.clusterDeployment, + testcase.masterCount, testcase.workerCount, testcase.network) + + if testcase.client { + assert.NotNil(t, testBuilder) + assert.Equal(t, testcase.expectedError, testBuilder.errorMsg) + assert.Equal(t, testcase.name, testBuilder.Definition.Name) + assert.Equal(t, testcase.namespace, testBuilder.Definition.Namespace) + assert.Equal(t, testcase.clusterDeployment, testBuilder.Definition.Spec.ClusterDeploymentRef.Name) + assert.Equal(t, testcase.masterCount, testBuilder.Definition.Spec.ProvisionRequirements.ControlPlaneAgents) + assert.Equal(t, testcase.workerCount, testBuilder.Definition.Spec.ProvisionRequirements.WorkerAgents) + assert.Equal(t, testcase.network, testBuilder.Definition.Spec.Networking) + } else { + assert.Nil(t, testBuilder) + } + } +} + +func TestPullAgentClusterInstall(t *testing.T) { + testCases := []struct { + name string + namespace string + client bool + exists bool + expectedError error + }{ + { + name: aciTestName, + namespace: aciTestNamespace, + client: true, + exists: true, + expectedError: nil, + }, + { + name: "", + namespace: aciTestNamespace, + client: true, + exists: true, + expectedError: errors.New("agentclusterinstall 'name' cannot be empty"), + }, + { + name: aciTestName, + namespace: "", + client: true, + exists: true, + expectedError: errors.New("agentclusterinstall 'namespace' cannot be empty"), + }, + { + name: aciTestName, + namespace: aciTestNamespace, + client: false, + exists: true, + expectedError: errors.New("the apiClient is nil"), + }, + { + name: aciTestName, + namespace: aciTestNamespace, + client: true, + exists: false, + expectedError: errors.New("agentclusterinstall object aci-test-name does not exist in namespace aci-test-namespace"), + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + testSettings *clients.Settings + ) + + if testCase.exists { + runtimeObjects = append(runtimeObjects, generateAgentClusterInstall()) + } + + if testCase.client { + testSettings = clients.GetTestClients(clients.TestClientParams{K8sMockObjects: runtimeObjects}) + } + + testBuilder, err := PullAgentClusterInstall(testSettings, testCase.name, testCase.namespace) + assert.Equal(t, err, testCase.expectedError) + + if testCase.expectedError != nil { + assert.Nil(t, testBuilder) + } else { + assert.Equal(t, testCase.name, testBuilder.Object.Name) + assert.Equal(t, testCase.name, testBuilder.Definition.Name) + assert.Equal(t, testCase.namespace, testBuilder.Object.Namespace) + assert.Equal(t, testCase.namespace, testBuilder.Definition.Namespace) + } + } +} + +func TestAgentClusterInstallCreate(t *testing.T) { + testCases := []struct { + exists bool + }{ + { + exists: true, + }, + { + exists: false, + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + if testCase.exists { + runtimeObjects = append(runtimeObjects, generateAgentClusterInstall()) + } + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + result, err := testBuilder.Create() + assert.Nil(t, err) + assert.NotNil(t, result) + assert.Equal(t, aciTestName, result.Definition.Name) + assert.Equal(t, aciTestNamespace, result.Definition.Namespace) + } +} + +func TestAgentClusterInstallDelete(t *testing.T) { + testCases := []struct { + exists bool + expectedError error + }{ + { + exists: true, + expectedError: nil, + }, + { + exists: false, + expectedError: errors.New("agentclusterinstall cannot be deleted because it does not exist"), + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + if testCase.exists { + runtimeObjects = append(runtimeObjects, generateAgentClusterInstall()) + } + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + err := testBuilder.Delete() + assert.Equal(t, testCase.expectedError, err) + + if testCase.expectedError == nil { + assert.Nil(t, testBuilder.Object) + } + } +} + +func TestAgentClusterInstallDeleteAndWait(t *testing.T) { + testCases := []struct { + exists bool + expectedError error + }{ + { + exists: true, + expectedError: nil, + }, + { + exists: false, + expectedError: errors.New("agentclusterinstall cannot be deleted because it does not exist"), + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + if testCase.exists { + runtimeObjects = append(runtimeObjects, generateAgentClusterInstall()) + } + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + err := testBuilder.DeleteAndWait(time.Second * 1) + assert.Equal(t, testCase.expectedError, err) + + if testCase.expectedError == nil { + assert.Nil(t, testBuilder.Object) + } + } +} + +func TestAgentClusterInstallGet(t *testing.T) { + testCases := []struct { + exists bool + }{ + { + exists: true, + }, + { + exists: false, + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + if testCase.exists { + runtimeObjects = append(runtimeObjects, generateAgentClusterInstall()) + } + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + aci, err := testBuilder.Get() + if testCase.exists { + assert.Nil(t, err) + assert.NotNil(t, aci) + } else { + assert.NotNil(t, err) + assert.Nil(t, aci) + } + } +} + +func TestAgentClusterInstallExists(t *testing.T) { + testCases := []struct { + exists bool + }{ + { + exists: true, + }, + { + exists: false, + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + if testCase.exists { + runtimeObjects = append(runtimeObjects, generateAgentClusterInstall()) + } + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + assert.Equal(t, testCase.exists, testBuilder.Exists()) + } +} + +func TestAgentClusterInstallUpdate(t *testing.T) { + testCases := []struct { + exists bool + expectedError error + }{ + { + exists: true, + expectedError: nil, + }, + { + exists: false, + expectedError: errors.New("cannot update non-existent agentclusterinstall"), + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + if testCase.exists { + runtimeObjects = append(runtimeObjects, generateAgentClusterInstall()) + } + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + testBuilder.Definition.Spec.ProvisionRequirements.WorkerAgents = 5 + + aci, err := testBuilder.Update(true) + assert.Equal(t, testCase.expectedError, err) + + if testCase.expectedError == nil { + assert.Equal(t, aci.Object.Spec.ProvisionRequirements.WorkerAgents, 5) + } + } +} + +func TestAgentClusterInstallWithOptions(t *testing.T) { + testCases := []struct { + option AgentClusterInstallAdditionalOptions + validator func(*AgentClusterInstallBuilder) bool + expectedError string + }{ + { + option: func(builder *AgentClusterInstallBuilder) (*AgentClusterInstallBuilder, error) { + builder.Definition.Spec.HoldInstallation = true + + return builder, nil + }, + validator: func(acib *AgentClusterInstallBuilder) bool { + return acib.Definition.Spec.HoldInstallation == true + }, + expectedError: "", + }, + { + option: func(builder *AgentClusterInstallBuilder) (*AgentClusterInstallBuilder, error) { + builder.Definition.Spec.IgnitionEndpoint = &hiveextV1Beta1.IgnitionEndpoint{ + Url: "https://some.ign.endpoint.com", + } + + return builder, nil + }, + validator: func(acib *AgentClusterInstallBuilder) bool { + + return acib.Definition.Spec.IgnitionEndpoint.Url == "https://some.ign.endpoint.com" + }, + expectedError: "", + }, + { + option: func(builder *AgentClusterInstallBuilder) (*AgentClusterInstallBuilder, error) { + + return builder, fmt.Errorf("agentclusterinstallbuilder contains error") + }, + validator: func(acib *AgentClusterInstallBuilder) bool { + + return acib.errorMsg != "" + }, + expectedError: "agentclusterinstallbuilder contains error", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + + testBuilder.WithOptions(testCase.option) + assert.Equal(t, testCase.expectedError, testBuilder.errorMsg) + assert.True(t, testCase.validator(testBuilder)) + } +} + +func TestAgentClusterInstallWithApiVip(t *testing.T) { + testCases := []struct { + ip string + expectError string + }{ + { + ip: "192.168.1.5", + expectError: "", + }, + { + ip: "fd2e::5", + expectError: "", + }, + { + ip: "notanip", + expectError: "agentclusterinstall apiVIP incorrectly formatted", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithAPIVip(testCase.ip) + assert.Equal(t, testCase.expectError, testBuilder.errorMsg) + + if testCase.expectError == "" { + assert.Equal(t, testCase.ip, testBuilder.Definition.Spec.APIVIP) + } + } +} +func TestAgentClusterInstallWithAdditionalApiVip(t *testing.T) { + testCases := []struct { + ip string + expectError string + }{ + { + ip: "192.168.1.5", + expectError: "", + }, + { + ip: "fd2e::5", + expectError: "", + }, + { + ip: "notanip", + expectError: "agentclusterinstall apiVIP incorrectly formatted", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithAdditionalAPIVip(testCase.ip) + assert.Equal(t, testCase.expectError, testBuilder.errorMsg) + + if testCase.expectError == "" { + assert.Contains(t, testBuilder.Definition.Spec.APIVIPs, testCase.ip) + } + } +} + +func TestAgentClusterInstallWithIngressVip(t *testing.T) { + testCases := []struct { + ip string + expectError string + }{ + { + ip: "192.168.1.10", + expectError: "", + }, + { + ip: "fd2e::10", + expectError: "", + }, + { + ip: "notanip", + expectError: "agentclusterinstall ingressVIP incorrectly formatted", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithIngressVip(testCase.ip) + assert.Equal(t, testCase.expectError, testBuilder.errorMsg) + + if testCase.expectError == "" { + assert.Equal(t, testCase.ip, testBuilder.Definition.Spec.IngressVIP) + } + } +} +func TestAgentClusterInstallWithAdditionalIngressVip(t *testing.T) { + testCases := []struct { + ip string + expectError string + }{ + { + ip: "192.168.1.10", + expectError: "", + }, + { + ip: "fd2e::10", + expectError: "", + }, + { + ip: "notanip", + expectError: "agentclusterinstall ingressVIP incorrectly formatted", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithAdditionalIngressVip(testCase.ip) + assert.Equal(t, testCase.expectError, testBuilder.errorMsg) + + if testCase.expectError == "" { + assert.Contains(t, testBuilder.Definition.Spec.IngressVIPs, testCase.ip) + } + } +} +func TestAgentClusterInstallWithUserManagedNetworking(t *testing.T) { + testCases := []struct { + umn bool + }{ + { + umn: true, + }, + { + umn: false, + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithUserManagedNetworking(testCase.umn) + + assert.Equal(t, testCase.umn, *testBuilder.Definition.Spec.Networking.UserManagedNetworking) + } +} +func TestAgentClusterInstallWithPlatformType(t *testing.T) { + testCases := []struct { + platform hiveextV1Beta1.PlatformType + }{ + { + platform: "BareMetal", + }, + { + platform: "None", + }, + { + platform: "VSphere", + }, + { + platform: "Nutanix", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithPlatformType(testCase.platform) + + assert.Equal(t, testCase.platform, testBuilder.Definition.Spec.PlatformType) + } +} +func TestAgentClusterInstallWithControlPlaneAgents(t *testing.T) { + testCases := []struct { + count int + expectedError string + }{ + { + count: 3, + expectedError: "", + }, + { + count: 1, + expectedError: "", + }, + { + count: 0, + expectedError: "agentclusterinstall controlplane agents must be greater than 0", + }, + { + count: -1, + expectedError: "agentclusterinstall controlplane agents must be greater than 0", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithControlPlaneAgents(testCase.count) + + assert.Equal(t, testCase.expectedError, testBuilder.errorMsg) + assert.Equal(t, testCase.count, testBuilder.Definition.Spec.ProvisionRequirements.ControlPlaneAgents) + } +} + +func TestAgentClusterInstallWithImageSet(t *testing.T) { + testCases := []struct { + image string + expectedError string + }{ + { + image: "4.16", + expectedError: "", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithImageSet(testCase.image) + + assert.Equal(t, testCase.expectedError, testBuilder.errorMsg) + assert.Equal(t, testCase.image, testBuilder.Definition.Spec.ImageSetRef.Name) + } +} + +func TestAgentClusterInstallWithWorkerAgents(t *testing.T) { + testCases := []struct { + count int + expectedError string + }{ + { + count: 3, + expectedError: "", + }, + { + count: 1, + expectedError: "", + }, + { + count: 0, + expectedError: "", + }, + { + count: -1, + expectedError: "agentclusterinstall worker agents cannot be less that 0", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithWorkerAgents(testCase.count) + + assert.Equal(t, testCase.expectedError, testBuilder.errorMsg) + assert.Equal(t, testCase.count, testBuilder.Definition.Spec.ProvisionRequirements.WorkerAgents) + } +} + +//nolint:lll +func TestAgentClusterInstallWithSSHPublicKey(t *testing.T) { + testCases := []struct { + sshKey string + }{ + { + sshKey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCaX4UsUhbLbeTGx6wob/6Y2qQzBDi2VhjFaFGugNk9zuNgPB4Um4VNa8TgRr/nrJxLWduuM0gbBgAA9719cCV6FsTq6e0TTrtFAy498vNrE1gyCp8gX2/+60NWwjeK3iglVym0WxmXhWpZCPk6EBsBQgclt6iQhVH20f60lWAD6+8I5iXCm5u63HNEzuTmJUVaVCEU62zamwwJUR+6yddnu+rIrLqw7xYuuATKMBuL+AUnB3zR08qv65Tyhf/YpyjlW/w7kCFwTsE0Xrbtumd1irF49DiY4Xb5WGPRTjrhVhzpAvtvEhfrMGGnbwnQ0P1pUTAQz8eYKSN4M0oxaGPObtjkEM4EAjBo5vyzN1xi9H/tekOQCmVDY2XOCVvIuxUPgq/8Uc3oGkoh3Eay+KSRIhQC3+kqXX889H//SmENoejIAxnETXPnVygKMaoJbh2d44RjIC5LkJsNSwcK24+hv4VU0uJjwXMPPE5YTUxcVPukATd4i22FOSiIL/ULuos=", + }, + { + sshKey: "", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithSSHPublicKey(testCase.sshKey) + + assert.Equal(t, testCase.sshKey, testBuilder.Definition.Spec.SSHPublicKey) + } +} +func TestAgentClusterInstallWithNetworkType(t *testing.T) { + testCases := []struct { + network string + }{ + { + network: "OpenShiftSDN", + }, + { + network: "OVNKubernetes", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithNetworkType(testCase.network) + + assert.Equal(t, testCase.network, testBuilder.Definition.Spec.Networking.NetworkType) + } +} +func TestAgentClusterInstallWithAdditionalClusterNetwork(t *testing.T) { + testCases := []struct { + cidr string + prefix int32 + expectedError string + }{ + { + cidr: "10.128.0.0/14", + prefix: 23, + expectedError: "", + }, + { + cidr: "10.128.0.0", + prefix: 23, + expectedError: "agentclusterinstall contains invalid clusterNetwork cidr", + }, + { + cidr: "10.128.0.0/14", + prefix: 0, + expectedError: "agentclusterinstall contains invalid clusterNetwork prefix", + }, + { + cidr: "10.128.0.0/14", + prefix: -1, + expectedError: "agentclusterinstall contains invalid clusterNetwork prefix", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithAdditionalClusterNetwork(testCase.cidr, testCase.prefix) + assert.Equal(t, testCase.expectedError, testBuilder.errorMsg) + + if testCase.expectedError == "" { + assert.Equal(t, testCase.cidr, testBuilder.Definition.Spec.Networking.ClusterNetwork[1].CIDR) + assert.Equal(t, testCase.prefix, testBuilder.Definition.Spec.Networking.ClusterNetwork[1].HostPrefix) + } + } +} + +func TestAgentClusterInstallWithAdditionalServiceNetwork(t *testing.T) { + testCases := []struct { + cidr string + expectedError string + }{ + { + cidr: "172.30.0.0/16", + expectedError: "", + }, + { + cidr: "", + expectedError: "agentclusterinstall contains invalid serviceNetwork cidr", + }, + { + cidr: "172.30.0.0/162", + expectedError: "agentclusterinstall contains invalid serviceNetwork cidr", + }, + } + + for _, testCase := range testCases { + testBuilder := generateAgentClusterInstallTestBuilder() + testBuilder.WithAdditionalServiceNetwork(testCase.cidr) + assert.Equal(t, testCase.expectedError, testBuilder.errorMsg) + + if testCase.expectedError == "" { + assert.Equal(t, testCase.cidr, testBuilder.Definition.Spec.Networking.ServiceNetwork[1]) + } + } +} +func TestAgentClusterInstallWaitForState(t *testing.T) { + testCases := []struct { + status hiveextV1Beta1.AgentClusterInstallStatus + state string + }{ + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + DebugInfo: hiveextV1Beta1.DebugInfo{ + State: "adding-hosts", + }, + }, + state: "adding-hosts", + }, + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + DebugInfo: hiveextV1Beta1.DebugInfo{ + State: "installing", + }, + }, + state: "installing", + }, + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + DebugInfo: hiveextV1Beta1.DebugInfo{ + State: "finalizing", + }, + }, + state: "finalizing", + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + testACI := generateAgentClusterInstall() + testACI.Status = testCase.status + + runtimeObjects = append(runtimeObjects, testACI) + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + aci, err := testBuilder.WaitForState(testCase.state, time.Second*2) + + assert.Nil(t, err) + assert.NotNil(t, aci) + } +} +func TestAgentClusterInstallWaitForStateInfo(t *testing.T) { + testCases := []struct { + status hiveextV1Beta1.AgentClusterInstallStatus + info string + }{ + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + DebugInfo: hiveextV1Beta1.DebugInfo{ + StateInfo: "Cluster is installed", + }, + }, + info: "Cluster is installed", + }, + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + DebugInfo: hiveextV1Beta1.DebugInfo{ + StateInfo: "Cluster is finalizing", + }, + }, + info: "Cluster is finalizing", + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + testACI := generateAgentClusterInstall() + testACI.Status = testCase.status + + runtimeObjects = append(runtimeObjects, testACI) + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + aci, err := testBuilder.WaitForStateInfo(testCase.info, time.Second*2) + + assert.Nil(t, err) + assert.NotNil(t, aci) + } +} + +func TestAgentClusterInstallWaitForConditionMessage(t *testing.T) { + testCases := []struct { + status hiveextV1Beta1.AgentClusterInstallStatus + conditionType string + message string + }{ + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + Conditions: []v1.ClusterInstallCondition{ + { + Type: "Stopped", + Status: corev1.ConditionTrue, + Reason: "InstallationCompleted", + Message: "The installation has stopped because it completed successfully", + }, + }, + }, + conditionType: "Stopped", + message: "The installation has stopped because it completed successfully", + }, + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + Conditions: []v1.ClusterInstallCondition{ + { + Type: "SpecSynced", + Status: corev1.ConditionTrue, + Reason: "SyncOK", + Message: "SyncOK", + }, + }, + }, + conditionType: "SpecSynced", + message: "SyncOK", + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + testACI := generateAgentClusterInstall() + testACI.Status = testCase.status + + runtimeObjects = append(runtimeObjects, testACI) + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + err := testBuilder.WaitForConditionMessage(testCase.conditionType, testCase.message, time.Second*5) + + assert.Nil(t, err) + } +} +func TestAgentClusterInstallWaitForConditionStatus(t *testing.T) { + testCases := []struct { + status hiveextV1Beta1.AgentClusterInstallStatus + conditionType string + conditionStatus corev1.ConditionStatus + }{ + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + Conditions: []v1.ClusterInstallCondition{ + { + Type: "Stopped", + Status: corev1.ConditionTrue, + Reason: "InstallationCompleted", + Message: "The installation has stopped because it completed successfully", + }, + }, + }, + conditionType: "Stopped", + conditionStatus: corev1.ConditionTrue, + }, + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + Conditions: []v1.ClusterInstallCondition{ + { + Type: "Failed", + Status: corev1.ConditionFalse, + Reason: "InstallationNotFailed", + Message: "The installation has not failed", + }, + }, + }, + conditionType: "Failed", + conditionStatus: corev1.ConditionFalse, + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + testACI := generateAgentClusterInstall() + testACI.Status = testCase.status + + runtimeObjects = append(runtimeObjects, testACI) + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + err := testBuilder.WaitForConditionStatus(testCase.conditionType, testCase.conditionStatus, time.Second*2) + + assert.Nil(t, err) + } +} +func TestAgentClusterInstallWaitForConditionReason(t *testing.T) { + testCases := []struct { + status hiveextV1Beta1.AgentClusterInstallStatus + conditionType string + reason string + }{ + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + Conditions: []v1.ClusterInstallCondition{ + { + Type: "Stopped", + Status: corev1.ConditionTrue, + Reason: "InstallationCompleted", + Message: "The installation has stopped because it completed successfully", + }, + }, + }, + conditionType: "Stopped", + reason: "InstallationCompleted", + }, + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + Conditions: []v1.ClusterInstallCondition{ + { + Type: "Failed", + Status: corev1.ConditionFalse, + Reason: "InstallationNotFailed", + Message: "The installation has not failed", + }, + }, + }, + conditionType: "Failed", + reason: "InstallationNotFailed", + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + testACI := generateAgentClusterInstall() + testACI.Status = testCase.status + + runtimeObjects = append(runtimeObjects, testACI) + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + err := testBuilder.WaitForConditionReason(testCase.conditionType, testCase.reason, time.Second*2) + + assert.Nil(t, err) + } +} +func TestAgentClusterInstallGetEvents(t *testing.T) { + path, err := os.Getwd() + assert.Nil(t, err) + + testCases := []struct { + status hiveextV1Beta1.AgentClusterInstallStatus + }{ + { + status: hiveextV1Beta1.AgentClusterInstallStatus{ + DebugInfo: hiveextV1Beta1.DebugInfo{ + EventsURL: fmt.Sprintf("file://%s/testdata/aci_events.json", path), + }, + }, + }, + } + + for _, testCase := range testCases { + var ( + runtimeObjects []runtime.Object + ) + + transport := &http.Transport{} + transport.RegisterProtocol("file", http.NewFileTransport(http.Dir("/"))) + eventsTransport = transport + + testACI := generateAgentClusterInstall() + testACI.Status = testCase.status + + runtimeObjects = append(runtimeObjects, testACI) + + testBuilder := buildTestBuilderWithFakeObjects(runtimeObjects) + + events, err := testBuilder.GetEvents(true) + + assert.Nil(t, err) + assert.NotNil(t, events) + assert.Len(t, events, 63) + } +} + +func TestAgentClusterInstallValidate(t *testing.T) { + testCases := []struct { + builderNil bool + definitionNil bool + apiClientNil bool + expectedError string + }{ + { + builderNil: true, + definitionNil: false, + apiClientNil: false, + expectedError: "error: received nil AgentClusterInstall builder", + }, + { + builderNil: false, + definitionNil: true, + apiClientNil: false, + expectedError: "can not redefine the undefined AgentClusterInstall", + }, + { + builderNil: false, + definitionNil: false, + apiClientNil: true, + expectedError: "AgentClusterInstall builder cannot have nil apiClient", + }, + { + builderNil: false, + definitionNil: false, + apiClientNil: false, + expectedError: "", + }, + } + + for _, testCase := range testCases { + testBuilder := buildTestBuilderWithFakeObjects([]runtime.Object{}) + + if testCase.builderNil { + testBuilder = nil + } + + if testCase.definitionNil { + testBuilder.Definition = nil + } + + if testCase.apiClientNil { + testBuilder.apiClient = nil + } + + result, err := testBuilder.validate() + if testCase.expectedError != "" { + assert.NotNil(t, err) + assert.Equal(t, testCase.expectedError, err.Error()) + assert.False(t, result) + } else { + assert.Nil(t, err) + assert.True(t, result) + } + } +} + +func dummyTestNetwork() hiveextV1Beta1.Networking { + return hiveextV1Beta1.Networking{ + ClusterNetwork: []hiveextV1Beta1.ClusterNetworkEntry{{ + CIDR: "10.128.0.0/14", + HostPrefix: 23, + }}, + ServiceNetwork: []string{"172.30.0.0/16"}, + } +} + +func buildTestBuilderWithFakeObjects(objects []runtime.Object) *AgentClusterInstallBuilder { + fakeClientScheme := runtime.NewScheme() + + err := clients.SetScheme(fakeClientScheme) + if err != nil { + return nil + } + + testBuilder := NewAgentClusterInstallBuilder(&clients.Settings{ + Client: fakeRuntimeClient.NewClientBuilder().WithScheme(fakeClientScheme).WithRuntimeObjects(objects...).Build(), + }, aciTestName, aciTestNamespace, "aci-test-clusterdeployment", 3, 2, dummyTestNetwork()) + + return testBuilder +} + +func generateAgentClusterInstallTestBuilder() *AgentClusterInstallBuilder { + return &AgentClusterInstallBuilder{ + apiClient: clients.GetTestClients(clients.TestClientParams{}).Client, + Definition: generateAgentClusterInstall(), + } +} + +func generateAgentClusterInstall() *hiveextV1Beta1.AgentClusterInstall { + return &hiveextV1Beta1.AgentClusterInstall{ + ObjectMeta: metav1.ObjectMeta{ + Name: aciTestName, + Namespace: aciTestNamespace, + }, + Spec: hiveextV1Beta1.AgentClusterInstallSpec{ + ClusterDeploymentRef: corev1.LocalObjectReference{ + Name: aciTestName, + }, + Networking: dummyTestNetwork(), + ProvisionRequirements: hiveextV1Beta1.ProvisionRequirements{ + ControlPlaneAgents: 3, + WorkerAgents: 2, + }, + }, + } +} diff --git a/pkg/assisted/testdata/aci_events.json b/pkg/assisted/testdata/aci_events.json new file mode 100644 index 000000000..866e20d64 --- /dev/null +++ b/pkg/assisted/testdata/aci_events.json @@ -0,0 +1,525 @@ +[ + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:38:21.396Z", + "message": "Successfully registered cluster", + "name": "cluster_registration_succeeded", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:38:29.976Z", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Updated image information (Image type is \"minimal-iso\", SSH public key is set)", + "name": "image_info_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:39:13.297Z", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Updated image information (Image type is \"minimal-iso\", SSH public key is set)", + "name": "image_info_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:44:52.559Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host f8adf340-e9d4-47e2-bb3a-43c7256ab571: Successfully registered", + "name": "host_registration_succeeded", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:44:59.755Z", + "message": "Cluster validation 'all-hosts-are-ready-to-install' that used to succeed is now failing", + "name": "cluster_validation_failed", + "severity": "warning" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:44:59.756Z", + "message": "Cluster validation 'sufficient-masters-count' is now fixed", + "name": "cluster_validation_fixed", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:44:59.757Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata.example.com: updated status from discovering to insufficient (Host cannot be installed due to following failing validation(s): Host couldn't synchronize with any NTP server)", + "name": "host_status_updated", + "severity": "warning" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:45:55.762Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: updated status from insufficient to known (Host is ready to be installed)", + "name": "host_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:45:59.754Z", + "message": "Cluster validation 'all-hosts-are-ready-to-install' is now fixed", + "name": "cluster_validation_fixed", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:45:59.765Z", + "message": "Updated status of the cluster to ready", + "name": "cluster_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:45:59.807Z", + "message": "Updated status of the cluster to preparing-for-installation", + "name": "cluster_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:46:03.757Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: updated status from known to preparing-for-installation (Host finished successfully to prepare for installation)", + "name": "host_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:11.601Z", + "message": "Cluster starting to prepare for installation", + "name": "cluster_prepare_installation_started", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:14.290Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: New image status quay.io/openshift-release-dev/ocp-release@sha256:b584f5458fb946115b0cf0f1793dc9224c5e6a4567e74018f0590805a03eb523. result: success. time: 8.71 seconds; size: 501.79 Megabytes; download rate: 60.41 MBps", + "name": "image_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:14.295Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: New image status quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a125f282c98a565bc89e93db70163991514f058f379ed8045bc6d01ea643798d. result: success. time: 3.85 seconds; size: 632.05 Megabytes; download rate: 172.16 MBps", + "name": "image_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:14.299Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: New image status quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:07a68ac8ce683916b782d190aaa06f05d408802349b83f259386cb6ca837bfcb. result: success. time: 3.28 seconds; size: 602.62 Megabytes; download rate: 192.52 MBps", + "name": "image_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:14.301Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: New image status registry.redhat.io/multicluster-engine/assisted-installer-rhel8@sha256:751e6ea48be4ba2c931cda65418cb26638d3f44b36ccca4c41ced07a081ba7d3. result: success. time: 3.75 seconds; size: 192.15 Megabytes; download rate: 53.70 MBps", + "name": "image_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:15.755Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: updated status from preparing-for-installation to preparing-successful (Host finished successfully to prepare for installation)", + "name": "host_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:19.760Z", + "message": "Updated status of the cluster to installing", + "name": "cluster_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:23.755Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: updated status from preparing-successful to installing (Installation is in progress)", + "name": "host_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:54.612Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: updated status from installing to installing-in-progress (Starting installation)", + "name": "host_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:54.615Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Starting installation: bootstrap", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:47:54.732Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Installing: bootstrap", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:48:00.514Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Waiting for bootkube", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:26.315Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:28.379Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 5%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:30.379Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 11%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:34.379Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 17%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:41.385Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 22%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:45.386Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 29%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:47.387Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 35%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:50.386Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 40%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:52.386Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 46%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:54.386Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 51%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:56.387Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 56%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:51:59.390Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 61%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:03.393Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 66%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:06.399Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 72%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:11.404Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 77%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:15.405Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 83%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:18.406Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 90%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:20.406Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 95%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:23.933Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Writing image to disk: 100%", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:26.100Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Uploaded logs for host testdata cluster bacfcadc-8d32-4eba-a18b-6587962f98ad", + "name": "host_logs_uploaded", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:52:26.394Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Rebooting: Ironic will reboot the node shortly", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:55:37.148Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Joined", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:57:37.160Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: updated status from installing-in-progress to installed (Done)", + "name": "host_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:57:37.165Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host: testdata, reached installation stage Done", + "name": "host_install_progress_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:57:39.756Z", + "message": "Updated status of the cluster to finalizing", + "name": "cluster_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:57:49.900Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Node testdata has been rebooted 2 times before completing installation", + "name": "reboots_for_node", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:58:07.152Z", + "message": "Updated finalizing stage of the cluster to 'Waiting for cluster operators'", + "name": "cluster_finalizing_stage_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:58:07.167Z", + "message": "Operator console status: progressing message: ", + "name": "cluster_operator_status", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T19:58:07.177Z", + "message": "Operator cvo status: failed message: ", + "name": "cluster_operator_status", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:00:37.189Z", + "message": "Uploaded logs for the cluster", + "name": "cluster_logs_uploaded", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:10:07.247Z", + "message": "Operator console status: progressing message: SyncLoopRefreshProgressing: Working toward version x.y.z, 0 replicas available", + "name": "cluster_operator_status", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:13:07.215Z", + "message": "Operator console status: available message: All is well", + "name": "cluster_operator_status", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:18:07.233Z", + "message": "Operator cvo status: available message: Done applying x.y.z", + "name": "cluster_operator_status", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:18:07.308Z", + "message": "Updated finalizing stage of the cluster to 'Adding router ca'", + "name": "cluster_finalizing_stage_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:18:07.333Z", + "message": "Updated finalizing stage of the cluster to 'Waiting for olm operators csv initialization'", + "name": "cluster_finalizing_stage_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:18:07.344Z", + "message": "Updated finalizing stage of the cluster to 'Done'", + "name": "cluster_finalizing_stage_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:18:09.755Z", + "message": "Updated status of the cluster to installed", + "name": "cluster_status_updated", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:18:09.756Z", + "message": "Successfully completed installing cluster", + "name": "cluster_installation_completed", + "severity": "info" + }, + { + "cluster_id": "bacfcadc-8d32-4eba-a18b-6587962f98ad", + "event_time": "2024-05-20T20:18:11.754Z", + "host_id": "f8adf340-e9d4-47e2-bb3a-43c7256ab571", + "infra_env_id": "d666d596-0885-4525-8d68-b40e61d0a5ed", + "message": "Host testdata: validation 'api-int-domain-name-resolved-correctly' that used to succeed is now failing", + "name": "host_validation_failed", + "severity": "warning" + } + ] \ No newline at end of file diff --git a/pkg/clients/clients.go b/pkg/clients/clients.go index e19d866ee..99d3dd365 100644 --- a/pkg/clients/clients.go +++ b/pkg/clients/clients.go @@ -505,6 +505,8 @@ func GetTestClients(tcp TestClientParams) *Settings { genericClientObjects = append(genericClientObjects, v) case *eskv1.Elasticsearch: genericClientObjects = append(genericClientObjects, v) + case *hiveextV1Beta1.AgentClusterInstall: + genericClientObjects = append(genericClientObjects, v) // ArgoCD Client Objects case *argocdOperatorv1alpha1.ArgoCD: genericClientObjects = append(genericClientObjects, v)