github.com/redhat-appstudio/e2e-tests@v0.0.0-20240520140907-9709f6f59323/docs/Installation.md (about)

     1  # RHTAP Installation locally and Openshift CI
     2  
     3  The following guide will walk through the necessary instruction about driving an installation of RHTAP locally or in Openshift CI.
     4  
     5  ## RHTAP in dev mode
     6  
     7  
     8  ### Requirements
     9  
    10  Requirements for installing RHTAP in E2E mode:
    11  
    12  * An OpenShift 4.12 or higher Environment (If you are using CRC/OpenShift Local please also review [optional-codeready-containers-post-bootstrap-configuration](https://github.com/redhat-appstudio/infra-deployments/blob/main/docs/development/deployment.md#optional-openshift-local-post-bootstrap-configuration))
    13  * A machine from which to run the install (usually your laptop) with required tools:
    14    * A properly setup Go workspace using **Go 1.19 is required**
    15    * The OpenShift Command Line Tool (oc) **Use the version corresponding to the Openshift version**
    16    * [yq]((https://github.com/mikefarah/yq))
    17    * jq
    18    * git
    19  * Tokens
    20    * Github Token with the following permissions
    21      * `repo`
    22      * `delete_repo`
    23      * `workflow`
    24    * Valid quay token where to push RHTAP components images generated by the e2e framework
    25  
    26  ### Installation
    27  
    28  1. Before deploying RHTAP in E2E mode you need to login to your OpenShift cluster with OpenShift Command Line Tool as `admin` (by default  `kubeadmin`):
    29  
    30     ```bash
    31      oc login -u <user> -p <password> --server=<oc_api_url>
    32     ```
    33  
    34  2. Export required (and recommended) environment variables from [default.env](../default.env). Copy the file (`cp default.env user.env`), edit the required variables and source it (`source user.env`).
    35  
    36  3. Install dependencies:
    37  
    38  ``` bash
    39  # Install dependencies
    40  $ go mod tidy
    41  # or go mod tidy -compat=1.21
    42  ```
    43  
    44  4. By default the installation script will use the `redhat-appstudio-qe` GitHub organization for pushing changes to `infra-deployments` repository.
    45  
    46  **It is recommended to use your fork of [infra-deployments repo](https://github.com/redhat-appstudio/infra-deployments) in your GitHub org instead** - you can change the GitHub organization with environment variable `export MY_GITHUB_ORG=<name-of-your-github-org>`.
    47  
    48  <details>
    49  <summary><h4>Advanced installation guidelines</h4></summary>
    50  <h5>GitHub Application for Pipelines as Code<h5>
    51  <p>
    52  
    53     Some tests could require you have a Github App created in order to test Component builds via Pipelines as Code.
    54  Such tests are [rhtap-demo](https://github.com/redhat-appstudio/e2e-tests/blob/main/tests/rhtap-demo/rhtap-demo.go), [build](https://github.com/redhat-appstudio/e2e-tests/blob/main/tests/build/build.go), and [status-reporting-to-pullrequest](https://github.com/redhat-appstudio/e2e-tests/blob/main/tests/integration-service/status-reporting-to-pullrequest.go).
    55  
    56  In this case, before you bootstrap a cluster, make sure you [created a Github App for your GitHub account](https://github.com/settings/apps). Fill in following details:
    57  </p>
    58  <ul><li> <b>GitHub App name</b>: unique app name</li> </ul>
    59  <ul><li> <b>Homepage URL</b>: some dummy URL (like https://example.com)</li></ul>
    60  <ul> <li> <b>Webhook</b>: mark as active and put some dummy URL to the <b>Webhook URL</b> field</li></ul>
    61  <ul> <li> <b>Permissions</b> and <b>Subscribe to events</b>: refer to <a href="https://pipelinesascode.com/docs/install/github_apps/#setup-manually">the guide in PaC documentation</a></li></ul>
    62  <ul> <li> <b>Where can this GitHub App be installed></b>: Any account</li> </ul>
    63  
    64  <p></p>
    65  
    66  Hit create, make a note of the <b>App ID</b> and navigate to the <b>Private keys</b> section where you generate a private key that gets downloaded automatically. Then export following environment variables (or if you're using .env file, update values of following variables):
    67  
    68  ```bash
    69  export E2E_PAC_GITHUB_APP_ID='<YOUR_APP_ID>'
    70  
    71  export E2E_PAC_GITHUB_APP_PRIVATE_KEY=$(base64 < /PATH/TO/YOUR/DOWNLOADED/PRIVATE_KEY.pem)
    72  ```
    73  
    74  <p>
    75  Navigate back to <a href="https://github.com/settings/apps">your GitHub App</a>, select Install App and select your GitHub org (the one that you're using in `MY_GITHUB_ORG` env var). Feel free to install it to all repositories of that organization or the forked repositories currently used by <a href="(https://github.com/redhat-appstudio/e2e-tests/blob/main/tests/rhtap-demo/rhtap-demo.go)">rhtap-demo</a> and <a href="(https://github.com/redhat-appstudio/e2e-tests/blob/main/tests/build/build.go">build tests</a>
    76  </p>
    77  
    78  </details>
    79  
    80  For bootstrapping a cluster, run the following command:
    81  
    82     ```bash
    83        make local/cluster/prepare
    84     ```
    85  
    86  More information about how to deploy RHTAP
    87  are in the [infra-deployments](https://github.com/redhat-appstudio/infra-deployments) repository.
    88  
    89  ### Building and running the e2e tests
    90  
    91  Most of the tests could require you to have specific container image repo's created (if you're using your own container image org/user account (`QUAY_E2E_ORGANIZATION`) or your own GitHub organization (`MY_GITHUB_ORG`).
    92  In that case, before you run the test, make sure you have created
    93  * `test-images` repo in quay.io, i.e. `quay.io/<QUAY_E2E_ORGANIZATION>/test-images` and make it **public** (this repo will be used for pushing container images produced by tests)
    94    * also make sure that the docker config, that is encoded in the value of `QUAY_TOKEN` environment variable, contains a correct credentials required to push to `test-images` repo. And make sure the robot account or user account has the **write** permissions set for `test-images` repo which is required by the tests to push the generated artifacts.
    95  * fork following GitHub repositories to your org (specified in `MY_GITHUB_ORG` env var)
    96    * https://github.com/redhat-appstudio-qe/devfile-sample-hello-world (for running build-service tests)
    97    * https://github.com/redhat-appstudio-qe/hacbs-test-project (for rhtap-demo test)
    98    * https://github.com/redhat-appstudio-qe/strategy-configs (for rhtap-demo test)
    99    * https://github.com/redhat-appstudio-qe/hacbs-test-project-integration (for status-reporting-to-pullrequest test)
   100  
   101  Note: All Environments used in all e2e-tests are in [default.env](../default.env) file. In case you need to run a specific tests, not all environments are necessary to be defined.
   102  
   103  You can use the following make target to build and run the tests:
   104     ```bash
   105        make local/test/e2e
   106     ```
   107  
   108  Or build and run the tests without scripts:
   109  1. Install dependencies and build the tests:
   110  
   111     ``` bash
   112     # Install dependencies
   113     $ go mod tidy
   114     # Create `e2e-appstudio` binary in bin folder. Please add the binary to the path or just execute `./bin/e2e-appstudio`
   115     $ make build
   116     ```
   117  
   118  2. Run the e2e tests:
   119  The `e2e-appstudio` command is the root command that executes all test functionality. To obtain all available flags for the binary please use `--help` flags. All ginkgo flags and go tests are available in `e2e-appstudio` binary.
   120  
   121  
   122     ```bash
   123        `./bin/e2e-appstudio`
   124     ```
   125  Note: The binary must be updated by running `make build` every time there are new changes in the tests.
   126  
   127  The instructions for every test suite can be found in the [tests folder](tests), e.g. [has Readme.md](tests/rhtap-demo/README.md).
   128  You can also specify which tests you want to run using [labels](docs/LabelsNaming.md) or [Ginkgo Focus](docs/DeveloperFocus.md).
   129  
   130  
   131  ## RHTAP in Openshift CI and branch pairing
   132  
   133  The e2e tests are executed against almost all AppStudio repositories.
   134  
   135  Sometimes when we have changes in AppStudio we are introducing some breaking changes and the e2e will fail. To prevent this the e2e framework installation in openshift-ci support a new feature of pairing the PR opened against an AppStudio repository with a corresponding PR opened against e2e-tests (based on branch names). Before the e2e framework will be executed in openshift-ci, the logic automatically tries to pair a PR opened in some repo with a branch of the same name that
   136  potentially could exists in the developer's fork of the e2e repository
   137  
   138  For example, if a developer with GH account `cooljohn` opens a PR (for application-service repo) from a branch `new-feature`, then the logic checks if there is a PR open in e2e-tests from the `new-feature` branch in the `cooljohn/e2e-tests` fork. If such a PR is found, the CI will install the e2e framework from that branch.
   139  
   140  Once the service PR passes CI with its pairing and is merged, the next step is to get the references in infra-deployments updated.
   141  Many services have automation to create PRs in infra-deployments to update their component to the latest version.
   142  However, this recently merged latest version will likely need the still unmerged e2e-tests update.
   143  The solution is to manually create a PR to infra-deployments that bumps the component version with the *same* branch name.
   144  This will allow the infra-deployments CI to run with your branch of e2e-tests, allowing the CI to pass.
   145  Finally, once the infra-deployments CI passes and PR merges, you should be able to rerun your e2e-tests PR and have it pass and merge.
   146  
   147  To continue on the previous example, once the application-service PR merges, `cooljohn` should open a pull request to infra-deployments using the branch `new-feature`
   148  to bump the application-service version to the one recently created by the application-service PR merging. This lets the infra-deployments CI run with the required
   149  e2e-tests changes from `cooljohn`'s fork.
   150  
   151  Pairing PRs is handled automatically by running this command from a root directory of this repository:
   152  
   153  ```bash
   154     make ci/test/e2e
   155  ```