coreapitesting

package
v0.0.0-...-cca3ada Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TestLocation                                = "westus3"
	TestAPIVersion                              = "2024-06-10-preview"
	TestTenantID                                = "00000000-0000-0000-0000-000000000000"
	TestSubscriptionID                          = "11111111-1111-1111-1111-111111111111"
	TestAltSubscriptionID                       = "22222222-2222-2222-2222-222222222222"
	TestResourceGroupName                       = "testResourceGroup"
	TestClusterName                             = "testCluster"
	TestNodePoolName                            = "testNodePool"
	TestExternalAuthName                        = "testExtAuth"
	TestDeploymentName                          = "testDeployment"
	TestManagedResourceGroupName                = "testManagedResourceGroup"
	TestNetworkSecurityGroupName                = "testNetworkSecurityGroup"
	TestVirtualNetworkName                      = "testVirtualNetwork"
	TestSubnetName                              = "testSubnet"
	TestVnetIntegrationSubnetName               = "testVnetIntegrationSubnet"
	TestKMSKeyName                              = "testKMSKeyName"
	TestKMSKeyVaultName                         = "testKMSKeyVaultName"
	TestKMSKeyVersion                           = "testKMSKeyVersion"
	TestPendingClusterServiceIDPath             = "/api/aro_hcp/v1alpha1/clusters/test-cluster-service-id"
	TestPendingClusterServiceIDClusterIDSegment = "test-cluster-service-id"
)

Variables

View Source
var (
	TestSubscriptionResourceID                = path.Join("/subscriptions", TestSubscriptionID)
	TestResourceGroupResourceID               = path.Join(TestSubscriptionResourceID, "resourceGroups", TestResourceGroupName)
	TestClusterResourceID                     = path.Join(TestResourceGroupResourceID, "providers", coreapi.ProviderNamespace, coreapi.ClusterResourceTypeName, TestClusterName)
	TestNodePoolResourceID                    = path.Join(TestClusterResourceID, coreapi.NodePoolResourceTypeName, TestNodePoolName)
	TestExternalAuthResourceID                = path.Join(TestClusterResourceID, coreapi.ExternalAuthResourceTypeName, TestExternalAuthName)
	TestDeploymentResourceID                  = path.Join(TestResourceGroupResourceID, "providers", coreapi.ProviderNamespace, "deployments", TestDeploymentName)
	TestNetworkSecurityGroupResourceID        = path.Join(TestResourceGroupResourceID, "providers", "Microsoft.Network", "networkSecurityGroups", TestNetworkSecurityGroupName)
	TestVirtualNetworkResourceID              = path.Join(TestResourceGroupResourceID, "providers", "Microsoft.Network", "virtualNetworks", TestVirtualNetworkName)
	TestSubnetResourceID                      = path.Join(TestVirtualNetworkResourceID, "subnets", TestSubnetName)
	TestVnetIntegrationSubnetResourceID       = path.Join(TestVirtualNetworkResourceID, "subnets", TestVnetIntegrationSubnetName)
	TestManagedIdentitiesDataPlaneIdentityURL = "https://dummyhost.identity.azure.net/otherinformation?aqueryarg=somevalue"
)

Functions

func CommonDeepCopyFuzzFuncs

func CommonDeepCopyFuzzFuncs() []interface{}

CommonDeepCopyFuzzFuncs returns fuzz funcs for deep-copy tests.

func CommonRoundTripFuzzFuncs

func CommonRoundTripFuzzFuncs() []interface{}

CommonRoundTripFuzzFuncs returns fuzz funcs shared by all API version round-trip conversion tests. It builds on CommonDeepCopyFuzzFuncs (which generates valid data for every field) and appends overrides that zero internal-only fields that do not survive the external API round-trip. Version-specific overrides can be appended after this slice; randfill uses the last-registered func for a type.

func CreateTestSubscription

func CreateTestSubscription(registeredFeatures ...string) *coreapi.Subscription

CreateTestSubscription creates a test subscription with optional registered feature flags. Call with no arguments for a standard subscription, or pass feature names to register them.

func DeepCopyFuzzerFor

func DeepCopyFuzzerFor(src rand.Source) *randfill.Filler

DeepCopyFuzzerFor creates a randfill.Filler with NilChance=.5, NumElements=1,3 pre-loaded with CommonDeepCopyFuzzFuncs.

func DoDeepCopyTest

func DoDeepCopyTest(t *testing.T, original runtime.Object, fuzzer *randfill.Filler)

DoDeepCopyTest verifies that DeepCopyObject produces an independent copy. It encodes the original to JSON, then re-fuzzes the copy. If the copy and original share any references, re-fuzzing the copy would mutate the original, and the JSON encoding would differ.

func FuzzArmResourceID

func FuzzArmResourceID(resourceType string, genName func() string) *azcorearm.ResourceID

FuzzArmResourceID constructs a lexically valid *azcorearm.ResourceID for the given ARM resource type (e.g. "Microsoft.Network/virtualNetworks/subnets"). genName is called once per path segment that needs a random name (resource group plus one per resource-type level). All path components are lowercased so the result survives case-normalizing round-trips.

func FuzzInternalID

func FuzzInternalID(genName func() string) metadataapi.InternalID

FuzzInternalID constructs a lexically valid InternalID for a Cluster Service cluster resource with a random name component.

func FuzzerFor

func FuzzerFor(funcs []interface{}, src rand.Source) *randfill.Filler

FuzzerFor creates a randfill.Filler with NilChance=.5, NumElements=0,1 suitable for round-trip conversion tests.

func GenName

func GenName(c randfill.Continue) func() string

GenName returns a name-generator closure backed by the given randfill.Continue.

func MinimumValidClusterTestCase

func MinimumValidClusterTestCase() *coreapi.HCPOpenShiftCluster

func MinimumValidExternalAuthTestCase

func MinimumValidExternalAuthTestCase() *coreapi.HCPOpenShiftClusterExternalAuth

func NewTestLogger

func NewTestLogger() *slog.Logger

func NewTestUserAssignedIdentity

func NewTestUserAssignedIdentity(name string) *azcorearm.ResourceID

Types

type ExternalTestResource

type ExternalTestResource struct {
	ID         *string
	Name       *string
	Type       *string
	SystemData *generated.SystemData
	Location   *string
	Tags       map[string]*string
	Identity   *generated.ManagedServiceIdentity
}

+k8s:deepcopy-gen=false

func (*ExternalTestResource) ConvertToInternal

func (*ExternalTestResource) GetVersion

func (m *ExternalTestResource) GetVersion() coreapi.Version

func (*ExternalTestResource) NewExternal

func (m *ExternalTestResource) NewExternal() any

type InternalTestResource

type InternalTestResource struct {
	coreapi.TrackedResource
	Identity *coreapi.ManagedServiceIdentity `json:"identity"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL