Skip to content

Commit

Permalink
Merge pull request #197 from m00g3n/add-app-gateway-k3d-integration-test
Browse files Browse the repository at this point in the history
Migrate ACM prow pipelines to GHA
  • Loading branch information
kyma-bot authored Apr 4, 2024
2 parents 53e184c + 7bd7a6e commit 2424fdd
Show file tree
Hide file tree
Showing 179 changed files with 11,948 additions and 12 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/kyma-integration-k3d-agent-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: run-cra-k3d
on:
push:
branches: [ main ]
pull_request_target:
branches: [ main ]
types:
- opened
- reopened
- synchronize
- ready_for_review
jobs:
run-cra-k3d:
uses: "./.github/workflows/reusable-k3d-agent-test.yml"
with:
k3d-version: v5.6.0
secrets:
compass-host: ${{ secrets.COMPASS_HOST }}
compass-client-id: ${{ secrets.COMPASS_CLIENT_ID }}
compass-client-secret: ${{ secrets.COMPASS_CLIENT_SECRET }}
36 changes: 36 additions & 0 deletions .github/workflows/kyma-integration-k3d-app-gateway.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Run app-gateway integration tests on k3d
on:
push:
branches: [ main ]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: azure/setup-helm@v4.1.0
id: install
- name: Checkout code
uses: actions/checkout@v3
- name: Install k3d
env:
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION: v5.4.6
run: curl --silent --fail $K3D_URL | TAG=$DEFAULT_K3D_VERSION bash
- name: Set up cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
/home/runner/work/application-connector-manager/application-connector-manager/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
run: make -C tests/hack/ci k3d-gateway-tests
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: app-gateway-test-results
path: application-gateway-test.log
39 changes: 39 additions & 0 deletions .github/workflows/kyma-integration-k3d-validator-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Run app-con-validator integration tests on k3d
on:
push:
branches: [ main ]
pull_request:
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: azure/setup-helm@v4.1.0
id: install
- name: Checkout code
uses: actions/checkout@v3
- name: Install k3d
env:
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION: v5.4.6
run: curl --silent --fail $K3D_URL | TAG=$DEFAULT_K3D_VERSION bash
- name: Insall yq
run: sudo add-apt-repository ppa:rmescandon/yq && sudo apt update && sudo apt install yq -y
- name: Set up cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
/home/runner/work/application-connector-manager/application-connector-manager/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run unit tests
run: make -C tests/hack/ci k3d-validator-tests
- name: Archive test results
if: always()
uses: actions/upload-artifact@v4
with:
name: application-connectivity-validator-test-results
path: application-connectivity-validator-test.log

50 changes: 50 additions & 0 deletions .github/workflows/reusable-k3d-agent-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: k3d CRA test
on:
workflow_call:
inputs:
k3d-version:
required: true
type: string
default: v5.6.0
secrets:
compass-host:
required: true
compass-client-id:
required: true
compass-client-secret:
required: true
jobs:
test-cra:
runs-on: ubuntu-latest
steps:
- uses: azure/setup-helm@v4.1.0
id: install-helm
- name: checkout
uses: actions/checkout@v3
- name: install-k3d
env:
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION: ${{ inputs.k3d-version }}
run: curl --silent --fail $K3D_URL | TAG=$DEFAULT_K3D_VERSION bash
- name: setup-cache
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
/home/runner/work/application-connector-manager/application-connector-manager/bin
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: run-tests
env:
COMPASS_CLIENT_ID: ${{ secrets.compass-client-id }}
COMPASS_CLIENT_SECRET: ${{ secrets.compass-client-secret }}
COMPASS_HOST: ${{ secrets.compass-host }}
run: make -C tests/hack/ci k3d-agent-tests
- name: archive-logs
if: always()
uses: actions/upload-artifact@v4
with:
name: compass-runtime-agent-test-results
path: compass-runtime-agent-test.log
3 changes: 0 additions & 3 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up cache
uses: actions/cache@v3
with:
Expand All @@ -22,12 +21,10 @@ jobs:
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Set up go environment
uses: actions/setup-go@v4
with:
go-version: 1.21

- name: Run unit tests
run: make test

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ vendor/*

# Output of the go coverage tool, specifically when used with LiteIDE
*.out
application-gateway-test.log
compass-runtime-agent-test.log

# Kubernetes Generated files - skip generated files, except for vendored files

Expand All @@ -30,4 +32,4 @@ manifests/*

mod
bin
charts
charts/**/*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.21.8 as builder
FROM golang:1.22.1 as builder

WORKDIR /workspace

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ require (
)

