diff --git a/.github/workflows/porter_stack_integration-test-provisioning.yml b/.github/workflows/porter_stack_integration-test-provisioning.yml new file mode 100644 index 0000000..ab2f92c --- /dev/null +++ b/.github/workflows/porter_stack_integration-test-provisioning.yml @@ -0,0 +1,36 @@ +"on": + push: + branches: + - sms/intgtests +name: Deploy to integration-test-provisioning +jobs: + porter-deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set Github tag + id: vars + run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT + - name: Setup porter + uses: porter-dev/setup-porter@v0.1.0 + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: portersupport + password: ${{ secrets.IMAGE_BUILD_TOKEN }} + - name: Pull unauthenticated images + run: | + docker pull ghcr.io/porter-dev/cluster-control-plane/ccp-cli:latest + - name: Deploy stack + timeout-minutes: 30 + run: exec porter apply + env: + PORTER_CLUSTER: "11" + PORTER_HOST: https://dashboard.internal-tools.porter.run + PORTER_PR_NUMBER: ${{ github.event.number }} + PORTER_PROJECT: "8" + PORTER_STACK_NAME: integration-test-provisioning + PORTER_TAG: ${{ steps.vars.outputs.sha_short }} + PORTER_TOKEN: ${{ secrets.PORTER_STACK_8_11 }} diff --git a/README.md b/README.md index 0c6d9cf..def878e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,14 @@ # app-integration-tests Central location for test apps and test `porter.yaml` files. + +# Tests Summary: + +## Provisioning + +Runs the following tests on internal-tools project, application (integration-test-provisioning), against project 468, in AWS account 081277119371. Uses the Porter CLI and CCP CLI to ensure that clusters can be created and deleted. Triggers in honeycomb should alert on all failures + +- Create a cluster every morning +- Delete a cluster every night +- Every 2 hours, perform an instance type change +- Update permissions every hour diff --git a/provisioning/Dockerfile b/provisioning/Dockerfile new file mode 100644 index 0000000..b87d8d4 --- /dev/null +++ b/provisioning/Dockerfile @@ -0,0 +1,12 @@ +FROM ghcr.io/porter-dev/porter/porter-cli:latest as porter-cli +FROM ghcr.io/porter-dev/cluster-control-plane/ccp-cli:latest as ccp-cli + +RUN apt update +RUN apt install -y software-properties-common +RUN apt update +RUN add-apt-repository -y ppa:rmescandon/yq +RUN apt install -y gettext-base yq jq + +COPY --from=porter-cli /usr/local/bin/porter /usr/local/bin/porter + +COPY testdata . diff --git a/provisioning/testdata/cluster-basic-no-id-template.json b/provisioning/testdata/cluster-basic-no-id-template.json new file mode 100644 index 0000000..d58305e --- /dev/null +++ b/provisioning/testdata/cluster-basic-no-id-template.json @@ -0,0 +1,41 @@ +{ + "cluster": { + "cloudProvider": "ENUM_CLOUD_PROVIDER_AWS", + "cloudProviderCredentialsId": "arn:aws:iam::081277119371:role/porter-manager", + "eksKind": { + "clusterName": "integration-test", + "clusterVersion": "v1.27.0", + "loadBalancer": {}, + "logging": {}, + "network": { + "serviceCidr": "172.20.0.0/16", + "vpcCidr": "10.78.0.0/16" + }, + "nodeGroups": [ + { + "instanceType": "t3.medium", + "maxInstances": 5, + "minInstances": 1, + "nodeGroupType": "NODE_GROUP_TYPE_SYSTEM" + }, + { + "instanceType": "t3.large", + "isStateful": true, + "maxInstances": 5, + "minInstances": 1, + "nodeGroupType": "NODE_GROUP_TYPE_MONITORING" + }, + { + "instanceType": "t3.medium", + "maxInstances": 10, + "minInstances": 1, + "nodeGroupType": "NODE_GROUP_TYPE_APPLICATION" + } + ], + "region": "us-east-1" + }, + "kind": "ENUM_KUBERNETES_KIND_EKS", + "projectId": $PROJECT_ID + }, + "complianceProfiles": {} +} \ No newline at end of file diff --git a/provisioning/testdata/cluster-basic-with-id-template.json b/provisioning/testdata/cluster-basic-with-id-template.json new file mode 100644 index 0000000..c4f4a04 --- /dev/null +++ b/provisioning/testdata/cluster-basic-with-id-template.json @@ -0,0 +1,42 @@ +{ + "cluster": { + "cloudProvider": "ENUM_CLOUD_PROVIDER_AWS", + "cloudProviderCredentialsId": "arn:aws:iam::081277119371:role/porter-manager", + "eksKind": { + "clusterName": "integration-test", + "clusterVersion": "v1.27.0", + "loadBalancer": {}, + "logging": {}, + "network": { + "serviceCidr": "172.20.0.0/16", + "vpcCidr": "10.78.0.0/16" + }, + "nodeGroups": [ + { + "instanceType": "t3.medium", + "maxInstances": 5, + "minInstances": 1, + "nodeGroupType": "NODE_GROUP_TYPE_SYSTEM" + }, + { + "instanceType": "t3.large", + "isStateful": true, + "maxInstances": 5, + "minInstances": 1, + "nodeGroupType": "NODE_GROUP_TYPE_MONITORING" + }, + { + "instanceType": "t3.medium", + "maxInstances": 10, + "minInstances": 1, + "nodeGroupType": "NODE_GROUP_TYPE_APPLICATION" + } + ], + "region": "us-east-1" + }, + "kind": "ENUM_KUBERNETES_KIND_EKS", + "projectId": $PROJECT_ID, + "clusterId": $CLUSTER_ID + }, + "complianceProfiles": {} +} \ No newline at end of file diff --git a/provisioning/testdata/delete-cluster.sh b/provisioning/testdata/delete-cluster.sh new file mode 100755 index 0000000..01f77e8 --- /dev/null +++ b/provisioning/testdata/delete-cluster.sh @@ -0,0 +1,28 @@ +#! /bin/bash +set -euo pipefail + +if [ -z "$PROJECT_ID" ]; +then + echo "Project ID is not set" + exit 1 +fi +echo "Project ID: $PROJECT_ID" + +if [ -z "$CLUSTER_ID" ]; +then + echo "Cluster ID is not set" + exit 1 +fi +echo "Cluster ID: $CLUSTER_ID" + +echo "Deleting cluster" +ccp-cli manage contract delete --project-id $PROJECT_ID --cluster-id $CLUSTER_ID + +export NEXT_INSTANCE_TYPE="t3.large" +export CURRENT_INSTANCE_TYPE="t3.medium" +export CLUSTER_ID="0" + +echo "Updating values in Porter" + +envsubst < template-porter.yaml > porter.yaml +porter apply -f porter.yaml \ No newline at end of file diff --git a/provisioning/testdata/template-porter.yaml b/provisioning/testdata/template-porter.yaml new file mode 100644 index 0000000..2dc69d9 --- /dev/null +++ b/provisioning/testdata/template-porter.yaml @@ -0,0 +1,10 @@ +version: v2 +name: integration-test-provisioning +env: + CLUSTER_ID: $CLUSTER_ID + PROJECT_ID: $PROJECT_ID + NEXT_INSTANCE_TYPE: $NEXT_INSTANCE_TYPE + CURRENT_INSTANCE_TYPE: $CURRENT_INSTANCE_TYPE +services: + - name: cluster-update + type: job diff --git a/provisioning/testdata/update-cluster.sh b/provisioning/testdata/update-cluster.sh new file mode 100755 index 0000000..f113e4f --- /dev/null +++ b/provisioning/testdata/update-cluster.sh @@ -0,0 +1,58 @@ +#! /bin/bash +set -euo pipefail + +contractname=cluster-basic-no-id.json + +if [ -z "$PROJECT_ID" ]; +then + echo "Project ID is not set" + exit 1 +fi +echo "Project ID: $PROJECT_ID" + +if [ -z "$CLUSTER_ID" ]; +then + echo "Cluster ID is not set" + exit 1 +fi +echo "Cluster ID: $CLUSTER_ID" + +if [ -z "$CURRENT_INSTANCE_TYPE" ]; +then + echo "Current instance type is not set" + exit 1 +fi +echo "Current instance type: $CURRENT_INSTANCE_TYPE" + +if [ -z "$NEXT_INSTANCE_TYPE" ]; +then + echo "Next instance type is not set" + exit 1 +fi +echo "Next instance type: $NEXT_INSTANCE_TYPE" + +if [ $CLUSTER_ID = 0 ]; +then + contractname=cluster-basic-no-id.json + envsubst < cluster-basic-no-id-template.json > apply-contract.json +else + contractname=cluster-basic-with-id.json + envsubst < cluster-basic-with-id-template.json > apply-contract.json +fi + +echo "Applying contract to cluster. If this returns an error, another integration test may be in progress. Please wait a few minutes and try again." +clusterid=$(ccp-cli manage contract update -f apply-contract.json -o json | jq '.cluster_id') +echo "Cluster ID: $clusterid" + +NEXT_TYPE=$CURRENT_INSTANCE_TYPE +CURRENT_TYPE=$NEXT_INSTANCE_TYPE +CLUSTER_ID=$clusterid + +export NEXT_INSTANCE_TYPE=$NEXT_TYPE +export CURRENT_INSTANCE_TYPE=$CURRENT_TYPE +export CLUSTER_ID=$CLUSTER_ID + +echo "Updating values in Porter" + +envsubst < template-porter.yaml > porter.yaml +porter apply -f porter.yaml \ No newline at end of file diff --git a/provisioning/testdata/update-permissions.sh b/provisioning/testdata/update-permissions.sh new file mode 100755 index 0000000..57483da --- /dev/null +++ b/provisioning/testdata/update-permissions.sh @@ -0,0 +1,9 @@ +#! /bin/bash + +if [ -z "$PROJECT_ID" ]; +then + echo "Project ID is not set" + exit 1 +fi + +ccp-cli manage cloud update-permissions --project-id $PROJECT_ID \ No newline at end of file