Skip to content

Commit

Permalink
Merge pull request #81 from markusewalker/markus/task-1643
Browse files Browse the repository at this point in the history
Automate private registry tests that are done for release testing
  • Loading branch information
markusewalker authored Jan 27, 2025
2 parents 1947888 + 2cff2b8 commit 52387c7
Show file tree
Hide file tree
Showing 62 changed files with 1,191 additions and 459 deletions.
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ARG RANCHER2_KEY_PATH
ARG RKE_KEY_PATH
ARG SANITY_KEY_PATH
ARG AIRGAP_KEY_PATH
ARG REGISTRY_KEY_PATH

ENV QASE_TEST_RUN_ID=${QASE_TEST_RUN_ID}
ENV TERRAFORM_VERSION=${TERRAFORM_VERSION}
Expand All @@ -38,6 +39,7 @@ ENV RANCHER2_KEY_PATH=${RANCHER2_KEY_PATH}
ENV RKE_KEY_PATH=${RKE_KEY_PATH}
ENV SANITY_KEY_PATH=${SANITY_KEY_PATH}
ENV AIRGAP_KEY_PATH=${AIRGAP_KEY_PATH}
ENV REGISTRY_KEY_PATH=${REGISTRY_KEY_PATH}

RUN wget https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -q && apt-get update > /dev/null && apt-get install unzip > /dev/null && \
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip > /dev/null && \
Expand Down
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RANCHER2_KEY_PATH="${RANCHER2_KEY_PATH:-}"
RKE_KEY_PATH="${RKE_KEY_PATH:-}"
SANITY_KEY_PATH="${SANITY_KEY_PATH:-}"
AIRGAP_KEY_PATH="${AIRGAP_KEY_PATH:-}"
REGISTRY_KEY_PATH="${REGISTRY_KEY_PATH:-}"

TRIM_JOB_NAME=$(basename "$JOB_NAME")

Expand All @@ -35,6 +36,7 @@ while [[ 3 -gt $count ]]; do
--build-arg RKE_KEY_PATH="$RKE_KEY_PATH" \
--build-arg SANITY_KEY_PATH="$SANITY_KEY_PATH" \
--build-arg AIRGAP_KEY_PATH="$AIRGAP_KEY_PATH" \
--build-arg REGISTRY_KEY_PATH="$REGISTRY_KEY_PATH" \
--build-arg EXTERNAL_ENCODED_VPN="$EXTERNAL_ENCODED_VPN" \
--build-arg VPN_ENCODED_LOGIN="$VPN_ENCODED_LOGIN" \
-t tfp-automation-validation-"${TRIM_JOB_NAME}""${BUILD_NUMBER}"
Expand Down
7 changes: 7 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ var WorkerNodePool = Nodepool{
Quantity: 1,
}

var AllRolesNodePool = Nodepool{
Etcd: true,
Controlplane: true,
Worker: true,
Quantity: 1,
}

var ScaleUpEtcdNodePool = Nodepool{
Etcd: true,
Controlplane: false,
Expand Down
35 changes: 18 additions & 17 deletions config/nodeproviders/aws/awsConfig.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package aws

type Config struct {
AMI string `json:"ami,omitempty" yaml:"ami,omitempty"`
AWSInstanceType string `json:"awsInstanceType,omitempty" yaml:"awsInstanceType,omitempty"`
AWSKeyName string `json:"awsKeyName,omitempty" yaml:"awsKeyName,omitempty"`
AWSRootSize int64 `json:"awsRootSize,omitempty" yaml:"awsRootSize,omitempty"`
AWSSecurityGroupNames []string `json:"awsSecurityGroupNames,omitempty" yaml:"awsSecurityGroupNames,omitempty"`
AWSSecurityGroups []string `json:"awsSecurityGroups,omitempty" yaml:"awsSecurityGroups,omitempty"`
AWSSubnetID string `json:"awsSubnetID,omitempty" yaml:"awsSubnetID,omitempty"`
AWSSubnets []string `json:"awsSubnets,omitempty" yaml:"awsSubnets,omitempty"`
AWSVpcID string `json:"awsVpcID,omitempty" yaml:"awsVpcID,omitempty"`
AWSRoute53Zone string `json:"awsRoute53Zone,omitempty" yaml:"awsRoute53Zone,omitempty"`
AWSZoneLetter string `json:"awsZoneLetter,omitempty" yaml:"awsZoneLetter,omitempty"`
PrivateAccess bool `json:"privateAccess,omitempty" yaml:"privateAccess,omitempty"`
PublicAccess bool `json:"publicAccess,omitempty" yaml:"publicAccess,omitempty"`
RegistryRootSize int64 `json:"registryRootSize,omitempty" yaml:"registryRootSize,omitempty"`
Region string `json:"region,omitempty" yaml:"region,omitempty"`
AWSUser string `json:"awsUser,omitempty" yaml:"awsUser,omitempty"`
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
AMI string `json:"ami,omitempty" yaml:"ami,omitempty"`
AWSInstanceType string `json:"awsInstanceType,omitempty" yaml:"awsInstanceType,omitempty"`
AWSKeyName string `json:"awsKeyName,omitempty" yaml:"awsKeyName,omitempty"`
AWSRootSize int64 `json:"awsRootSize,omitempty" yaml:"awsRootSize,omitempty"`
AWSSecurityGroupNames []string `json:"awsSecurityGroupNames,omitempty" yaml:"awsSecurityGroupNames,omitempty"`
AWSSecurityGroups []string `json:"awsSecurityGroups,omitempty" yaml:"awsSecurityGroups,omitempty"`
AWSSubnetID string `json:"awsSubnetID,omitempty" yaml:"awsSubnetID,omitempty"`
AWSSubnets []string `json:"awsSubnets,omitempty" yaml:"awsSubnets,omitempty"`
AWSVpcID string `json:"awsVpcID,omitempty" yaml:"awsVpcID,omitempty"`
AWSRoute53Zone string `json:"awsRoute53Zone,omitempty" yaml:"awsRoute53Zone,omitempty"`
AWSZoneLetter string `json:"awsZoneLetter,omitempty" yaml:"awsZoneLetter,omitempty"`
PrivateAccess bool `json:"privateAccess,omitempty" yaml:"privateAccess,omitempty"`
PublicAccess bool `json:"publicAccess,omitempty" yaml:"publicAccess,omitempty"`
RegistryRootSize int64 `json:"registryRootSize,omitempty" yaml:"registryRootSize,omitempty"`
Region string `json:"region,omitempty" yaml:"region,omitempty"`
StandaloneSecurityGroupNames []string `json:"standaloneSecurityGroupNames,omitempty" yaml:"standaloneSecurityGroupNames,omitempty"`
AWSUser string `json:"awsUser,omitempty" yaml:"awsUser,omitempty"`
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
30 changes: 0 additions & 30 deletions framework/airgapSetup.go

This file was deleted.

21 changes: 0 additions & 21 deletions framework/cleanup/airgap/cleanup.go

This file was deleted.

48 changes: 0 additions & 48 deletions framework/cleanup/airgap/cleanupAirgapConfig.go

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package rke
package cleanup

import (
"testing"
Expand All @@ -9,13 +9,13 @@ import (
"github.com/rancher/tfp-automation/defaults/configs"
)

// ConfigRKECleanup is a function that will run terraform destroy and cleanup Terraform resources.
func ConfigRKECleanup(t *testing.T, terraformOptions *terraform.Options) {
// Cleanup is a function that will run terraform destroy and cleanup Terraform resources.
func Cleanup(t *testing.T, terraformOptions *terraform.Options, keyPath string) {
rancherConfig := new(rancher.Config)
config.LoadConfig(configs.Rancher, rancherConfig)

if *rancherConfig.Cleanup {
terraform.Destroy(t, terraformOptions)
ConfigRKECleanupTF()
TFFilesCleanup(keyPath)
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
package rancher2
package cleanup

import (
"os"

"github.com/rancher/tfp-automation/defaults/configs"
resources "github.com/rancher/tfp-automation/framework/set/resources/rancher2"
"github.com/sirupsen/logrus"
)

// ConfigCleanupTF is a function that will cleanup the main.tf file and terraform.tfstate files.
func ConfigCleanupTF() error {
keyPath := resources.SetKeyPath()

// TFFilesCleanup is a function that will cleanup the main.tf file and terraform.tfstate files.
func TFFilesCleanup(keyPath string) error {
file, err := os.Create(keyPath + configs.MainTF)
if err != nil {
logrus.Errorf("Failed to overwrite main.tf file. Error: %v", err)

return err
}

Expand All @@ -24,7 +20,6 @@ func ConfigCleanupTF() error {
_, err = file.WriteString("// Leave blank - main.tf will be set during testing")
if err != nil {
logrus.Errorf("Failed to write to main.tf file. Error: %v", err)

return err
}

Expand All @@ -36,15 +31,13 @@ func ConfigCleanupTF() error {

if err != nil {
logrus.Errorf("Failed to delete terraform.tfstate, terraform.tfstate.backup, and terraform.lock.hcl files. Error: %v", err)

return err
}
}

err = os.RemoveAll(keyPath + configs.TerraformFolder)
if err != nil {
logrus.Errorf("Failed to delete .terraform folder. Error: %v", err)

return err
}

Expand Down
21 changes: 0 additions & 21 deletions framework/cleanup/rancher2/cleanup.go

This file was deleted.

48 changes: 0 additions & 48 deletions framework/cleanup/rke/cleanupRKEConfig.go

This file was deleted.

21 changes: 0 additions & 21 deletions framework/cleanup/sanity/cleanup.go

This file was deleted.

Loading

0 comments on commit 52387c7

Please sign in to comment.