You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System Patch Manager is one of the applications for [console.redhat.com](https://console.redhat.com). This application allows users to display and manage available patches for their registered systems. This code repo stores sources for the backend part of the application which provides the REST API to the frontend.
6
+
System Patch Manager is one of the applications for [console.redhat.com](https://console.redhat.com). This application allows users to display and manage available patches for their registered systems. This code repo stores sources for the backend part of the application, which provides the REST API for the frontend.
-[Control by private API](#control-by-private-api)
17
17
-[VMaaS](#vmaas)
18
18
-[Monitoring](#monitoring)
19
-
-[Profiling](#profiling)
19
+
-[Profiling](#profiling)
20
20
21
21
## Development environment
22
+
Ensure that you have Go and Podman installed.
22
23
23
24
### Running locally
24
-
Uses`podman-compose` to deploy the individual project components and supporting containers, which simulate the CMSfR platform and database:
25
+
Use`podman-compose` to deploy the individual project components and supporting containers that simulate the CMSfR platform and database:
25
26
~~~bash
26
27
podman-compose up --build # Build images if needed and start containers
27
28
podman-compose down # Stop and remove containers
28
29
~~~
29
30
30
-
Use `--profile monitoring` to run local `prometheus` and `grafana`, for example
31
+
#### Run with monitoring
32
+
Use `--profile monitoring` to run local `prometheus` and `grafana`, for example:
31
33
~~~bash
32
34
podman-compose --profile monitoring up
33
35
~~~
34
-
Grafana is accessible at `http://localhost:3000`, Prometheus at `http://localhost:9090`
36
+
Grafana is available at <http://localhost:3000> and Prometheus at <http://localhost:9090>.
35
37
38
+
#### Run a component in the host OS
39
+
Run a single component in the host OS while running the rest in podman-compose:
40
+
~~~bash
41
+
podman-compose stop evaluator_upload # stop a single component using podman-compose
42
+
export$(xargs < conf/local.env)
43
+
./scripts/entrypoint.sh evaluator # (or listener, or manager) run the component in the host OS
44
+
~~~
36
45
37
46
### Local app requests
38
-
When podmancompose is running, you can test the app using dev shell scripts:
47
+
When podman-compose is running, use dev shell scripts to test the app:
39
48
~~~bash
40
49
cd dev/scripts
41
50
./systems_list.sh # show systems
@@ -44,94 +53,89 @@ cd dev/scripts
44
53
./platform_upload.sh # simulate archive upload to trigger listener and evaluator_upload
45
54
~~~
46
55
47
-
### Running in host OS
48
-
Run single component in host OS, rest in podman-compose:
49
-
~~~bash
50
-
podman-compose stop evaluator_upload # stop single component running using podman-compose
51
-
export$(xargs < conf/local.env)
52
-
./scripts/entrypoint.sh evaluator # (or listener, or manager) run component in host OS
53
-
~~~
56
+
### Testing and debugging
57
+
A large part of the application functionality is covered with tests; this requires running a test database and mocked services. All of this is encapsulated in the test configuration, which is run using podman-compose. It also includes static code analysis, database migration tests, and a Dockerfile check. It is used to check pull requests too.
54
58
55
-
### Running tests
56
-
We cover a large part of the application functionality with tests; this requires also running a test database and mocked services. This is all encapsulated into the configuration runable using podman-compose command. It also includes static code analysis, database migration tests and dockerfiles checking. It's also used when checking pull requests for the repo.
59
+
Use this command to run the whole test suite:
57
60
~~~bash
58
61
podman-compose -f docker-compose.test.yml up --build --abort-on-container-exit
59
62
~~~
60
63
61
-
### Run single test or set of tests in containers
62
-
- Open `./scripts/go_test.sh` file
63
-
- Comment line that runs all tests
64
-
- Uncomment and modify the last line to run one or a set of tests
65
-
- Run the same command as for running all tests (from above)
64
+
####Run one or more tests instead
65
+
1. Open `./scripts/go_test.sh` file.
66
+
2. Comment out the line that runs all tests.
67
+
3. Uncomment and modify the last line to specify one or a set of tests.
68
+
4. Run the same command as for the whole suite (from above).
66
69
67
-
### Run single test locally
68
-
After running all test suite, testing platform components are still running (kafka, platform, db). This is especially useful when fixing some test or adding a new one. You need to have golang installed.
70
+
####Run a single test locally
71
+
After running the entire test suite (without `--abort-on-container-exit` flag), testing platform components (`kafka`, `platform`, `db`) are still up. This is especially useful when fixing a test or adding a new one.
69
72
~~~bash
70
73
podman-compose -f docker-compose.test.yml up --build --no-start # build images
71
74
podman-compose -f docker-compose.test.yml run test ./scripts/go_test.sh './evaluator -run TestEvaluate'# run "TestEvaluate" test from "evaluator" component
72
75
~~~
73
76
74
-
### Run tests in VS Code
75
-
76
-
Prerequisite is to have [Go Extension](https://marketplace.visualstudio.com/items?itemName=golang.Go)
77
+
#### Run tests in VS Code
78
+
A prerequisite is to have the [Go Extension](https://marketplace.visualstudio.com/items?itemName=golang.Go)
77
79
installed.
78
80
79
-
To set it up copy the example settings from `.vscode/settings.example.json`:
80
-
```
81
+
To set things up, copy the example settings from `.vscode/settings.example.json`:
Our REST API is documented using OpenAPI v3. On a local instance it can be accessed on<http://localhost:8080/openapi/index.html>.
111
+
The REST API is documented using OpenAPI v3. On a local instance, it can be accessed at<http://localhost:8080/openapi/index.html>.
99
112
100
-
To update/regenerate OpenAPI sources run:
113
+
For the first time, ensure that you have `swaggo/swag` binary installed:
114
+
~~~bash
115
+
go get -u github.com/swaggo/swag/cmd/swag
116
+
~~~
117
+
118
+
Run this command to update/regenerate OpenAPI source files:
101
119
~~~bash
102
-
go get -u github.com/swaggo/swag/cmd/swag # download binary to generate, do it first time only
103
120
./scripts/generate_docs.sh
104
121
~~~
105
122
106
123
## Control by private API
107
-
There is a private API accessible only from inside of `vmaas_sync` container. It allows running component routines manually. In local environment it can be tested like this:
124
+
There is a private API accessible only from the `vmaas_sync` container, which allows triggering component routines manually. In a local environment, test it like this:
This project uses [VMaaS](https://github.com/RedHatInsights/vmaas) for retrieving information about advisories, and resolving which advisories can be applied to which systems. For local development this repo contains VMaaS service mock as a part of platform mock allowing independent running of the service using podman-compose.
132
+
This project uses [VMaaS](https://github.com/RedHatInsights/vmaas) for retrieving information about advisories and resolving which advisories can be applied to which systems. For local development, the platform mock contains a VMaaS service mock.
116
133
117
134
## Monitoring
118
135
Each application component (except for the database) exposes metrics for [Prometheus](https://prometheus.io/)
119
136
on `/metrics` endpoint (see [docker-compose.yml](docker-compose.yml) for ports). Runtime logs can be sent to Amazon
120
137
CloudWatch if configuration environment variables are set (see [awscloudwatch.go](base/utils/awscloudwatch.go)).
121
138
122
-
## Kafka control
123
-
Your can control and inspect def Kafka instance using:
124
-
~~~bash
125
-
docker-compose exec kafka bash # enter kafka component and run inside:
126
-
/usr/bin/kafka-topics --list --bootstrap-server=kafka:9092 # show created topics
- set`ENABLE_PROFILE_{container_name}=true` in the ClowdApp
162
-
- download the profile file using internal api`/api/patch/admin/pprof/{manager|listener|evaluator_upload|evaluator_recalc}/{heap|profile|block|mutex|trace}`
163
-
-`go tool pprof <saved.file>`
157
+
1. Set`ENABLE_PROFILE=true` in the `conf/common.env`.
158
+
2. Run `podman-compose up --build`.
159
+
3. Run `go tool pprof http://localhost:{port}/debug/pprof/{heap|profile|block|mutex}` with:
160
+
-`9000` - manager,
161
+
-`9002` - listener,
162
+
-`9003` - evaluator-upload, or
163
+
-`9004` - evaluator-recalc.
164
+
165
+
### Using Admin API
166
+
1. Set`ENABLE_PROFILE_{container_name}=true` in the ClowdApp.
167
+
2. Download the profile file using internal API`/api/patch/admin/pprof/{manager|listener|evaluator_upload|evaluator_recalc}/{heap|profile|block|mutex|trace}`.
0 commit comments