|
| 1 | +## End-to-end Cypress tests for Konveyor UI |
| 2 | + |
| 3 | +## Getting Started |
| 4 | + |
| 5 | +### Requirements |
| 6 | + |
| 7 | +1. Operating system (typically Fedora or macOS) |
| 8 | +2. Install Node.js 20 or above (OS native packages, or [nodejs](https://nodejs.org/en/download), or [nvm](https://github.com/nvm-sh/nvm) managed installs are all ok) |
| 9 | + |
| 10 | +### Install and run automation |
| 11 | + |
| 12 | +1. Clone automation repository and setup |
| 13 | + |
| 14 | + ```sh |
| 15 | + git clone https://github.com/konveyor/tackle2-ui.git |
| 16 | + cd tackle2-ui |
| 17 | + npm clean-install |
| 18 | + ``` |
| 19 | + |
| 20 | +2. Setup your cypress environment |
| 21 | + Copy the sample `cypress/.env.example` to `cypress/.env` and update for your environment. The variables |
| 22 | + in this file will not override and existing exported environment variables. |
| 23 | + |
| 24 | + ```sh |
| 25 | + cp cypress/.env.example cypress/.env |
| 26 | + ``` |
| 27 | + |
| 28 | +3. Open Cypress and run test cases |
| 29 | + ```sh |
| 30 | + cd cypress |
| 31 | + npx cypress open |
| 32 | + ``` |
| 33 | + |
| 34 | +## Required Parameters for Tests |
| 35 | + |
| 36 | +Some tests require certain configuration parameters to be correctly defined in the `cypress.config.ts` file. Below is a list of tests and the parameters they require. |
| 37 | + |
| 38 | +- `export_to_jira_datacenter.test.ts` |
| 39 | + - `jira_stage_datacenter_project_id` |
| 40 | + - `jira_stage_bearer_token` |
| 41 | + - `jira_stage_datacenter_url` |
| 42 | + |
| 43 | +- `export_to_jira_cloud.test.ts` |
| 44 | + - `jira_atlassian_cloud_project` |
| 45 | + - `jira_atlassian_cloud_email` |
| 46 | + - `jira_atlassian_cloud_token` |
| 47 | + - `jira_atlassian_cloud_url` |
| 48 | + |
| 49 | +- `source_analysis.test.ts` and `binary_analysis.test.ts` |
| 50 | + - `git_user` |
| 51 | + - `git_password` |
| 52 | + |
| 53 | +## Code formatting using Prettier tool |
| 54 | + |
| 55 | +Husky and lint-staged are used to format staged files when committing. |
| 56 | + |
| 57 | +To manually check the code formatting: `npm run lint` |
| 58 | + |
| 59 | +To manually format the cypress code: `npm run lint:fix` |
| 60 | + |
| 61 | +## Pull request testing |
| 62 | + |
| 63 | +1. Update Pull request with upstream main branch |
| 64 | +2. Pull requests will be tested against environment before merging to main codebase |
| 65 | +3. Pull request's owner must add **RFR** label once pull request is ready to test against environment |
| 66 | +4. After adding **RFR** label, the PR owner should force push the pull request to trigger GitHub action |
| 67 | +5. In some cases, the reviewer wants to trigger the PR test GH action but they can't force push to the PR branch. Hence added feature of triggering GH action manually. Steps to trigger GH action for PR testing manually: |
| 68 | + - Go to Actions tab |
| 69 | + - Click on GH action(Pull request test) |
| 70 | + - Click on run workflow dropdown |
| 71 | + - select PR branch |
| 72 | + - Click on button Run workflow |
| 73 | + |
| 74 | +## Tag based test execution |
| 75 | + |
| 76 | +This repository uses the package [cypress-tags](https://www.npmjs.com/package/cypress-tags) to slice up test runs. |
| 77 | + |
| 78 | +1. To run tests based on tags, use below command |
| 79 | + |
| 80 | + ```sh |
| 81 | + CYPRESS_INCLUDE_TAGS=@tagName npx cypress run |
| 82 | + ``` |
| 83 | + |
| 84 | +2. To run multiple tags(tiers) in a single run, provide tag names separated by commas |
| 85 | + ```sh |
| 86 | + CYPRESS_INCLUDE_TAGS=@tier1,@tier2 npx cypress run |
| 87 | + ``` |
| 88 | + |
| 89 | +## Running tests locally with Konveyor operator installed to minikube |
| 90 | + |
| 91 | +1. Install minikube on your local machine by referring to [docs](https://minikube.sigs.k8s.io/docs/start/) |
| 92 | + |
| 93 | +1. Setup recommended minikube configurations and start minikube with the ingress addon |
| 94 | + |
| 95 | + ```sh |
| 96 | + minikube config set memory 10240 |
| 97 | + minikube config set cpus 4 |
| 98 | + minikube start --addons=ingress |
| 99 | + ``` |
| 100 | + |
| 101 | +1. Install kubectl if needed, or substitute `minikube kubectl --` for all `kubectl` commands. |
| 102 | + |
| 103 | +1. Install [OLM manually](https://github.com/operator-framework/operator-lifecycle-manager/releases) |
| 104 | + |
| 105 | + ```sh |
| 106 | + curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.28.0/install.sh -o install.sh |
| 107 | + chmod +x install.sh |
| 108 | + ./install.sh v0.28.0 |
| 109 | + ``` |
| 110 | + |
| 111 | +1. Install the Konveyor operator ([operator install](https://github.com/konveyor/operator?tab=readme-ov-file#konveyor-operator-installation-on-k8s)) to the default namespace **konveyor-tackle** |
| 112 | + |
| 113 | + ```sh |
| 114 | + kubectl apply -f https://raw.githubusercontent.com/konveyor/operator/main/tackle-k8s.yaml |
| 115 | + ``` |
| 116 | + |
| 117 | +1. Create a Tackle CR (setting the spec values as needed) |
| 118 | + |
| 119 | + ```sh |
| 120 | + cat << EOF | kubectl apply -f - |
| 121 | + kind: Tackle |
| 122 | + apiVersion: tackle.konveyor.io/v1alpha1 |
| 123 | + metadata: |
| 124 | + name: tackle |
| 125 | + namespace: konveyor-tackle |
| 126 | + spec: |
| 127 | + feature_auth_required: false |
| 128 | + EOF |
| 129 | + ``` |
| 130 | +
|
| 131 | +1. Wait for the tackle ingress to become available |
| 132 | +
|
| 133 | + ```sh |
| 134 | + kubectl wait -n konveyor-tackle ingress/tackle --for=jsonpath='{.status.loadBalancer.ingress[0]}' --timeout=600s |
| 135 | + ``` |
| 136 | +
|
| 137 | +1. Once the Konveyor UI ingress is running, tests can be run against this local instance, with video captures of the tests turned on, using the command |
| 138 | + ```sh |
| 139 | + CYPRESS_baseUrl=https://$(minikube ip) npx cypress run --config video=true |
| 140 | + ``` |
| 141 | +
|
| 142 | +## Tags and Tiers in Konveyor UI tests |
| 143 | +
|
| 144 | +### Tags |
| 145 | +
|
| 146 | +### `@interOp` tag: (Used by interOp team, rosa, rosa-sts, aro clusters) |
| 147 | +
|
| 148 | +Tests include: |
| 149 | +
|
| 150 | +- “Creating source control credentials with username/password” |
| 151 | +- “Custom Migration Targets CRUD operations” |
| 152 | +- “Analysis for acmeair app upload binary” |
| 153 | +- “Test inheritance after discarding application assessment and review” |
| 154 | +- “Business service CRUD operations” |
| 155 | +- “Stakeholder CRUD operations” |
| 156 | +- “Migration Waves CRUD operations” |
| 157 | +
|
| 158 | +### `@ci` tag: |
| 159 | +
|
| 160 | +- Runs on minikube for CI testing https://github.com/konveyor/ci |
| 161 | +- Running tests on GitHub Actions on minikube has some constraints like |
| 162 | + 1. Limited resources |
| 163 | + 2. Cannot run tests with credentials |
| 164 | + 3. Time taken to run CI tests |
| 165 | +
|
| 166 | +Considering the above factors, we are including tests that are most necessary to test functionality of MTA while merging a PR. More tests will be added here once they're stabilized. |
| 167 | +
|
| 168 | +Tests include: |
| 169 | +
|
| 170 | +- “Business service CRUD” |
| 171 | +- "Jobfunction CRUD" |
| 172 | +- "Stakeholder , Stakeholder Group , Tag and Archetype CRUD operations" |
| 173 | +- "Application assessment, review, analyze and validate efforts and issues" |
| 174 | +
|
| 175 | +### `@tier0` tag: |
| 176 | +
|
| 177 | +Basic sanity tests. Runs on stage and production and nightly runs on [Konveyor CI](https://github.com/konveyor/ci). |
| 178 | +
|
| 179 | +Tests include: |
| 180 | +
|
| 181 | +- “Creating source control credentials with username/password |
| 182 | +- ”Custom Migration Targets CRUD operations |
| 183 | +- “Source Analysis on bookserver app and its issues validation” |
| 184 | +- “Source analysis on bookserver app with EAP8 target” |
| 185 | +- “Test inheritance after discarding application assessment and review” |
| 186 | +- “Business service CRUD operations” |
| 187 | +- “Migration Waves CRUD operations” |
| 188 | +
|
| 189 | +### `@tier1` tag: |
| 190 | +
|
| 191 | +Includes analysis tests like binary and source+dependencies with credentials, runs on nightly [Konveyor CI](https://github.com/konveyor/ci). |
| 192 | +
|
| 193 | +### `@tier2` tag: |
| 194 | +
|
| 195 | +CRUD tests for all functionality |
| 196 | +
|
| 197 | +### `@tier3` tag: |
| 198 | +
|
| 199 | +Sorting/filtering for all functionality |
| 200 | +
|
| 201 | +### `@tier4` tag: |
| 202 | +
|
| 203 | +Load and performance tests. |
| 204 | +
|
| 205 | +## License's header management |
| 206 | +
|
| 207 | +To check if the license's header is available in all eligible files, execute: |
| 208 | +
|
| 209 | +```shell |
| 210 | +yarn license-check-and-add check |
| 211 | +``` |
| 212 | +
|
| 213 | +To add the license's header to all eligible files, execute: |
| 214 | +
|
| 215 | +```shell |
| 216 | +yarn license-check-and-add add |
| 217 | +``` |
| 218 | +
|
| 219 | +## Code of Conduct |
| 220 | +
|
| 221 | +Refer to Konveyor's Code of Conduct [here](https://github.com/konveyor/community/blob/main/CODE_OF_CONDUCT.md). |
0 commit comments