replace (
golang.org/x/crypto => golang.org/x/crypto v0.12.0
golang.org/x/crypto => golang.org/x/crypto v0.17.0
golang.org/x/net => golang.org/x/net v0.17.0
golang.org/x/sys => golang.org/x/sys v0.11.0
golang.org/x/text => golang.org/x/text v0.12.0
golang.org/x/tools => golang.org/x/tools v0.12.0
google.golang.org/protobuf => google.golang.org/protobuf v1.33.0
)
5 changes: 1 addition & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8=
go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E=
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
Expand All @@ -131,7 +131,6 @@ golang.org/x/oauth2 v0.12.0/go.mod h1:A74bZ3aGXgCY0qaIC9Ahg6Lglin4AMAco8cIv9baba
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4=
golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0=
Expand All @@ -150,8 +149,6 @@ google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 h1:SeZZZx0cP0fqUyA
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97/go.mod h1:t1VqOqqvce95G3hIDCT5FeO3YUc6Q4Oe24L/+rNMxRk=
google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13 h1:U7+wNaVuSTaUqNvK2+osJ9ejEZxbjHHk8F2b6Hpx0AE=
google.golang.org/genproto/googleapis/api v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:RdyHbowztCGQySiCvQPgWQWgWhGnouTdCflKoDBt32U=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
4 changes: 2 additions & 2 deletions pkg/crypto/sha256/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ func Test_calculateSHA256(t *testing.T) {
u.SetGroupVersionKind(schema.GroupVersionKind{
Kind: "CustomResourceDefinition",
Group: "apiextensions.k8s.io",
Version: "v1",
Version: "1.0.0",
})

return u
}(),
},
want: "9NtR-1kpz4ub0a8jS4YySJEGZKmPfvC5FLh5GNW5UlA=",
want: "YVinn88v80IHE3oiOSjwAPUG0OumBQ-dy1ypGbAounU=",
},
}
for _, tt := range tests {
Expand Down
2 changes: 2 additions & 0 deletions tests/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deployments/
README.md
1 change: 1 addition & 0 deletions tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
resources/charts/gateway-test/certs/
17 changes: 17 additions & 0 deletions tests/Dockerfile.compass-runtime-agent
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# image builder base on golang:1.22.1-alpine3.19
FROM golang@sha256:0466223b8544fb7d4ff04748acc4d75a608234bf4e79563bff208d2060c0dd79 as builder

WORKDIR /compass-test/

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .

RUN CGO_ENABLED=0 go test -v -c -o compass-test ./test/compass-runtime-agent/

FROM scratch

COPY --from=builder /compass-test/compass-test /
ENTRYPOINT [ "/compass-test" ]
CMD ["-test.v", "-test.parallel", "1"]
17 changes: 17 additions & 0 deletions tests/Dockerfile.connectivity-validator
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# image builder base on golang:1.22.1-alpine3.19
FROM golang@sha256:0466223b8544fb7d4ff04748acc4d75a608234bf4e79563bff208d2060c0dd79 as builder

WORKDIR /validator-test/

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .

RUN CGO_ENABLED=0 go test -v -c -o validator-test ./test/application-connectivity-validator/

FROM scratch

COPY --from=builder /validator-test/validator-test /
ENTRYPOINT [ "/validator-test" ]
CMD ["-test.v"]
17 changes: 17 additions & 0 deletions tests/Dockerfile.gateway
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# image builder base on golang:1.22.1-alpine3.19
FROM golang@sha256:0466223b8544fb7d4ff04748acc4d75a608234bf4e79563bff208d2060c0dd79 as builder

WORKDIR /gateway-test/

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .

RUN CGO_ENABLED=0 go test -v -c -o gateway-test ./test/application-gateway/

FROM scratch

COPY --from=builder /gateway-test/gateway-test /
ENTRYPOINT [ "/gateway-test" ]
CMD ["-test.v"]
17 changes: 17 additions & 0 deletions tests/Dockerfile.mockapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# image builder base on golang:1.22.1-alpine3.19
FROM golang@sha256:0466223b8544fb7d4ff04748acc4d75a608234bf4e79563bff208d2060c0dd79 as builder

WORKDIR /mock-app/

COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .


RUN CGO_ENABLED=0 go build -v -o mock-app ./tools/external-api-mock-app

FROM scratch
COPY --from=builder /mock-app/mock-app .
ENTRYPOINT [ "/mock-app" ]
CMD []
38 changes: 38 additions & 0 deletions tests/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
GATEWAY_TEST_IMAGE = "$(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/gateway-test:$(DOCKER_TAG)"
VALIDATOR_TEST_IMAGE = "$(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/connectivity-validator-test:$(DOCKER_TAG)"
COMPASS_TEST_IMAGE = "$(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/compass-runtime-agent-test:$(DOCKER_TAG)"
MOCK_APP_IMAGE = "$(DOCKER_PUSH_REPOSITORY)$(DOCKER_PUSH_DIRECTORY)/mock-app:$(DOCKER_TAG)"

REGISTRY_PORT ?= 5001

publish-gateway-test: image-gateway-test
docker push $(GATEWAY_TEST_IMAGE)

image-gateway-test:
docker build -t $(GATEWAY_TEST_IMAGE) -f Dockerfile.gateway .

publish-mock-app: image-mock-app
docker push $(MOCK_APP_IMAGE)

image-mock-app:
docker build -t $(MOCK_APP_IMAGE) -f Dockerfile.mockapp .

publish-validator-test: image-validator-test
docker push $(VALIDATOR_TEST_IMAGE)

image-validator-test:
docker build -t $(VALIDATOR_TEST_IMAGE) -f Dockerfile.connectivity-validator .

publish-compass-runtime-agent-test: image-compass-runtime-agent-test
docker push $(COMPASS_TEST_IMAGE)

.PHONY: image-compass-runtime-agent-test
image-compass-runtime-agent-test:
@echo "::group::image-compass-runtime-agent-test"
@docker build -t $(COMPASS_TEST_IMAGE) -f ${PWD}/tests/Dockerfile.compass-runtime-agent .
@echo "::endgroup::"

.PHONY: compass-runtime-agent-test-image
compass-runtime-agent-test-image: \
image-compass-runtime-agent-test \
publish-compass-runtime-agent-test
Loading

0 comments on commit 2424fdd

Please sign in to comment.