Skip to content

Commit

Permalink
adding initial agent integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CrowleyRajapakse committed Feb 29, 2024
1 parent 3a6804d commit 318c0a5
Show file tree
Hide file tree
Showing 76 changed files with 6,964 additions and 0 deletions.
129 changes: 129 additions & 0 deletions .github/workflows/agent-integration-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
name: start and run agent cucumber integration tests
on:
workflow_dispatch:
pull_request_target:
types: [labeled]
concurrency:
group: integration-test-${{ github.event.number || github.run_id }}
cancel-in-progress: true
env:
GH_TOKEN: ${{ secrets.APK_BOT_TOKEN }}
jobs:
runs_agent_cucumber_integration_tests_on_pull_request:
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
runs-on: ubuntu-latest
steps:
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create AKS Cluster and set context
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az aks create --resource-group "${{ secrets.AZURE_RESOURCE_GROUP }}" --name "agent-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}" --enable-cluster-autoscaler --min-count 1 --max-count 3 --location "southeastasia" --generate-ssh-keys
- uses: azure/aks-set-context@v3
with:
resource-group: '${{ secrets.AZURE_RESOURCE_GROUP }}'
cluster-name: 'go-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }}'
- name: Create Namespace apk
shell: sh
run: |
kubectl create namespace apk
kubectl get ns
- name: Checkout apk-repo.
uses: actions/checkout@v3
with:
fetch-depth: "0"
path: apk-repo
token: ${{ secrets.APK_BOT_TOKEN }}
- name: Set release username and email
shell: sh
run: |
git config --global user.name ${{ secrets.APK_BOT_USER }}
git config --global user.email ${{ secrets.APK_BOT_EMAIL }}
- name: checkout pull request and merge.
shell: sh
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
run: |
cd apk-repo
gh pr checkout ${{ github.event.number }} -b pr-${{ github.event.number }}
git checkout pr-${{ github.event.number }}
git merge origin/main
- name: Helm release deploy APIM CP
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
cd apk-repo/test/apim-apk-agent-test/apim-cp-helm-chart
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add jetstack https://charts.jetstack.io
helm dependency build
helm install apim -n apk . --debug --wait --timeout 5m0s \
--set deployment.image.respository=sampathrajapakse/wso2am \
--set deployment.image.tag=4.3.0 \
kubectl get pods -n apk
kubectl get svc -n apk
- name: Helm release deploy APK DP
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
cd /helm-charts
helm dependency build
helm install apk-test-setup -n apk . --debug --wait --timeout 15m0s \
kubectl get pods -n apk
kubectl get svc -n apk
- name: Helm release deploy APIM APK Agent
if: github.event_name == 'pull_request_target' && contains(github.event.label.name, 'trigger-action')
shell: sh
run: |
cd apk-repo/test/apim-apk-agent-test/agent-helm-chart
helm dependency build
helm install apim-apk-agent -n apk . --debug --wait --timeout 2m0s \
--set controlPlane.serviceURL=https://apim-wso2am-cp-1-service:9443/ \
--set controlPlane.eventListeningEndpoints=amqp://admin:admin@apim-wso2am-cp-1-service:5673?retries='10'&connectdelay='30' \
--set dataPlane.k8ResourceEndpoint=https://apk-wso2-apk-config-ds-service.apk.svc.cluster.local:9443/api/configurator/apis/generate-k8s-resources \
kubectl get pods -n apk
kubectl get svc -n apk
- name: Run test cases
shell: sh
run: |
cd apk-repo/test/apim-apk-agent-test/cucumber-tests
sh ./scripts/setup-hosts.sh
./gradlew runTests
- name: Helm release undeploy
if: always()
shell: sh
run: |
cd apk-repo/helm-charts
kubectl describe pods -n apk
kubectl get pods -n apk
kubectl get svc -n apk
helm uninstall apim-apk-agent -n apk
cd apk-repo/test/apim-apk-agent-test/apim-cp-helm-chart
helm uninstall apim -n apk
cd apk-repo/test/apim-apk-agent-test/agent-helm-chart
helm uninstall apim-apk-agent -n apk
- name: Delete AKS cluster
if: always()
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az aks delete --resource-group ${{ secrets.AZURE_RESOURCE_GROUP }} --name go-integ-${{ secrets.AKS_CLUSTER_NAME }}-${{ github.event.number || github.run_id }} --yes
- name: Logout from azure
if: always()
uses: azure/CLI@v1
with:
azcliversion: 2.44.1
inlineScript: |
az logout
- name: Publish Test Report
if: always()
uses: malinthaprasan/action-surefire-report@v1
with:
report_paths: 'apk-agent-repo/test/postman-tests/build/*.xml'
fail_on_test_failures: true
6 changes: 6 additions & 0 deletions test/apim-apk-agent-test/agent-helm-chart/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: cert-manager
repository: https://charts.jetstack.io
version: v1.10.1
digest: sha256:ec4c4f13caccd7a20912773027a411630546bcb6139744732d49806ce2514fc8
generated: "2024-01-22T12:10:42.822012+05:30"
24 changes: 24 additions & 0 deletions test/apim-apk-agent-test/agent-helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

