Skip to content

Commit fb05dc8

Browse files
authored
Fleetqa/test basic gitapp (#409)
* Adding Github App test
1 parent 6738163 commit fb05dc8

File tree

10 files changed

+99
-0
lines changed

10 files changed

+99
-0
lines changed

.github/workflows/master-e2e.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ on:
5959
aws_secret_access_key:
6060
description: AWS Secret Access Key to use to create EC2 instances
6161
required: false
62+
github_app_id:
63+
description: GitHub App ID for github app connection
64+
required: false
65+
github_app_installation_id:
66+
description: GitHub App Installation ID for github app connection
67+
required: false
68+
github_app_private_key:
69+
description: GitHub App Private Key for github app connection
70+
required: false
6271

6372
inputs:
6473
branch:
@@ -337,6 +346,9 @@ jobs:
337346
RSA_PUBLIC_KEY_QA: ${{ secrets.rsa_public_key_qa }}
338347
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
339348
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
349+
GH_APP_ID: ${{ secrets.github_app_id }}
350+
GH_APP_INSTALLATION_ID: ${{ secrets.github_app_installation_id }}
351+
GH_APP_PRIVATE_KEY: ${{ secrets.github_app_private_key }}
340352
GREPTAGS: ${{ inputs.grep_test_by_tag }}
341353
UPGRADE: 'false'
342354
# Add cypress/e2e/unit_tests/user.spec.ts again when implementing RBAC tests.
@@ -435,6 +447,9 @@ jobs:
435447
RSA_PUBLIC_KEY_QA: ${{ secrets.rsa_public_key_qa }}
436448
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
437449
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
450+
GH_APP_ID: ${{ secrets.github_app_id }}
451+
GH_APP_INSTALLATION_ID: ${{ secrets.github_app_installation_id }}
452+
GH_APP_PRIVATE_KEY: ${{ secrets.github_app_private_key }}
438453
GREPTAGS: ${{ inputs.grep_test_by_tag }}
439454
UPGRADE: ${{ inputs.upgrade }}
440455
FLEET_APP_VERSION: ${{ steps.component.outputs.fleet_app_version }}

.github/workflows/ui-pr_rm_current.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ jobs:
3232
qase_api_token: ${{ secrets.QASE_API_TOKEN }}
3333
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
3434
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
35+
github_app_id: ${{ secrets.GH_APP_ID }}
36+
github_app_installation_id: ${{ secrets.GH_APP_INSTALLATION_ID }}
37+
github_app_private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
3538
with:
3639
test_description: "CI test for PR#${{ github.event.pull_request.number }} with K3s"
3740
cluster_name: cluster-k3s

.github/workflows/ui-rm_head.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ jobs:
5151
qase_api_token: ${{ secrets.QASE_API_TOKEN }}
5252
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
5353
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
54+
github_app_id: ${{ secrets.GH_APP_ID }}
55+
github_app_installation_id: ${{ secrets.GH_APP_INSTALLATION_ID }}
56+
github_app_private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
5457
with:
5558
test_description: "CI/Manual - UI - Deployment test with Standard K3s"
5659
cluster_name: cluster-k3s

.github/workflows/ui-rm_prime_alpha_rc.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ jobs:
5050
rsa_private_key_qa: ${{ secrets.RSA_PRIVATE_KEY_QA }}
5151
rsa_public_key_qa: ${{ secrets.RSA_PUBLIC_KEY_QA }}
5252
qase_api_token: ${{ secrets.QASE_API_TOKEN }}
53+
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
54+
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
55+
github_app_id: ${{ secrets.GH_APP_ID }}
56+
github_app_installation_id: ${{ secrets.GH_APP_INSTALLATION_ID }}
57+
github_app_private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
5358
with:
5459
test_description: "CI/Manual - UI - Deployment test with Standard K3s"
5560
cluster_name: cluster-k3s
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: fleet.cattle.io/v1alpha1
2+
kind: GitRepo
3+
metadata:
4+
name: gitapp-test
5+
namespace: fleet-local
6+
spec:
7+
branch: master
8+
clientSecretName: github-app-secret
9+
repo: https://github.com/fleetrepoci/test
10+
pollingInterval: 1m0s
11+
12+

tests/cypress/e2e/unit_tests/p1_2_fleet.spec.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,3 +1541,45 @@ describe('Test Fleet `doNotDeploy: false` will deploy resources to all clusters.
15411541
})
15421542
)
15431543
});
1544+
1545+
if (!/\/2\.11/.test(Cypress.env('rancher_version')) && !/\/2\.12/.test(Cypress.env('rancher_version'))) {
1546+
1547+
describe('Test Git App with Fleet', { tags: '@p1_2'}, () => {
1548+
qase(199,
1549+
it("Fleet-199: Test Git App deployment using Fleet.", { tags: '@fleet-199' }, () => {
1550+
1551+
const github_app_id = Cypress.env("gh_app_id")
1552+
const github_app_installation_id = Cypress.env("gh_app_installation_id")
1553+
const github_app_private_key = Cypress.env("gh_app_private_key")
1554+
1555+
// Create secret from UI
1556+
cy.accesMenuSelection('local', 'Storage', 'Secrets');
1557+
cy.nameSpaceMenuToggle('All Namespaces');
1558+
cy.clickButton('Create');
1559+
cy.get('div.title.with-description').contains('Opaque').should('be.visible').click();
1560+
cy.get('div[data-testid="name-ns-description-namespace"]').should('exist').click();
1561+
1562+
// This is necessary to select 'fleet-local' from the dropdown and not 'cattle-fleet-local-system' option
1563+
cy.contains("div.vs__option-kind", "fleet-local ").should('exist').click();
1564+
cy.typeValue('Name', 'github-app-secret');
1565+
1566+
cy.get("section[id='data'] input[placeholder='e.g. foo']").type('github_app_id');
1567+
cy.get("section[id='data'] textarea[placeholder='e.g. bar']").type(github_app_id);
1568+
cy.clickButton('Add');
1569+
1570+
cy.get("section[id='data'] input[placeholder='e.g. foo']").eq(1).type('github_app_installation_id');
1571+
cy.get("section[id='data'] textarea[placeholder='e.g. bar']").eq(1).type(github_app_installation_id);
1572+
cy.clickButton('Add');
1573+
1574+
cy.get("section[id='data'] input[placeholder='e.g. foo']").eq(2).type('github_app_private_key');
1575+
cy.get("section[id='data'] textarea[placeholder='e.g. bar']").eq(2).type(github_app_private_key, false);
1576+
cy.wait(2000);
1577+
cy.clickButton('Create');
1578+
1579+
// Create GitRepo and validate active status
1580+
cy.addFleetRepoFromYaml('assets/gitapp-test/fleet.yaml');
1581+
cy.verifyTableRow(0, 'Active', '1/1');
1582+
})
1583+
)
1584+
});
1585+
};

