-
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.
[PCP-8898] Initial support for TP automation (#44)
- Loading branch information
1 parent
ed668e2
commit a23978c
Showing
23 changed files
with
1,907 additions
and
62 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
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
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
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 |
---|---|---|
|
@@ -9,43 +9,69 @@ kind: generic-runner | |
meta: | ||
guiEnv: | ||
note: "tp-automation-o11y" | ||
GUI_TP_CLUSTER_NAME: '' | ||
GUI_PIPELINE_LOG_DEBUG: false | ||
GUI_DP_USER_NAME: "" | ||
GUI_DP_PASSWORD: "" | ||
GUI_TP_CLUSTER_NAME: '' | ||
GUI_GITHUB_TOKEN: "" | ||
GUI_DP_HOST_PREFIX: "cp-sub1" | ||
GUI_DP_USER_EMAIL: "[email protected]" | ||
GUI_DP_USER_PASSWORD: "Tibco@123" | ||
GUI_TP_PORT_FORWARD: true | ||
GUI_TP_OVERWRITE_DNS: false | ||
globalEnvVariable: | ||
REPLACE_RECIPE: true | ||
GITHUB_TOKEN: ${GUI_GITHUB_TOKEN:-""} | ||
PIPELINE_LOG_DEBUG: ${GUI_PIPELINE_LOG_DEBUG} | ||
PIPELINE_CHECK_DOCKER_STATUS: false | ||
TP_CLUSTER_NAME: ${GUI_TP_CLUSTER_NAME} | ||
DP_USER_NAME: ${GUI_DP_USER_NAME:-""} | ||
DP_PASSWORD: ${GUI_DP_PASSWORD:-""} | ||
TP_CLUSTER_NAME: ${GUI_TP_CLUSTER_NAME:-"on-prem"} | ||
DP_HOST_PREFIX: ${GUI_DP_HOST_PREFIX:-"cp-sub1"} | ||
DP_USER_EMAIL: ${GUI_DP_USER_EMAIL:-"[email protected]"} | ||
DP_USER_PASSWORD: ${GUI_DP_USER_PASSWORD:-"Tibco@123"} | ||
CP_ADMIN_EMAIL: ${GUI_CP_ADMIN_EMAIL:-"[email protected]"} | ||
CP_ADMIN_PASSWORD: ${GUI_CP_ADMIN_PASSWORD:-"Tibco@123"} | ||
PYTHON_FILE_INPUT_NAME: py-scripts.yaml | ||
PYTHON_FILE_ENTRY_POINT: run.py | ||
TP_PORT_FORWARD: ${GUI_TP_PORT_FORWARD:-true} | ||
TP_OVERWRITE_DNS: ${GUI_TP_OVERWRITE_DNS:-false} | ||
tasks: | ||
- condition: true | ||
clusters: | ||
- name: ${TP_CLUSTER_NAME} | ||
script: | ||
ignoreErrors: false | ||
fileName: script.sh | ||
content: | | ||
input_yaml="${PYTHON_FILE_INPUT_NAME}" | ||
yq eval 'to_entries | .[] | .key + " " + (.value)' "$input_yaml" | while read -r file_name decoded_content; do | ||
if [[ -n $file_name ]]; then | ||
echo "$decoded_content" | base64 -d > "$file_name" | ||
echo "Created file: $file_name" | ||
fi | ||
done | ||
python ${PYTHON_FILE_ENTRY_POINT} | ||
payload: | ||
base64Encoded: false | ||
fileName: ${PYTHON_FILE_INPUT_NAME} | ||
content: | | ||
{{- $root := . }} | ||
{{- range $path, $bytes := .Files.Glob "scripts/o11y/*" }} | ||
{{ base $path }}: | | ||
{{ $root.Files.Get $path | b64enc | indent 2 -}} | ||
{{- end }} | ||
- condition: ${TP_OVERWRITE_DNS} # this is used for overwrite DNS | ||
clusters: | ||
- name: ${TP_CLUSTER_NAME} | ||
script: | ||
ignoreErrors: false | ||
fileName: script.sh | ||
content: | | ||
echo "nameserver 10.178.2.10" > /etc/resolv.conf | ||
- condition: ${TP_PORT_FORWARD} # this is used for run pipeline locally | ||
clusters: | ||
- name: ${TP_CLUSTER_NAME} | ||
script: | ||
ignoreErrors: false | ||
fileName: script.sh | ||
content: | | ||
nohup kubectl port-forward -n ingress-system --address 0.0.0.0 service/ingress-nginx-controller 80:http 443:https & | ||
- condition: true | ||
clusters: | ||
- name: ${TP_CLUSTER_NAME} | ||
script: | ||
ignoreErrors: false | ||
fileName: script.sh | ||
content: | | ||
input_yaml="${PYTHON_FILE_INPUT_NAME}" | ||
yq eval 'to_entries | .[] | .key + " " + (.value)' "$input_yaml" | while read -r file_name decoded_content; do | ||
if [[ -n $file_name ]]; then | ||
echo "$decoded_content" | base64 -d > "$file_name" | ||
echo "Created file: $file_name" | ||
fi | ||
done | ||
pip install -r requirements.txt | ||
python ${PYTHON_FILE_ENTRY_POINT} | ||
payload: | ||
base64Encoded: false | ||
fileName: ${PYTHON_FILE_INPUT_NAME} | ||
content: | | ||
{{- $root := . }} | ||
{{- range $path, $bytes := .Files.Glob "scripts/o11y/*" }} | ||
{{ base $path }}: | | ||
{{ $root.Files.Get $path | b64enc | indent 2 -}} | ||
{{- end }} |
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 @@ | ||
## Test Python script in Docker container | ||
|
||
```shell | ||
# Optional, GITHUB_TOKEN is required for private repo | ||
export GITHUB_TOKEN="" | ||
|
||
# Optional, if you want to use different host prefix, email and password, you can set them here | ||
export HOST_PREFIX="cp-sub1" | ||
export USER_EMAIL="[email protected]" | ||
export USER_PASSWORD="Tibco@123" | ||
|
||
# Optional, if you want to use different admin email and password, you can set them here | ||
export ADMIN_EMAIL="[email protected]" | ||
export ADMIN_PASSWORD="Tibco@123" | ||
|
||
cd charts | ||
helm template provisioner-config-local provisioner-config-local | yq eval .data | yq eval '.["pp-maintain-tp-automation-o11y.yaml"]' | yq eval .recipe > recipe.yaml | ||
export PIPELINE_INPUT_RECIPE="$(pwd)/recipe.yaml" | ||
export PIPELINE_DOCKER_IMAGE="ghcr.io/tibcosoftware/platform-provisioner/platform-provisioner:v1.0.0-tester" | ||
export PIPELINE_ON_PREM_KUBECONFIG_FILE_NAME=config | ||
../dev/platform-provisioner.sh | ||
``` | ||
|
||
## Test Python script in Mac | ||
|
||
```shell | ||
|
||
# Install pyenv and python 3.12.8 if you don't have it(Only need to run once) | ||
brew update && brew install pyenv | ||
pyenv install 3.12.8 | ||
pyenv global 3.12.8 | ||
python --version | ||
|
||
cd charts/provisioner-config-local/scripts/o11y | ||
python -m venv .venv | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
|
||
# Install playwright (Only need to run once) | ||
playwright install | ||
|
||
# Optional, GITHUB_TOKEN is required for private repo | ||
export GITHUB_TOKEN="" | ||
|
||
# Optional, if you want to use different host prefix, email and password, you can set them here | ||
export HOST_PREFIX="cp-sub1" | ||
export USER_EMAIL="[email protected]" | ||
export USER_PASSWORD="Tibco@123" | ||
|
||
# Optional, if you want to use different admin email and password, you can set them here | ||
export ADMIN_EMAIL="[email protected]" | ||
export ADMIN_PASSWORD="Tibco@123" | ||
|
||
# Optional, if you want to see the browser UI during the test | ||
export HEADLESS="false" | ||
python run.py | ||
``` |
38 changes: 38 additions & 0 deletions
38
charts/provisioner-config-local/scripts/o11y/color_logger.py
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,38 @@ | ||
from colorama import Fore, Style, init | ||
|
||
# Initialize colorama for cross-platform support | ||
init(autoreset=True) | ||
|
||
class ColorLogger: | ||
@staticmethod | ||
def info(message): | ||
print(f"{Fore.LIGHTBLUE_EX}[INFO] {message}") | ||
|
||
@staticmethod | ||
def success(message): | ||
print(f"{Fore.GREEN}[INFO] {message}") | ||
|
||
@staticmethod | ||
def warning(message): | ||
print(f"{Fore.YELLOW}[WARNING] {message}") | ||
|
||
@staticmethod | ||
def error(message): | ||
print(f"{Fore.RED}[ERROR] {message}") | ||
|
||
@staticmethod | ||
def debug(message): | ||
print(f"{Fore.CYAN}[DEBUG] {message}") | ||
|
||
@staticmethod | ||
def critical(message): | ||
print(f"{Fore.MAGENTA}[CRITICAL] {message}") | ||
|
||
@staticmethod | ||
def custom(message, color): | ||
""" | ||
Print a custom-colored message. | ||
:param message: The message to print. | ||
:param color: The color from `colorama.Fore` (e.g., Fore.BLUE). | ||
""" | ||
print(f"{color}{message}{Style.RESET_ALL}") |
Oops, something went wrong.