apiVersion: v2
name: apim-apk-agent
description: A Helm chart for deploying apim-apk-agent
version: 0.1.0
dependencies:
- name: cert-manager
version: "v1.10.1"
repository: "https://charts.jetstack.io"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# The following manifests contain a self-signed issuer CR and a certificate CR.
# More document can be found at https://docs.cert-manager.io

apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: apim-apk-agent-server-cert
namespace: {{ .Release.Namespace }}
spec:
commonName: apim-apk-agent-service
privateKey:
algorithm: RSA
encoding: PKCS8
size: 2048

dnsNames:
- apim-apk-agent-service.{{ .Release.Namespace }}.svc
- apim-apk-agent-service.{{ .Release.Namespace }}.svc.cluster.local
issuerRef:
kind: "ClusterIssuer"
name: "apk-agent-selfsigned-issuer"
secretName: apk-agent-server-cert


Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: apk-agent-root-certificate
namespace: {{ .Release.Namespace }}
type: kubernetes.io/tls
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvVENDQWVXZ0F3SUJBZ0lVZDRuanY4eVNQZ283dDBGMWUyYUpFbzlUcFE0d0RRWUpLb1pJaHZjTkFRRUwKQlFBd0RqRU1NQW9HQTFVRUF3d0RZWEJyTUI0WERUSXpNRE13T1RBNE1UWXpORm9YRFRNek1ETXdOakE0TVRZegpORm93RGpFTU1Bb0dBMVVFQXd3RFlYQnJNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDCkFRRUExRzlCQWNWYTNhTWVteEVSWStKOFVtSC9XOEpwY0VPdGRlTlg1WU5paG5OT1h0bHZoU3pGek9QYUs5N1AKcjRJcUdBU2JWTmlSKzFKNldFb2kvYjZaSlR4MHEzWVVuMFlsUUpyejdnMjBUZG9HSmp4R1ZXem4wRVc0YmVIWApHcTYw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WRsT2ZYejUKUFdIQ3RJcWRkdlRkeG50TnpxekRnVzg9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2022, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: apk-agent-selfsigned-issuer
spec:
ca:
secretName: apk-agent-root-certificate
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Copyright (c) 2023, WSO2 LLC. (https://www.wso2.com) All Rights Reserved.
#
# WSO2 LLC. licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file except
# in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
labels:
app.kubernetes.io/app: "apim-apk-agent"
helm.sh/chart: {{ .Chart.Name }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/app: "apim-apk-agent"
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/app: "apim-apk-agent"
app.kubernetes.io/name: {{ .Chart.Name }}
app.kubernetes.io/instance: {{ .Release.Name }}
spec:
serviceAccountName: wso2agent-platform
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: grpc-port
containerPort: 18000
- name: rest-port
containerPort: 18001
env:
- name: APIM_APK_AGENT_PRIVATE_KEY_PATH
value: /home/wso2/security/keystore/apk-agent.key
- name: APIM_APK_AGENT_PUBLIC_CERT_PATH
value: /home/wso2/security/keystore/apk-agent.crt
- name: APIM_APK_AGENT_SERVER_NAME
value: apim-apk-agent-service.{{ .Release.Namespace }}.svc
- name: APIM_APK_AGENT_GRPC_PORT
value: "18000"
volumeMounts:
- name: log-conf-volume
mountPath: /home/wso2/conf/
- name: apk-agent-certificates
mountPath: /home/wso2/security/keystore/apk-agent.key
subPath: tls.key
- name: apk-agent-certificates
mountPath: /home/wso2/security/keystore/apk-agent.crt
subPath: tls.crt
- name: apk-agent-certificates
mountPath: /home/wso2/security/truststore/apk-agent-ca.crt
subPath: ca.crt
readinessProbe:
exec:
command: [ "sh", "check_health.sh" ]
initialDelaySeconds: 20
periodSeconds: 20
failureThreshold: 5
livenessProbe:
exec:
command: [ "sh", "check_health.sh" ]
initialDelaySeconds: 20
periodSeconds: 20
failureThreshold: 5
volumes:
- name: log-conf-volume
configMap:
name: {{ .Release.Name }}-log-conf
- name: apk-agent-certificates
secret:
secretName: apk-agent-server-cert
59 changes: 59 additions & 0 deletions test/apim-apk-agent-test/agent-helm-chart/templates/log-conf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-log-conf
namespace: {{ .Release.Namespace }}
data:
config.toml: |
[controlPlane]
enabled = {{ .Values.controlPlane.enabled }}
serviceURL = "{{ .Values.controlPlane.serviceURL }}"
username = "{{ .Values.controlPlane.username }}"
password = "{{ .Values.controlPlane.password }}"
environmentLabels = ["{{ .Values.controlPlane.environmentLabels }}"]
skipSSLVerification = {{ .Values.controlPlane.skipSSLVerification }}
[controlPlane.brokerConnectionParameters]
eventListeningEndpoints = ["{{ .Values.controlPlane.eventListeningEndpoints }}"]
[dataPlane]
enabled = {{ .Values.dataPlane.enabled }}
k8ResourceEndpoint = "{{ .Values.dataPlane.k8ResourceEndpoint }}"
namespace = "{{ .Values.dataPlane.namespace }}"
log_config.toml: |
# The logging configuration for Adapter
## Adapter root Level configurations
logLevel = "INFO" # LogLevels can be "DEBG", "FATL", "ERRO", "WARN", "INFO", "PANC"
LogFormat = "TEXT" # Values can be "JSON", "TEXT"
[rotation]
MaxSize = 10 # In MegaBytes (MB)
MaxBackups = 3
MaxAge = 2 # In days
Compress = true
## Adapter package Level configurations
[[pkg]]
name = "github.com/wso2/apk/adapter/internal/adapter"
logLevel = "INFO" # LogLevels can be "DEBG", "FATL", "ERRO", "WARN", "INFO", "PANC"
[[pkg]]
name = "github.com/wso2/apk/adapter/internal/oasparser"
logLevel = "INFO"
# The logging configuration for Router
[accessLogs]
enable = false
format = "[%START_TIME%] '%REQ(:METHOD)% %DYNAMIC_METADATA(envoy.filters.http.ext_authz:originalPath)% %REQ(:PATH)% %PROTOCOL%' %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% '%REQ(X-FORWARDED-FOR)%' '%REQ(USER-AGENT)%' '%REQ(X-REQUEST-ID)%' '%REQ(:AUTHORITY)%' '%UPSTREAM_HOST%'\n"
[wireLogs]
enable = false
include = ["Headers", "Body", "Trailers"]
# [[pkg]]
# name = "github.com/wso2/apk/Adapter/pkg/xds"
# logLevel = "INFO"
Loading

0 comments on commit 318c0a5

Please sign in to comment.