From ff561b934ee5f1a6a8a9eb7c55794a39aca384ed Mon Sep 17 00:00:00 2001 From: acammies <acammies@redhat.com> Date: Mon, 16 Apr 2018 16:32:25 +0200 Subject: [PATCH] Added in API pipeline testing --- 3-revenge-of-the-automated-testing/README.md | 25 ++++++++++++++++++++++++- images/exercise3/api-post-build.png | 0 images/exercise3/api-build-step.png | 0 images/exercise3/api-fail-build.png | 0 4 files changed, 24 insertions(+), 1 deletions(-) diff --git a/3-revenge-of-the-automated-testing/README.md b/3-revenge-of-the-automated-testing/README.md index b7a3525..962464b 100644 --- a/3-revenge-of-the-automated-testing/README.md +++ b/3-revenge-of-the-automated-testing/README.md @@ -90,7 +90,30 @@ 2. Rerun the `dev-todolist-fe-build` job. It should have failed and not run any other builds. ![new-gitlab-proj](../images/exercise3/jenkins-with-failing-build.png) -2. Undo the changes you made to the `ListOfTodos.spec.js` file, commit your code and rerun the build. This should trigger a full `build --> bake --> deploy`. +2. Undo the changes you made to the `ListOfTodos.spec.js` file, commit your code and rerun the build. This should trigger a full `build --> bake --> deploy` of `todolist-fe`. + +2. We're now going to do the same for the api. Head to the `configure` panel of the `dev-todolist-api-build` job. + +2. Add `scl enable rh-nodejs8 'npm run test:ci'` above `npm run build:ci`. +![new-gitlab-proj](../images/exercise3/api-build-step.png) + +2. [break me up and add screenshots] Scroll to the `Post-build Actions` section and click `Add post-build action`. Select `Publish xUnit test result report`. + +2. Click the `Add` button under `Publish xUnit test result report` and select `JUnit`. In the pattern field enter `reports/server/mocha/test-results.xml`. In the `Failed Tests Thresholds` input box enter 0 under `Red Ball Total`. It should look a little something like this: +![new-gitlab-proj](../images/exercise3/api-post-build.png) + +2. We're now going to deliberately fail a test again to ensure that `bake` and `deploy` jobs aren't triggered if any tests fail. Go to `todo.spec.js` in `/server/api/todo` and head to `line 35`. Replace `false` with `true`. +![new-gitlab-proj](../images/exercise3/api-fail-build.png) + +2. Push this to Gitlab and rerun the build job. +```bash +$ git add . +$ git commit -m "Deliberately failed test to test the pipeline stops me deploying broken code" +$ git push +``` + +2. If successful this will fail the build and not run the `bake` or `deploy` jobs. Don't forget to remove the changes that you made to your tests! + <!-- 2. TODO - add tests to jenkins with screenshots etc. --> diff --git a/images/exercise3/api-build-step.png b/images/exercise3/api-build-step.png new file mode 100644 index 0000000..db02e20 --- /dev/null +++ b/images/exercise3/api-build-step.png Binary files differ diff --git a/images/exercise3/api-fail-build.png b/images/exercise3/api-fail-build.png new file mode 100644 index 0000000..0f3366a --- /dev/null +++ b/images/exercise3/api-fail-build.png Binary files differ diff --git a/images/exercise3/api-post-build.png b/images/exercise3/api-post-build.png new file mode 100644 index 0000000..b7f457b --- /dev/null +++ b/images/exercise3/api-post-build.png Binary files differ -- Gitblit v1.9.3