> For the complete documentation index, see [llms.txt](https://docs.viettelsoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.viettelsoftware.com/huong-dan-cai-dat/3.-cai-dat-runner.md).

# 3. Cài đặt Runner

Runner là các ứng dụng chạy ở server. Nó chứa các thành phần để thiết lập cho việc chạy các testcase automation theo yêu cầu của người dùng.\
\
Runner gồm 3 thành phần là Runner Core, Runner Hub và Connector. Để cài đặt Runner ta thực hiện các bước sau:

[Hướng dẫn cài đặt docker, docker-compose](/huong-dan-cai-dat/5.-cai-dat-docker-docker-compose.md)

### **Chuẩn bị.**&#x20;

* Server triển khai cần được cài đặt docker
* Tạo file daemon.json nếu chưa tồn tại

  `sudo nano /etc/docker/daemon.json`
* Đăng ký insecure bằng cách thêm cấu hình sau vào file daemon.json

  `{`

  `"insecure-registries" : ["repo.viettelsoftware.com:8088"]`&#x20;

&#x20;   `}`

* Restart lại docker

  `sudo systemctl restart docker`

### **Bước 1. Tải các file cài đặt**

Truy cập link tải: <https://drive.google.com/drive/u/0/folders/1lkWIsyo__JX370bqhxbqqgWZ0Rpjq-_7>

### **Bước 2. Cài đặt Runner Core/Runner Hub**

1. Tạo thư mục chứa file cài đặt. Ví dụ : `/home/automation/VT-AT/runner/`
2. Copy 3 file **runner.env, runner.yml** và **runner-hub.yml** vào thư mục cài đặt
3. Truy cập tới thư mục cài đặt: `cd /home/automation/VT-AT/runner/`
4. Chạy lệnh cài đặt **runner** : `docker compose -f runner.yml up -d`
5. Chạy lệnh cài đặt **runner-hub** : `docker compose -f runner-hub.yml up -d`
6. Cấu hình file **runner.env**

   \-  Cần update thông tin sau trong file **runner.env**&#x20;

   * **`ip_connector`**` ``: Ip của server triển khai connector`
   * **`ip_runnerhub`**` ``: ip của server triển khai runner hub`&#x20;

### **Bước 3. Cài đặt Connector**

1. Tạo thư mục chứa file cài đặt. Ví dụ : `/home/automation/VT-AT/connector/`
2. Copy 2 file **application.yml**và **connector.yml** vào thư mục cài đặt
3. Truy cập tới thư mục cài đặt: `cd /home/automation/VT-AT/connector/`
4. Chạy lệnh cài đặt **Connector**: `docker compose -f connector.yml up -d`
5. Cấu hình file **application.yml**

   &#x20;\-   Cần cập thông tin sau  trong file application.yml

   * **`ip_runner`**`: Ip server cài runner ở` [**`bước 2`**](#buoc-2.-cai-dat-runner-core-runner-hub)
   * **`domain_jira`**`: Thông tin domain/ip jira`
   * **`port_jira`**` ``: port của ứng dụng jira`

### Bước 4. Kiểm tra cài đặt

Đảm bảo hệ thống đã được cài đặt curl ([link tham khảo](/huong-dan-cai-dat/6.-huong-dan-cai-dat-curl.md))

1. Kiểm tra connector đã hoat động đúng hay không

```
curl --location 'http://{ip_connector}:8000/api/project/run' \

--header 'Content-Type: application/json' \

--header 'Cookie: connect.sid=s%3AdvEhQR0b0ckEsaEaIZe4sZcFA68M3kiy.nKzvm4uoGYGdX9v%2BYPA%2Fk4tNTdrEMV1eQZbcC29tEEE; connect.sid=s%3AYpY4DvmurlTIecub8zq-qbbMam3s1RMr.1CRtUjzxhiZm1xvOFqgZu%2BB9okbqZSv6Y%2B1zlDBFgVk' \

--data '{

    "browser": "chrome",

    "apiKey": "8dd705c9-369b-4284-9e1c-7863232a89e4",

    "test_run_id": 242,

    "test_ids": [

        "EX",

        "While"

    ],

    "test_run_history_id": 722,

    "topic": "automation-test-runner-kafka"

}'
```

Trong đó **ip\_connector** : là Ip của server triển khai connector

**Kết quả thành công:**

`{ "data": {}, "message": "TypeError: Cannot read properties of undefined (reading 'projectName')", "error": "Internal Server Error" }`

*Nếu không ra kết quả hoặc ra kết quả khác thì liên hệ VTIT để kiểm tra lại*

2. Kiểm tra runner-hub đã hoat động đúng hay không

```
curl --location 'http://{ip_runnerhub}:8185/api/project/run' \

--header 'Content-Type: application/json' \

--header 'Cookie: connect.sid=s%3AdvEhQR0b0ckEsaEaIZe4sZcFA68M3kiy.nKzvm4uoGYGdX9v%2BYPA%2Fk4tNTdrEMV1eQZbcC29tEEE; connect.sid=s%3AYpY4DvmurlTIecub8zq-qbbMam3s1RMr.1CRtUjzxhiZm1xvOFqgZu%2BB9okbqZSv6Y%2B1zlDBFgVk' \

--data '{

    "browser": "chrome",

    "apiKey": "8dd705c9-369b-4284-9e1c-7863232a89e4",

    "test_run_id": 242,

    "test_ids": [

        "EX",

        "While"

    ],

    "test_run_history_id": 722,

    "topic": "automation-test-runner-kafka"

}'
```

Trong đó **ip\_runnerhub** : ip của server triển khai runner hub&#x20;

**Kết quả thành công:**

`{ "data": {}, "message": "TypeError: Cannot read properties of undefined (reading 'projectName')", "error": "Internal Server Error" }`

*Nếu không ra kết quả hoặc ra kết quả khác thì liên hệ VTIT để kiểm tra lại*
