tencent cloud

Tencent Cloud Smart Advisor

Release Notes
Product Introduction
Overview
Features
Product Strengths
Scenarios
Customer Cases
Purchase Guide
Getting Started
Using TSA to Execute a Chaos Experiment on CFG
Operation Guide
Operation Guide to TSA-Cloud Architecture
Operation Guide to TSA-Cloud Risk Assessment
Operation Guide to TSA-Chaotic Fault Generator
Operation Guide to TSA-Digital Assets
Permission Management
API Documentation
History
Introduction
API Category
Making API Requests
Other APIs
Task APIs
Cloud Architecture Console APIs
Data Types
Error Codes
FAQs
FAQs: TSA
FAQs: TSA-Cloud Risk Assessment
FAQs: TSA-Cloud Architecture
FAQs: TSA-Chaotic Fault Generator
Related Protocol
Tencent Cloud Smart Advisor Service Level Agreement
PRIVACY POLICY MODULE CHAOTIC FAULT GENERATOR
DATA PRIVACY AND SECURITY AGREEMENT MODULE CHAOTIC FAULT GENERATOR
Contact Us

Performing Single-Core CPU Stress Test with Custom Actions

PDF
フォーカスモード
フォントサイズ
最終更新日: 2025-03-24 15:23:01

Background

CFG allows users to customize fault actions for chaos engineering experiments. Users can configure action parameters and execute script commands based on specific scenarios.

Practical Examples

This section demonstrates how to configure custom actions to perform chaos engineering experiments for CVM single-core CPU stress test.

Step 1: Experiment preparation

A CVM instance that can be used for fault injection (The example instance runs TencentOS Server 2.6 (Final) system.)
Fault action script file

Step 2: Create custom actions

1. Log in to Tencent Cloud Smart Advisor > Chaotic Fault Generator, click Action Library Management, and select Create Custom Action.
2. Configure custom actions, and configure command content and command parameters. Click Save after completing the configuration.
3. After the above contents are saved, the corresponding custom actions will appear in the custom action list.
The example command content is as follows, where the percentage and timeout parameters can be passed during execution.
#!/bin/bash
user=$(whoami)
if [ !$user == 'root' ]
then
sudo -i
fi
echo -e "["`date +"%Y-%m-%d %H:%M:%S"`"] \\c"
echo "installing stress-ng..."
yum install stress-ng -y

percentage={{percentage}}
timeout={{timeout}}

stress-ng -c 1 -l $percentage --timeout $timeout

if [[ !$? -eq 0 ]]
then
echo -e "["`date +"%Y-%m-%d %H:%M:%S"`"] \\c"
echo "Failed"
exit 1
else
echo -e "["`date +"%Y-%m-%d %H:%M:%S"`"] \\c"
echo "Completed"
exit 0
fi

Step 3: Experiment orchestration

1. Enter the Experiment Management page and click Create a New Experiment.
2. Click Skip and create a blank experiment, fill in the experiment details, and select the objective CVM instance for the experiment.
3. Add experiment actions. Click Add Now , select Shell Script , select the created Custom action, and click Next .
4. Leave the action parameters as default and click Confirm.
5. After configuring action parameters, click Next. After confirming all configurations, click Submit to complete experiment creation.

Step 4: Execute the experiment

1. Execute the experiment and observe the execution results.
2. Use the top command to view CPU. The CPU usage has reached the configured value.


3. The action will last for 60 seconds. After completing experiment execution, view the CPU usage. It has been recovered to normal.



ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック