-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* That extra env var is for a specific case with graphql and no auth * Adds remaining tests * Adds step by step doc
- Loading branch information
1 parent
8033d27
commit 2d0ebb0
Showing
4 changed files
with
190 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# graphql memory profiling with heaptrack and disabled auth | ||
|
||
* Install [heaptrack](https://github.com/KDE/heaptrack) | ||
|
||
```shell | ||
sudo dnf install heaptrack | ||
``` | ||
|
||
* Clone trustify and generate a database dump | ||
|
||
```shell | ||
cargo run --bin xtask generate-dump | ||
``` | ||
|
||
* Use the generated dump | ||
* Change `trustify/etc/deploy/compose/compose.yaml` | ||
* Add the following: | ||
|
||
```yaml | ||
volumes: | ||
- /dump_path_here/dump.sql:/docker-entrypoint-initdb.d/dump.sql:Z | ||
``` | ||
* Open a terminal and start postgres | ||
```shell | ||
podman-compose -f etc/deploy/compose/compose.yaml up | ||
``` | ||
|
||
* Change `trustify/Cargo.toml` | ||
* Add the following: | ||
|
||
```yaml | ||
[profile.release] | ||
debug = true | ||
``` | ||
|
||
* Clean and build with `--release` | ||
|
||
```shell | ||
cargo clean ; cargo build --release | ||
``` | ||
|
||
* Open a terminal and start trustify with heaptrack and graphql feature | ||
|
||
```shell | ||
cd target/release/ | ||
TRUSTD_WITH_GRAPHQL=true heaptrack ./trustd api --db-password eggs --devmode --auth-disabled | ||
``` | ||
|
||
* Run loadtest | ||
|
||
```shell | ||
MEM_PROF=true cargo run --release --bin loadtest -- --host http://localhost:8080 -u 256 | ||
``` | ||
|
||
* Stop loadtest and trustify, and heaptrack will show the results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,49 @@ | ||
use goose::goose::{GooseUser, TransactionResult}; | ||
use urlencoding::encode; | ||
|
||
pub async fn graphql_query_advisory(user: &mut GooseUser) -> TransactionResult { | ||
let query = r#"{"query": "{getAdvisories { id sha256 published organization { id website } vulnerabilities { id title }}}" }"#; | ||
let encoded_query = encode(query); | ||
let url = format!("/graphql?query={}", encoded_query); | ||
let _response = user.get(&url).await?; | ||
pub async fn g_get_advisories(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{"query": "{getAdvisories { id sha256 published organization { id website } vulnerabilities { id title }}}" }"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn g_get_advisory_by_id(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{ "query": "{ getAdvisoryById(id: \"37292820-00ee-4299-8097-a11f8348bdf8\") { id title }}" }"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn g_get_organization_by_name(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{"query": "{ getOrganizationByName(name: \"Red Hat\") { id name }}"}"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn g_get_sbom_by_id(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{ "query": "{ getSbomById(id: \"01926efa-bbb2-7222-9f4d-692bd5e40a46\") {sbomId, authors}}" }"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn g_get_sbom_by_labels(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{ "query": "{ getSbomsByLabels(labels: \"type:spdx\") { sbomId sourceDocumentId authors labels }}" }"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn g_cves_by_sbom(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{ "query": "{ cvesBySbom(id: \"01926efa-bbb2-7222-9f4d-692bd5e40a46\") { vulnerabilityId status packages { id name version } }}" }"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn g_get_vulnerability_by_id(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{ "query": "{ getVulnerabilityById(identifier: \"CVE-2024-28111\") { id published }}" }"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} | ||
|
||
pub async fn g_get_vulnerabilities(user: &mut GooseUser) -> TransactionResult { | ||
let body = r#"{ "query": "{ getVulnerabilities { id published withdrawn }}" }"#; | ||
let _response = user.post("/graphql", body).await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters