test/e2e: export types, functions, and package vars for external consumption#64
Open
josecastillolema wants to merge 14 commits into
Open
test/e2e: export types, functions, and package vars for external consumption#64josecastillolema wants to merge 14 commits into
josecastillolema wants to merge 14 commits into
Conversation
Renames the central unexported systemTestInput struct (and all ~43
fields) to SystemTestInput so it can be referenced from outside the
package. Pure rename, no behavior change.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
Renames ApplySDNConfig/ApplyConfig/HasDpuNodes/TotalDPUs methods to
exported form and changes SetInput() to return *SystemTestInput
(previously void, only mutated the package-private 'input' global) so
external callers can obtain the constructed value directly.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
Fixes remaining references to ApplySDNConfig/ApplyConfig/HasDpuNodes/
TotalDPUs across the package (gopls rename call-site updates that
hadn't been staged yet) and a stale doc comment.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
…ntsInput fields
Both types were already exported but every field was unexported,
making them uninstantiable from outside the package. Exports the
remaining fields and getProvisionDPUClustersInput ->
GetProvisionDPUClustersInput, the only function that builds a
ProvisionDPUClustersInput from the current SystemTestInput.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
Exports the package-level shared state that non-test files read
directly instead of receiving as parameters: Ctx, TestClient,
RestConfig, Clientset, Conf, CleanupFlags, CleanupTracker,
ArtifactsDir, CollectResources, DPUClusterClient,
DPUClusterRestConfig, DPUClusterRestClient, HostClusterRESTClient,
MetricsURI. An external caller can now set these before invoking
Validate*/Verify* functions, matching the package's existing
global-state design. Vars only used within _test.go files
(configPath, testKubeconfig, externalTest, enableSOSReports,
dpuClusterClientsInitialized) are left unexported.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
Exports config -> Config (all fields were already exported, only the
type name was not) and readConfig -> ReadConfig. Exports the
namespace/name/timeout consts referenced when constructing objects
that match the suite's conventions: ConfigName,
DPFOperatorSystemNamespace, ArgoCDTrackingIDAnnotation,
NGCPullSecretName, DPFPullSecretName, KubeStateMetricsPort,
DefaultAPIServerPort, PerformanceMTU, ProvisioningTimeout,
DPUDeploymentReadyTimeout. testMTUValue is left unexported as it is
only used by test files exercising an MTU-change scenario.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
The VPCOVN scenario had no exported facade at all - its logic lived
entirely in vpcovn_test.go's It() blocks calling unexported helpers
in vpcovn.go directly. Exports VPCOVNTestInput and its 8 fields,
ApplyVPCOVNConfig, all 19 unexported helper functions
(CreateVtepDPUServiceIPAM, CreateOVNCentralDPUService,
CreateOrUpdateVPCDPUServiceChain, etc.), and the VPCOVNInput
package-var singleton so an external caller can reconstruct the same
scenario the upstream test drives.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
Same treatment as VPCOVN: the Weave scenario had no exported facade,
its logic lived entirely in weave_test.go's It() blocks calling
unexported helpers in weave.go directly. Exports WeaveTestInput and
its field, ApplyWeaveConfig, response/metric types
(VpcctlVNetResponse, VpcctlAttachmentResponse,
VpcctlListAttachmentResponse, WeaveMetrics, MetricDeltaExpect,
MetricRef) and their fields, all 24 unexported helper functions, and
the WeaveInput package-var singleton. weavePodsToVerify,
dpuPortToPCIUnderscored, and dpuPortToDropNIC are left unexported as
they are small lookup tables only referenced from within
weave_test.go's own test bodies, not needed to call any exported
helper.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
…est.go files
Go excludes _test.go files from normal package imports, so all the
work exporting SystemTestInput/globals/etc in prior commits was
necessary but not sufficient - the var declarations and setup
functions themselves lived in _test.go files and were simply
undefined for an external `import e2e ...` consumer.
Moves (pure relocation, no logic changes):
- Package vars Ctx/TestClient/RestConfig/Clientset/Conf/CleanupFlags/
CleanupTracker/ArtifactsDir/CollectResources/input/VPCOVNInput and
the test-flag-only externalTest var: e2e_suite_test.go and
system_test.go -> new globals.go
- SetInput/SystemSetupBeforeSuite/createNGCImagePullSecret/
AnnotateAndLabelNodes/GetProvisionDPUClustersInput/validateFlags:
system_test.go -> new system_bootstrap.go
- ProvisioningBeforeSuite: provisioning_test.go -> provisioning.go
- SNAPBeforeSuite: snap_test.go -> new snap.go
- SDNBeforeSuite: sdn_test.go -> new sdn.go
- VPCOVNBeforeSuite: vpcovn_test.go -> vpcovn.go
- CreateDPUWorkerNodes: scale_test.go -> new scale.go
_test.go files keep only their Describe/It/BeforeSuite/AfterSuite
Ginkgo registrations and the TestE2E entrypoint, which only matter
when running via 'go test' - confirmed both 'go build ./...' (the
external-import path) and 'go test ./test/e2e/... -list .*' (the
internal go-test path) pass after this change.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
The upgrade validation framework (installPhase/validationPhase DSL,
artifact snapshot/compare machinery, BFB LTS rollout helpers) was
entirely defined in _test.go files with unexported identifiers -
neither visible nor reachable from an external import.
Renames upgrade_framework_test.go -> upgrade_framework.go and
upgrade_artifacts_test.go -> upgrade_artifacts.go outright (neither
file had any Describe/It registrations, only type/func/var
declarations). Splits the 3 helpers upgrade_framework.go depends on
(RolloutAllDPUs, VerifyDPUsHaveKubeletVersion,
RemoveStaleDPUDeviceProtectionFinalizers) out of upgrade_lts_test.go
into a new upgrade_lts.go, leaving that file's Describe block and its
two local-only helpers (expectedDPUServicesV2510, envOrDefault) in
place.
Exports InstallPhaseInput/ValidationPhaseInput and all their fields,
InstallPhase/ValidationPhase/IsUpgradeValidationPhase,
UpgradeExpectedChange and its fields, ValidationPhaseLabels, and the
remaining ~20 unexported helper functions across
upgrade_framework.go/upgrade_artifacts.go/upgrade_apply.go/
upgrade_lts.go. An external caller can now define and register a
custom InstallPhase/ValidationPhase the same way upgrade_test.go and
upgrade_lts_test.go's Describe blocks do.
Confirmed clean: go build ./... (external-import path), go vet ./...,
and go test ./test/e2e/... -list '.*' (internal go-test path).
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
…cturedFromFile, GetDPUClusterClient(s))
These utils.go/system_setup.go helpers are called throughout the
package to check Ginkgo label filters, load YAML manifests into
objects, and establish DPU cluster clients - all required to
replicate BeforeSuite/SetInput semantics from outside the package.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
Applies the same export treatment to leader_election.go's target type
that was proven in an earlier standalone PoC against the leader
election failover test, now folded into this branch's broader export
so the type is consistent with the rest of the exported surface.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
…ommit The LeaderElectionTarget struct-literal fields and target.Component reference in leader_election_test.go should have been included in d241d5d alongside the type/field renames in leader_election.go. gitleaks.version: 8.30.0 gitleaks.check-secrets: ENABLED
The quick-start guide still referenced the pre-export lowercase names
(systemTestInput, hasDpuNodes, applyConfig, ctx, dpuClusterClient,
input.client, dpfPullSecretName/dpfOperatorSystemNamespace) that this
branch renamed to their exported form. Updates all references and the
system_test.go -> system_bootstrap.go file pointer for SetInput/
SystemSetupBeforeSuite.
gitleaks.version: 8.30.0
gitleaks.check-secrets: ENABLED
Author
|
cc @aserdean |
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Exports the unexported types, functions, and package-level state throughout test/e2e so the suite can be consumed as a plain Go library import (import e2e "github.com/nvidia/doca-platform/test/e2e") from an external repository, instead of requiring go test internals or copy-pasted logic.
Why
Downstream consumers (e.g. openshift-dpf) want to run this suite's actual test logic against a pre-existing DPF deployment without reimplementing it. A prior PoC proved this is viable for one test (leader-election failover) by exporting a single struct. This PR generalizes that to the whole package.
What changed
SetInput()now returns the constructed value instead of only mutating a package-private global.ProvisionDPUClustersInput/DeployDPFSystemComponentsInput— were already exported types but every field was unexported (uninstantiable); fields exported.Ctx,TestClient,RestConfig,Conf,CleanupFlags,DPUClusterClient, etc.) — exported so external callers can set them before invoking Validate*/Verify* functions, matching the package's existing global-state design._test.goboundary fix (the critical one): Go excludes _test.go files from normal package imports, soSetInput,SystemSetupBeforeSuite,SDNBeforeSuite,VPCOVNBeforeSuiteand their backing package vars were exported by name but still undefined to an external importer. Relocated 8 functions and ~12 package vars into new/existing non-test .go files: pure moves, zero logic changes.All changes are mechanical renames/relocations — no test logic, assertions, or control flow were modified.
Verification
go build ./... (external-import path),go vet ./...andgo test ./test/e2e/... -list '.*'(internal go test path) all pass.DeferCleanupscaled the controller back to 1 replica).Assisted-by: Claude 🤖