Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ibi mgmt: add directory structure for ibi tests #138

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ linters-settings:
- github.com/openshift-kni/eco-gotests/tests/system-tests/rdscore/internal/rdscoreinittools
- github.com/openshift-kni/eco-gotests/tests/lca/imagebasedupgrade/mgmt/internal/mgmtinittools
- github.com/openshift-kni/eco-gotests/tests/accel/internal/accelinittools
- github.com/openshift-kni/eco-gotests/tests/lca/imagebasedinstall/mgmt/internal/mgmtinittools
# Select the Go version to target. The default is '1.13'.
go: "1.22"
# https://staticcheck.io/docs/options#checks
Expand Down Expand Up @@ -203,6 +204,9 @@ issues:
- path: 'tests/lca/imagebasedupgrade/mgmt/internal/mgmtinittools'
linters:
- gochecknoinits
- path: 'tests/lca/imagebasedinstall/mgmt/internal/mgmtinittools'
linters:
- gochecknoinits
- path: "tests/internal/inittools"
linters:
- depguard
Expand Down
22 changes: 22 additions & 0 deletions tests/lca/imagebasedinstall/internal/ibiconfig/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ibiconfig

import (
"github.com/golang/glog"
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedinstall/internal/ibiparams"
"github.com/openshift-kni/eco-gotests/tests/lca/internal/lcaconfig"
)

// IBIConfig type contains imagebasedupgrade configuration.
type IBIConfig struct {
*lcaconfig.LCAConfig
}

// NewIBIConfig returns instance of IBIConfig type.
func NewIBIConfig() *IBIConfig {
glog.V(ibiparams.IBILogLevel).Info("Creating new IBIConfig struct")

var ibiConfig IBIConfig
ibiConfig.LCAConfig = lcaconfig.NewLCAConfig()

return &ibiConfig
}
9 changes: 9 additions & 0 deletions tests/lca/imagebasedinstall/internal/ibiparams/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ibiparams

const (
// Label represents ibi label that can be used for test cases selection.
Label = "ibi"

// IBILogLevel custom loglevel for the imagebasedinstall testing verbose mode.
IBILogLevel = 50
)
8 changes: 8 additions & 0 deletions tests/lca/imagebasedinstall/internal/ibiparams/ibivars.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package ibiparams

import "github.com/openshift-kni/eco-gotests/tests/lca/internal/lcaparams"

var (
// Labels represents the range of labels that can be used for test cases selection.
Labels = []string{lcaparams.Label, Label}
)
104 changes: 104 additions & 0 deletions tests/lca/imagebasedinstall/mgmt/internal/mgmtconfig/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package mgmtconfig

import (
"os"

"github.com/golang/glog"
"github.com/kelseyhightower/envconfig"
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedinstall/internal/ibiconfig"
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedinstall/mgmt/internal/mgmtparams"
"github.com/openshift-kni/eco-gotests/tests/lca/internal/seedimage"
"gopkg.in/yaml.v2"
)

// Cluster contains resources information that make up the cluster to be installed.
type Cluster struct {
Info struct {
ClusterName string `yaml:"cluster_name"`
BaseDomain string `yaml:"base_domain"`
MachineCIDR struct {
IPv4 string `yaml:"ipv4"`
IPv6 string `yaml:"ipv6"`
} `yaml:"machine_cidr"`
Hosts map[string]struct {
Network struct {
Interfaces map[string]struct {
MACAddress string `yaml:"mac_address"`
} `yaml:"interfaces"`
BondConfig struct {
Interfaces string `yaml:"interfaces"`
Options struct {
Mode string `yaml:"mode"`
MIIMON string `yaml:"miimon"`
} `yaml:"options"`
} `yaml:"bond_config"`
Address struct {
IPv4 string `yaml:"ipv4"`
IPv6 string `yaml:"ipv6"`
} `yaml:"address"`
Gateway struct {
IPv4 string `yaml:"ipv4"`
IPv6 string `yaml:"ipv6"`
} `yaml:"gateway"`
DNS struct {
IPv4 string `yaml:"ipv4"`
IPv6 string `yaml:"ipv6"`
} `yaml:"dns"`
} `yaml:"network"`
BMC struct {
User string `yaml:"user"`
Password string `yaml:"pass"`
URLv4 string `yaml:"urlv4"`
URLv6 string `yaml:"urlv6"`
MACAddress string `yaml:"mac_address"`
} `yaml:"bmc"`
} `yaml:"hosts"`
} `yaml:"spoke_cluster_info"`
}

// MGMTConfig type contains mgmt configuration.
type MGMTConfig struct {
*ibiconfig.IBIConfig
Cluster *Cluster
ClusterInfoPath string `envconfig:"ECO_LCA_IBI_MGMT_CLUSTER_INFO"`
SeedImage string `envconfig:"ECO_LCA_IBI_MGMT_SEED_IMAGE" default:"quay.io/ocp-edge-qe/ib-seedimage-public:ci"`
SeedClusterInfo *seedimage.SeedImageContent
SSHKeyPath string `envconfig:"ECO_LCA_IBI_MGMT_SSHKEY_PATH"`
PublicSSHKey string
}

// NewMGMTConfig returns instance of MGMTConfig type.
func NewMGMTConfig() *MGMTConfig {
glog.V(mgmtparams.MGMTLogLevel).Info("Creating new MGMTConfig struct")

var mgmtConfig MGMTConfig
mgmtConfig.IBIConfig = ibiconfig.NewIBIConfig()

err := envconfig.Process("eco_lca_ibi_mgmt_", &mgmtConfig)
if err != nil {
return nil
}

if mgmtConfig.ClusterInfoPath != "" {
content, err := os.ReadFile(mgmtConfig.ClusterInfoPath)
if err != nil {
return &mgmtConfig
}

err = yaml.Unmarshal(content, mgmtConfig.Cluster)
if err != nil {
return &mgmtConfig
}
}

if mgmtConfig.SSHKeyPath != "" {
content, err := os.ReadFile(mgmtConfig.SSHKeyPath)
if err != nil {
return &mgmtConfig
}

mgmtConfig.PublicSSHKey = string(content)
}

return &mgmtConfig
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package mgmtinittools

import (
"github.com/openshift-kni/eco-goinfra/pkg/clients"
"github.com/openshift-kni/eco-gotests/tests/internal/inittools"
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedinstall/mgmt/internal/mgmtconfig"
)

var (
// APIClient provides API access to the cluster.
APIClient *clients.Settings
// MGMTConfig provides access to general configuration parameters.
MGMTConfig *mgmtconfig.MGMTConfig
)

func init() {
MGMTConfig = mgmtconfig.NewMGMTConfig()
APIClient = inittools.APIClient
}
12 changes: 12 additions & 0 deletions tests/lca/imagebasedinstall/mgmt/internal/mgmtparams/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package mgmtparams

const (
// Label represents mgmt label that can be used for test cases selection.
Label = "mgmt"

// IBIONamespace is the namespace where the image-based-install-operator runs.
IBIONamespace = "multicluster-engine"

// MGMTLogLevel custom loglevel for the mgmt testing verbose mode.
MGMTLogLevel = 50
)
10 changes: 10 additions & 0 deletions tests/lca/imagebasedinstall/mgmt/internal/mgmtparams/mgmtvars.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package mgmtparams

import (
"github.com/openshift-kni/eco-gotests/tests/lca/imagebasedinstall/internal/ibiparams"
)

var (
// Labels represents the range of labels that can be used for test cases selection.
Labels = append(ibiparams.Labels, Label)
)
Loading