Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RHINENG-15237: Update floorist queries and payload file to randomly add different ca… #2186

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update floorist queries and payload file to randomly add different ca…
…nonical_facts

rh-pre-commit.version: 2.3.2
rh-pre-commit.check-secrets: ENABLED
thearifismail committed Jan 14, 2025
commit da8850b9a4384441fbc69bd1d1a48420fc2b66c8
19 changes: 13 additions & 6 deletions deploy/clowdapp.yml
Original file line number Diff line number Diff line change
@@ -1239,25 +1239,32 @@ objects:
suspend: ${{FLOORIST_SUSPEND}}
logLevel: ${FLOORIST_LOGLEVEL}
queries:
- prefix: hms_analytics/inventory/hosts
- prefix: hms_analytics/inventory/${ENV_NAME}/hosts
query: >-
SELECT
"id",
COALESCE("account", '0') AS "account_number",
COALESCE("account", '0') AS "account",
"org_id" AS "org_id",
"created_on" AS "created_at",
"modified_on" AS "updated_at"
"modified_on" AS "updated_at",
"reporter" AS "reporter",
"canonical_facts"->>'insights_id' as "insights_id",
"canonical_facts"->>'subscription_manager_id' as "subscription_manager_id",
"canonical_facts"->>'bios_uuid' as "bios_uuid",
"canonical_facts"->>'provider_id' as "provider_id",
"canonical_facts"->>'provider_type' as "provider_type"
FROM "hbi"."hosts"
- prefix: hms_analytics/inventory/groups_success_metrics
GROUP BY id, account, org_id, created_on, updated_at, canonical_facts, reporter;
- prefix: hms_analytics/inventory/${ENV_NAME}/groups
query: >-
SELECT
"id",
COALESCE("account", '0') AS "account_number",
"org_id" AS "org_id",
COALESCE("account", '0') AS "account",
"name" AS "name",
"created_on" AS "created_at",
"modified_on" AS "updated_at"
FROM "hbi"."groups"

- apiVersion: v1
data:
nginx.conf: |-
28 changes: 24 additions & 4 deletions utils/payloads.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import json
import os
import random
import uuid
from datetime import datetime
from datetime import timedelta
@@ -555,7 +556,7 @@ def random_uuid():


IS_EDGE = os.environ.get("IS_EDGE", False)
IS_INSIGHTS_CLIENT = os.environ.get("IS_INSIGHTS_CLIENT", False)
USE_RANDOMNESS = os.environ.get("USE_RANDOMENESS", True)


def build_host_chunk():
@@ -567,7 +568,7 @@ def build_host_chunk():
system_profile["host_type"] = "edge"

payload = {
"bios_uuid": random_uuid(),
"insights_id": random_uuid(),
"org_id": org_id,
"display_name": fqdn,
"tags": [
@@ -580,8 +581,27 @@ def build_host_chunk():
"stale_timestamp": (datetime.now(timezone.utc) + timedelta(days=1)).isoformat(),
"reporter": "puptoo",
}
if IS_INSIGHTS_CLIENT:
payload["insights_id"] = random_uuid()

# randomize the use of canonical_facts and reporters
if USE_RANDOMNESS:
add_bios = random.choice([True, False])
add_subsman = random.choice([True, False])
add_provider_id = random.choice([True, False])

if add_bios:
payload["bios_uuid"] = random_uuid()

if add_subsman:
payload["subscription_manager_id"] = random_uuid()

if add_provider_id:
payload["provider_id"] = random_uuid()
payload["provider_type"] = random.choice(["aws", "azure", "google", "ibm"])

payload["reporter"] = random.choice(
["cloud-connector", "puptoo", "rhsm-conduit", "rhsm-system-profile-bridge", "yuptoo"]
)

return payload