Skip to content
Open
Show file tree
Hide file tree
Changes from 9 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
146 changes: 146 additions & 0 deletions .github/workflows/component-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
# SPDX-FileCopyrightText: (C) 2025 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Component Tests
permissions:
contents: read

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

env:
# Test environment configuration
HARBOR_SERVER: https://harbor.kind.internal
HARBOR_NAMESPACE: harbor
HARBOR_ADMIN_CREDENTIAL: admin-secret
KEYCLOAK_SERVER: https://keycloak.kind.internal
KEYCLOAK_NAMESPACE: keycloak
KEYCLOAK_SECRET: keycloak-secret
VAULT_SERVER: https://vault.kind.internal
CATALOG_SERVER: https://catalog.kind.internal
ADM_SERVER: https://adm.kind.internal
RS_ROOT_URL: oci://registry.kind.internal
RS_PROXY_ROOT_URL: https://registry.kind.internal
MANIFEST_PATH: /manifests
MANIFEST_TAG: latest
REGISTRY_HOST_EXTERNAL: https://harbor.kind.internal
SERVICE_ACCOUNT: default

jobs:
component-tests:
runs-on: ubuntu-latest
timeout-minutes: 45

strategy:
matrix:
go-version: ['1.21', '1.22']

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

- name: Cache Go modules
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-

- name: Create KinD cluster
uses: helm/[email protected]
with:
cluster_name: kind
config: test/config/kind-config.yaml

- name: Install kubectl
uses: azure/setup-kubectl@v4
with:
version: 'v1.29.0'

- name: Install Helm
uses: azure/setup-helm@v4
with:
version: '3.13.0'

- name: Set up test infrastructure
run: |
# Install required CRDs and services for testing
kubectl create namespace harbor --dry-run=client -o yaml | kubectl apply -f -
kubectl create namespace keycloak --dry-run=client -o yaml | kubectl apply -f -
kubectl create namespace orch-app --dry-run=client -o yaml | kubectl apply -f -

# Create mock services for testing
kubectl apply -f test/manifests/test-services.yaml

- name: Wait for test infrastructure
run: |
# Wait for mock services to be ready
kubectl wait --for=condition=available --timeout=300s deployment/mock-harbor -n harbor
kubectl wait --for=condition=available --timeout=300s deployment/mock-keycloak -n keycloak
kubectl wait --for=condition=available --timeout=300s deployment/mock-catalog -n orch-app

- name: Set up port forwarding
run: |
# Set up port forwarding for test services
kubectl port-forward -n harbor svc/mock-harbor 8080:80 &
kubectl port-forward -n keycloak svc/mock-keycloak 8081:80 &
kubectl port-forward -n orch-app svc/mock-catalog 8082:80 &
sleep 10 # Give port forwarding time to establish

- name: Download dependencies
run: |
go mod download
go mod vendor

- name: Build application
run: |
make go-build

- name: Run unit tests
run: |
make go-test

- name: Run component tests
run: |
make component-test

- name: Run component tests with coverage
run: |
make component-test-coverage

- name: Upload coverage reports
uses: codecov/codecov-action@v4
with:
files: ./coverage.xml,./component-coverage.xml
flags: component-tests
name: component-coverage
fail_ci_if_error: false

- name: Archive test results
uses: actions/upload-artifact@v4
if: always()
with:
name: component-test-results-go${{ matrix.go-version }}
path: |
coverage.xml
component-coverage.xml
*.log

- name: Cleanup
if: always()
run: |
# Kill port forwarding processes
pkill -f "kubectl port-forward" || true
# Additional cleanup if needed
kubectl delete namespace harbor keycloak orch-app --ignore-not-found=true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ bin/
vendor/
build/_output/
coverage.*
component-coverage.*
venv-env/
ci/
artifacts/
Expand Down
25 changes: 21 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,27 @@ lint: yamllint go-lint hadolint mdlint ## Runs lint stage
.PHONY: test
test: go-test ## Runs test stage

.PHONY: coverage
coverage: go-cover-dependency ## Runs coverage stage
$(GOCMD) test -gcflags=-l `go list $(PKG)/cmd/... $(PKG)/internal/... | grep -v "/mocks" | grep -v "/test/"` -v -coverprofile=coverage.txt -covermode count
${GOPATH}/bin/gocover-cobertura < coverage.txt > coverage.xml
## Component testing targets
.PHONY: component-test

component-test: ## Run component tests
@echo "---COMPONENT TESTS---"
@./test/scripts/setup-test-env.sh
@trap './test/scripts/cleanup-test-env.sh' EXIT; \
GOPRIVATE="github.com/open-edge-platform/*" $(GOCMD) test -timeout 2m -v -p 1 -parallel 1 \
./test/component/... \
| tee >(go-junit-report -set-exit-code > component-test-report.xml)
@echo "---END COMPONENT TESTS---"

.PHONY: component-test-coverage
component-test-coverage: ## Run component tests with coverage
@echo "---COMPONENT TESTS WITH COVERAGE---"
@./test/scripts/setup-test-env.sh
@trap './test/scripts/cleanup-test-env.sh' EXIT; \
GOPRIVATE="github.com/open-edge-platform/*" $(GOCMD) test -timeout 2m -v -p 1 -parallel 1 \
-coverprofile=component-coverage.txt -covermode=atomic ./test/component/... \
| tee >(go-junit-report -set-exit-code > component-test-report.xml)
@echo "---END COMPONENT TESTS WITH COVERAGE---"

.PHONY: list
list: ## displays make targets
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.3-dev
0.4.3
4 changes: 2 additions & 2 deletions deploy/charts/app-orch-tenant-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
apiVersion: v2
description: Tenant Controller
name: app-orch-tenant-controller
version: 0.4.2
version: 0.4.3
annotations:
revision: ""
created: ""
appVersion: "0.4.2"
appVersion: "0.4.3"
47 changes: 47 additions & 0 deletions test/component/component_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-FileCopyrightText: (C) 2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0

package component

import (
"testing"

"github.com/stretchr/testify/suite"
)

// TestComponentTests is the main test runner for component tests
func TestComponentTests(t *testing.T) {
t.Log("🎯 Running Component Tests for App Orchestration Tenant Controller")
t.Log("")
t.Log("Component tests validate:")
t.Log(" ✓ Plugin integration (Harbor, Catalog, Extensions)")
t.Log(" ✓ Manager event handling and project lifecycle")
t.Log(" ✓ Nexus hook integration and watcher management")
t.Log(" ✓ Southbound service communications")
t.Log(" ✓ Error handling and recovery scenarios")
t.Log(" ✓ Concurrent operations and thread safety")
t.Log("")

// Run plugin component tests
t.Run("PluginComponents", func(t *testing.T) {
suite.Run(t, new(PluginComponentTests))
})

// Run manager component tests
t.Run("ManagerComponents", func(t *testing.T) {
suite.Run(t, new(ManagerComponentTests))
})

// Run nexus hook component tests
t.Run("NexusHookComponents", func(t *testing.T) {
suite.Run(t, new(NexusHookComponentTests))
})

// Run southbound component tests
t.Run("SouthboundComponents", func(t *testing.T) {
suite.Run(t, new(SouthboundComponentTests))
})

t.Log("")
t.Log("🎉 Component Test Suite Complete")
}
Loading
Loading