Commit 11012bf3 authored by Ian Ernst's avatar Ian Ernst
Browse files

Fixes Advanced CICD Labs

parent 8468c8ff
Loading
Loading
Loading
Loading
+49 −7
Changes for content/handbook/customer-experience/professional-services-engineering/education-services/ilt-labs/advgitlabcicdhandsonlab3.md: 49 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -11,7 +11,47 @@ The purpose of this lab is to create a review app from a Node.js application. A

- Create a review app from the Node.js application

## Task A. Creating a Review App
## Task A. Creating a Web App

For this task, we will be creating a web application to run in our review environment. We will do this work on a separate `review-app` branch, so that the `main` branch keeps the search code and tests used in later labs.

1. Navigate to your project repository.

1. Select **Code > Branches**.

1. Select **New branch**.

1. Set the branch name to `review-app`, leave **Create from** set to `main`, and select **Create branch**.

1. Select **Build > Pipeline Editor**, and set the branch to **review-app**.

1. When we add express code into our `index.js` file, our tests will no longer be able to run against `index.js`, since running this will create a webserver that waits for connections. Thus, let's remove the `install deps`, `test binarysearch` and the `test linearsearch` jobs from the file. Remove the jobs from the `.gitlab-ci.yml` file, and select **Commit changes**.

1. Navigate back to your project repository, and set your branch to **review-app**.

1. Select your `index.js` file.

1. Select **Edit > Edit single file**.

1. Remove the binary search and linear search methods, and add the code below, which will run our web application:

      ```js
      const express = require('express')
      const app = express()
      const port = 4001

      app.get('/', (req, res) => {
        res.send('Hello World!')
      })

      app.listen(port, () => {
        console.log(`Example app listening on port ${port}`)
      })
      ```

1. Commit your changes to the `review-app` branch.

## Task B. Creating a Review App

1. In the left sidebar, select **Operate > Environments**.

@@ -94,7 +134,8 @@ The purpose of this lab is to create a review app from a Node.js application. A
          - ssh root@$ip 'cd /www/ && npm i express'
          - ssh root@$ip 'cd /www/ && npm i -g pm2'
          - scp index.js root@$ip:/www
          - ssh root@$ip 'pm2 start -f /www/index.js'
          - ssh root@$ip 'pm2 delete index || true'
          - ssh root@$ip 'pm2 start /www/index.js --name index'
      ```

1. Here is what your final job script should look like:
@@ -119,7 +160,8 @@ The purpose of this lab is to create a review app from a Node.js application. A
          - ssh root@$ip 'cd /www/ && npm i express'
          - ssh root@$ip 'cd /www/ && npm i -g pm2'
          - scp index.js root@$ip:/www
          - ssh root@$ip 'pm2 start -f /www/index.js'
          - ssh root@$ip 'pm2 delete index || true'
          - ssh root@$ip 'pm2 start /www/index.js --name index'
        environment:
          name: review/$CI_COMMIT_REF_NAME
          url: http://$ip:4001
@@ -129,7 +171,7 @@ The purpose of this lab is to create a review app from a Node.js application. A

1. Select **Commit changes**.

## Task B. Verify the review app
## Task C. Verify the review app

To test that your review app works, let's create a new merge request.

@@ -137,9 +179,9 @@ To test that your review app works, let's create a new merge request.

1. Select **New branch**.

1. Set the branch name to `test_review` and select **Create branch**.
1. Set the branch name to `test_review`, set **Create from** to `review-app`, and select **Create branch**.

1. Create a merge request for this branch.
1. Create a merge request for this branch. Set the target branch to `review-app`.

1. Once you have created this, open the Web IDE from the merge request by selecting **Code > Open in Web IDE**

@@ -161,7 +203,7 @@ To test that your review app works, let's create a new merge request.
      })
      ```

1. Select the **source control** icon. Enter a commit message, then click the **Commit and put to...** button to commit your code change.
1. Select the **source control** icon. Enter a commit message, then click the **Commit and push to...** button to commit your code change.

1. Wait for the pipeline to complete.

+4 −2
Changes for content/handbook/customer-experience/professional-services-engineering/education-services/ilt-labs/advgitlabcicdhandsonlab4.md: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ Follow these steps to set up and use a feature flag:

1. Select **Edit > Edit in single file**.

1. In your `index.js` file, remove all of your existing code and replace it with the following, ensuring to replace **your-instance-url** and **your-instance-id** with the values your made a note of earlier:
1. In your `index.js` file, remove all of your existing code and replace it with the following, ensuring to replace **your-instance-url** and **your-instance-id** with the values you made a note of earlier:

      ```js
      const { initialize } = require('unleash-client');
@@ -59,6 +59,8 @@ Follow these steps to set up and use a feature flag:

1. Keep everything as the default value, and select **Create a merge request**.

    > The pipeline for this commit fails, because the test jobs from earlier labs cannot load the new `index.js`. You replace these jobs in Task B.
    >
    > This code will continually run, attempting to check if the feature flag toggle is enabled or disabled. Since it is enabled for 50% of users, you should see it around half the time when this runs.

## Task B. Test the Feature Flag
@@ -89,7 +91,7 @@ Follow these steps to set up and use a feature flag:

1. Select the `test_flag` job.

1. Observe that sometimes this job outputs true and sometimes it outputs false. This is because the feature flag is active 50% of the time.
1. Observe that sometimes this job outputs `Toggle enabled` and sometimes it outputs `Toggle disabled`. This is because the feature flag is active 50% of the time.

1. Cancel the job by selecting the **Cancel** button.

+7 −1
Changes for content/handbook/customer-experience/professional-services-engineering/education-services/ilt-labs/advgitlabcicdhandsonlab6.md: 7 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -177,7 +177,13 @@ When multiple users work on a project at the same time, merge conflicts are ofte
          reports:
            junit: junit.xml

      install deps: &cachedef
      .cachedef: &cachedef
        cache:
          key: $CI_COMMIT_REF_SLUG
          paths:
            - node_modules

      install deps:
        stage: deps
        script:
          - npm install jest jest-junit