Skip to content

Commit a9a0553

Browse files
committed
HYPERFLEET-1057 - feat: Add infra repo installation support for E2E
Adds infrastructure and tooling to enable E2E tests to install HyperFleet components using the hyperfleet-infra repository instead of custom scripts. - Add git, helmfile, and helm plugins (helm-diff, helm-git) to Dockerfile - Create env.ci configuration file with CI-specific environment variables - Add cleanup-k8s-resources.sh script to uninstall Helm releases and delete namespaces - Add cleanup-pubsub-resources.sh script to remove GCP Pub/Sub topics and subscriptions - Update adapter release naming to use adapter name directly (temporary workaround for HYPERFLEET-1097) - Change API release name from "api" to "hyperfleet-api" for consistency - Update test helper to use "hyperfleet-api" release name in upgrade/restore operations - Fix cluster force delete test to use adapter name as release name - Copy env and scripts directories to container image alongside existing deploy-scripts
1 parent 0bd1740 commit a9a0553

8 files changed

Lines changed: 765 additions & 19 deletions

File tree

Dockerfile

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FROM ${BASE_IMAGE}
3030

3131
# Install runtime dependencies and tools
3232
USER root
33-
RUN dnf -y install --allowerasing jq gettext curl && dnf clean all
33+
RUN dnf -y install --allowerasing jq gettext curl git && dnf clean all
3434

3535
# Install kubectl (latest stable)
3636
RUN curl -fsSL "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" \
@@ -39,6 +39,18 @@ RUN curl -fsSL "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release
3939
# Install Helm
4040
RUN curl -fsSL https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
4141

42+
# Install Helm plugins - helm-git and helm-diff
43+
ARG HELM_GIT_VERSION=v1.5.2
44+
ARG HELM_DIFF_VERSION=3.15.7
45+
RUN helm plugin install https://github.com/aslafy-z/helm-git --version ${HELM_GIT_VERSION} && \
46+
helm plugin install https://github.com/databus23/helm-diff --version ${HELM_DIFF_VERSION}
47+
48+
ARG HELMFILE_VERSION=1.5.2
49+
# Install helmfile
50+
RUN curl -fsSL "https://github.com/helmfile/helmfile/releases/download/v${HELMFILE_VERSION}/helmfile_${HELMFILE_VERSION}_linux_amd64.tar.gz" | \
51+
tar -xz -C /usr/local/bin helmfile && \
52+
chmod +x /usr/local/bin/helmfile
53+
4254
WORKDIR /e2e
4355

4456
# Copy the hyperfleet-credential-provider binary
@@ -53,6 +65,13 @@ COPY --from=builder /build/testdata /e2e/testdata
5365
# Copy deploy scripts
5466
COPY --from=builder /build/deploy-scripts /e2e/deploy-scripts
5567

68+
# Copy env files
69+
COPY --from=builder /build/env /e2e/env
70+
71+
# Copy cleanup scripts
72+
COPY --from=builder /build/scripts /e2e/scripts
73+
74+
5675
# Copy default config (fallback if ConfigMap is not mounted)
5776
COPY --from=builder /build/configs /e2e/configs
5877

deploy-scripts/lib/adapter.sh

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,8 @@ install_adapter_instance() {
107107
log_info "Resource type: ${resource_type}"
108108
log_info "Adapter name: ${adapter_name}"
109109

110-
# Construct deterministic release name (matches API/Sentinel pattern)
111-
# Kubernetes resource names have a 63-character limit
112-
# Reserve ~15 characters for Helm's deployment/pod suffixes
113-
local max_release_name_length=48
114-
local release_name="adapter-${resource_type}-${adapter_name}"
115-
116-
if [[ ${#release_name} -gt ${max_release_name_length} ]]; then
117-
local release_hash
118-
release_hash=$(printf '%s' "${release_name}" | sha256sum | cut -c1-8)
119-
local max_base_length=$((max_release_name_length - ${#release_hash} - 1))
120-
release_name="${release_name:0:${max_base_length}}-${release_hash}"
121-
log_warning "Release name truncated to ${max_release_name_length} chars to stay within Kubernetes limits"
122-
fi
110+
# Temporary workaround for installation - HYPERFLEET-1097
111+
local release_name="${adapter_name}"
123112

124113
log_info "Release name: ${release_name} (length: ${#release_name})"
125114

deploy-scripts/lib/api.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
install_api() {
1212
log_section "Installing API"
1313

14-
local release_name="api"
14+
local release_name="hyperfleet-api"
1515
local full_chart_path="${WORK_DIR}/api/${API_CHART_PATH}"
1616

1717
# Use API_ADAPTERS_* environment variables for API configuration
@@ -121,7 +121,7 @@ install_api() {
121121
uninstall_api() {
122122
log_section "Uninstalling API"
123123

124-
local release_name="api"
124+
local release_name="hyperfleet-api"
125125

126126
# Check if release exists
127127
if [[ -z "$(helm list -n "${NAMESPACE}" -q -f "^${release_name}$")" ]]; then

e2e/cluster/force_delete.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ var _ = ginkgo.Describe("[Suite: cluster][delete] Force-Delete Cluster Stuck in
5151

5252
Expect(h.Cfg.Adapters.Cluster).NotTo(BeEmpty(), "cluster adapter config is required for this test")
5353
clAdapterName := h.Cfg.Adapters.Cluster[0]
54-
clReleaseName := helper.GenerateAdapterReleaseName(helper.ResourceTypeClusters, clAdapterName)
54+
// Standard adapters are deployed with release name = adapter name (e.g., "cl-namespace", not "adapter-clusters-cl-namespace")
55+
clReleaseName := clAdapterName
5556

5657
deploymentName, err := h.GetDeploymentName(ctx, h.Cfg.Namespace, clReleaseName)
5758
Expect(err).NotTo(HaveOccurred(), "failed to find cluster adapter deployment")

env/env.ci

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
# ============================================================================
3+
# WARNING: These variables are sourced by E2E test automation steps.
4+
# Do NOT modify this file without testing the changes in the E2E pipeline.
5+
# ============================================================================
6+
7+
# Image Registry Configuration
8+
export IMAGE_REGISTRY="${IMAGE_REGISTRY:-registry.ci.openshift.org}"
9+
10+
# API Component Configuration
11+
export API_IMAGE_REPO="${API_IMAGE_REPO:-ci/hyperfleet-api}"
12+
export API_IMAGE_TAG="${API_IMAGE_TAG:-latest}"
13+
export API_SERVICE_TYPE="${API_SERVICE_TYPE:-LoadBalancer}"
14+
15+
16+
# =====================================================================
17+
# API Adapter Configuration
18+
# ============================================================================
19+
# NOTE: These are SEPARATE from tier0 deployment configuration above
20+
# These should be set based on specific test case requirements
21+
# Set per test case as needed
22+
23+
# Adapters for API cluster configuration
24+
export API_ADAPTERS_CLUSTER="${API_ADAPTERS_CLUSTER:-cl-namespace,cl-job,cl-deployment,cl-maestro}"
25+
26+
# Adapters for API nodepool configuration
27+
export API_ADAPTERS_NODEPOOL="${API_ADAPTERS_NODEPOOL:-np-configmap}"
28+
29+
# Sentinel Component Configuration
30+
export SENTINEL_IMAGE_REPO="${SENTINEL_IMAGE_REPO:-ci/hyperfleet-sentinel}"
31+
export SENTINEL_IMAGE_TAG="${SENTINEL_IMAGE_TAG:-latest}"
32+
export SENTINEL_BROKER_TYPE="${SENTINEL_BROKER_TYPE:-googlepubsub}"
33+
export SENTINEL_GOOGLEPUBSUB_CREATE_TOPIC_IF_MISSING="${SENTINEL_GOOGLEPUBSUB_CREATE_TOPIC_IF_MISSING:-true}"
34+
35+
# Adapter Component Configuration
36+
export ADAPTER_IMAGE_REPO="${ADAPTER_IMAGE_REPO:-ci/hyperfleet-adapter}"
37+
export ADAPTER_IMAGE_TAG="${ADAPTER_IMAGE_TAG:-latest}"
38+
export ADAPTER_GOOGLEPUBSUB_CREATE_TOPIC_IF_MISSING="${ADAPTER_GOOGLEPUBSUB_CREATE_TOPIC_IF_MISSING:-true}"
39+
export ADAPTER_GOOGLEPUBSUB_CREATE_SUBSCRIPTION_IF_MISSING="${ADAPTER_GOOGLEPUBSUB_CREATE_SUBSCRIPTION_IF_MISSING:-true}"
40+
41+
42+
# Helm Chart Sources
43+
# Note: ADAPTER_CHART_* and API_CHART_* vars are also required by tier2 E2E tests
44+
# (e.g., crash recovery) which deploy dedicated adapters and upgrade API config at runtime.
45+
# When running tier2 tests in CI, ensure these are exported alongside GINKGO_LABEL_FILTER=tier2.
46+
export API_CHART_REPO="${API_CHART_REPO:-https://github.com/openshift-hyperfleet/hyperfleet-api.git}"
47+
export API_CHART_REF="${API_CHART_REF:-main}"
48+
export API_CHART_PATH="${API_CHART_PATH:-charts}"
49+
50+
export SENTINEL_CHART_REPO="${SENTINEL_CHART_REPO:-https://github.com/openshift-hyperfleet/hyperfleet-sentinel.git}"
51+
export SENTINEL_CHART_REF="${SENTINEL_CHART_REF:-main}"
52+
export SENTINEL_CHART_PATH="${SENTINEL_CHART_PATH:-charts}"
53+
54+
export ADAPTER_CHART_REPO="${ADAPTER_CHART_REPO:-https://github.com/openshift-hyperfleet/hyperfleet-adapter.git}"
55+
export ADAPTER_CHART_REF="${ADAPTER_CHART_REF:-main}"
56+
export ADAPTER_CHART_PATH="${ADAPTER_CHART_PATH:-charts}"
57+
58+

pkg/helper/api_config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (h *Helper) UpgradeAPIRequiredAdapters(ctx context.Context, apiChartPath, n
2323
cmdCtx, cancel := context.WithTimeout(ctx, 3*time.Minute)
2424
defer cancel()
2525

26-
cmd := exec.CommandContext(cmdCtx, "helm", "upgrade", "api", apiChartPath, // #nosec G204 -- args from trusted test config
26+
cmd := exec.CommandContext(cmdCtx, "helm", "upgrade", "hyperfleet-api", apiChartPath, // #nosec G204 -- args from trusted test config
2727
"--namespace", namespace,
2828
"--reuse-values",
2929
"--wait",
@@ -83,7 +83,7 @@ func (h *Helper) RestoreAPIRequiredAdaptersWithRetry(ctx context.Context, apiCha
8383
"max_retries", maxRetries,
8484
"error", lastErr,
8585
"manual_fix", fmt.Sprintf(
86-
"helm upgrade api %s -n %s --reuse-values --set config.adapters.required.cluster={%s}",
86+
"helm upgrade hyperfleet-api %s -n %s --reuse-values --set config.adapters.required.cluster={%s}",
8787
apiChartPath, namespace, adapterList))
8888

8989
return fmt.Errorf("failed to restore API config after %d retries: %w", maxRetries, lastErr)

0 commit comments

Comments
 (0)