package k8s import ( "time" "edge-infra.dev/test/framework" "edge-infra.dev/test/framework/config" "edge-infra.dev/test/framework/gcp" ) // Timeouts has configuration values for K8s specific timeouts var Timeouts struct { DefaultTimeout time.Duration `default:"30s" description:"default timeout for k8s operations"` Tick time.Duration `default:"1s" description:"default tick interval for k8s operations to be retried"` InstallTimeout time.Duration `default:"60s" description:"default timeout for installing components"` // Add additional specialized timeouts here based on objects worked with, // e.g., PVC binding, etc. Default should cover most basic K8s interactions } // Runtime has configuration values related to the cluster runtime var Runtime struct { GKE bool `default:"false" description:"whether or not the test is being ran against a GKE cluster"` } // KonfigKonnector has configuration values needed for installing & configuring // K8s config connector var KonfigKonnector struct { APIKey string `description:"path to key.json for service account that will be used with k8s cfg connector, required for non-GKE test runs"` ServiceAccount string `description:"service account name to use when configurng k8s cfg connector on GKE via workload identity"` } func init() { _ = config.AddOptions(&Timeouts, "k8s") _ = config.AddOptions(&Runtime, "k8s") _ = config.AddOptions(&KonfigKonnector, "k8s-cfg-conn") } // NeedsKonfigKonnector is a function that can be hooked in as a framework.Step // so that test suites which require K8s cfg connector for integration tests are // automatically skipped if the pre-reqs aren't provided. // Only skips if the test is an integration test. func NeedsKonfigKonnector(f *framework.Framework) { // tests relying on KCC to create resources will need a valid GCP project ID // to schedule resources against gcp.NeedsProjectID(f) if Runtime.GKE && KonfigKonnector.ServiceAccount == "" { f.Skip("KonfigKonnector", "missing service account for GKE runtime") } if !Runtime.GKE && KonfigKonnector.APIKey == "" { f.Skip("KonfigKonnector", "missing key.json for non-GKE runtime") } }