tests/cypress/plugins/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ module.exports = (on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions)
5252
config.env.k8s_version_upgrade_ds_cluster_to = process.env.K8S_VERSION_UPGRADE_DS_CLUSTER_TO
5353
config.env.aws_access_key_id = process.env.AWS_ACCESS_KEY_ID;
5454
config.env.aws_secret_access_key = process.env.AWS_SECRET_ACCESS_KEY;
55+
config.env.gh_app_id = process.env.GH_APP_ID;
56+
config.env.gh_app_installation_id = process.env.GH_APP_INSTALLATION_ID;
57+
config.env.gh_app_private_key = process.env.GH_APP_PRIVATE_KEY;
5558

5659
return config;
5760
};

tests/cypress/support/commands.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,17 @@ Cypress.Commands.add('continuousDeliveryBundlesMenu', () => {
136136
});
137137
});
138138

139+
// Command to add Fleet Repo from YAML file
140+
Cypress.Commands.add('addFleetRepoFromYaml', (yamlFilePath, fleetNamespace='fleet-local') => {
141+
cy.continuousDeliveryMenuSelection();
142+
cy.fleetNamespaceToggle(fleetNamespace);
143+
cy.clickButton('Create App Bundle');
144+
cy.get('[data-testid="subtype-banner-item-fleet.cattle.io.gitrepo"]').should('be.visible').click();
145+
cy.clickButton('Edit as YAML');
146+
cy.addYamlFile(yamlFilePath);
147+
cy.clickButton('Create');
148+
});
149+
139150
// Command add and edit Fleet Git Repository
140151
// TODO: Rename this command name to 'addEditFleetGitRepo'
141152
Cypress.Commands.add('addFleetGitRepo', ({ repoName, repoUrl, branch, path, path2, gitOrHelmAuth, gitAuthType, userOrPublicKey, pwdOrPrivateKey, tlsOption, tlsCertificate, keepResources, correctDrift, fleetNamespace='fleet-local', editConfig=false, helmUrlRegex, deployToTarget, allowedTargetNamespace="", local=false }) => {

tests/cypress/support/e2e.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ declare global {
7777
createCloudCluster(cloudInstanceType: string, clusterName: string, subnetId: string): Chainable<Element>;
7878
deleteDownstreamCluster(clusterName: string, deleteOption?: boolean): Chainable<Element>;
7979
addHelmOp(fleetNamespace: string?, repoName: string, repoUrl: string, chart: string, version?: string, values?: string, deployTo?: string, serviceAccountName?: string, targetNamespace?: string, helmAuth?: string): Chainable<Element>;
80+
addFleetRepoFromYaml(yamlFilePath: string, fleetNamespace?: string): Chainable<Element>;
81+
8082
}
8183
}
8284
}

tests/scripts/start-cypress-tests

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ docker run --init -v $PWD:/workdir -w /workdir \
3232
-e "K8S_VERSION_UPGRADE_DS_CLUSTER_TO=$K8S_VERSION_UPGRADE_DS_CLUSTER_TO" \
3333
-e "AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID" \
3434
-e "AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY" \
35+
-e "GH_APP_ID=$GH_APP_ID" \
36+
-e "GH_APP_INSTALLATION_ID=$GH_APP_INSTALLATION_ID" \
37+
-e "GH_APP_PRIVATE_KEY=$GH_APP_PRIVATE_KEY" \
3538
--add-host host.docker.internal:host-gateway \
3639
--ipc=host \
3740
$CYPRESS_DOCKER \

0 commit comments

Comments
 (0)