Table of contents
4. Prepare local warehouse files
5. Start the cluster execution script
introduction
Testing is a vital part of software development, but long waits and inefficient testing often make people feel irritable. Now, we have a brand new solution: Stress Testing with Locally Attached Clusters!
By assigning test tasks to multiple nodes for parallel processing, you can greatly shorten the test time, not only improve test efficiency, but also find and solve problems more quickly. Let us experience this new and efficient testing method together!
background
At present, we mainly use the coding platform + cluster method for stress testing on this side of the stress test. What should we do when the coding platform hangs or is under maintenance and we need stress testing? The following introduces the local + cluster method for stress testing, so that cluster stress testing can also be performed when the coding platform is unavailable.
detailed steps
1. First open the terminal
2. Install kubectl
download the latest version
curl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl"
When using the following method one to install, you need to specify the version to install, and replace the $(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt) command part, such as:
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.4-tke.6/bin/darwin/amd64/kubectl
Make the kubectl binary executable
chmod +x ./kubectl
Move the binaries into PATH
sudo mv ./kubectl /usr/local/bin/kubectl
Test to make sure you have the latest version installed
kubectl version
This place will prompt you to confirm the cluster information
3. Configure kubeconfig
method one:
We need to go to Tencent Cloud to get the cluster configuration information. If the current access client has not configured any cluster access credentials, that is, the content of ~/.kube/config is empty, you can directly copy the above kubeconfig access credentials and paste them into ~/. in kube/config.
After adding it, execute the command check and find that the version is inconsistent and report a warning, but this does not affect our subsequent operations. The cause of the problem is that the installation version and the cluster version are inconsistent when installing kubectl. Just reinstall
kubectl version
View cluster information to determine whether to connect to the cluster
kubectl get pod
Method Two:
If the current access client has been configured with access credentials of other clusters or if there is a problem with method 1 and you do not want to reinstall, you can download the above kubeconfig to the specified location and execute the following command to append the kubeconfig of this cluster to the environment variable, but this command will only It takes effect in this terminal window, and you need to reconnect to the cluster after launch
export KUBECONFIG=$KUBECONFIG:$HOME/Downloads/cls-0414cfrl-config
Among them, $HOME/Downloads/cls-0414cfrl-config is the file path of the kubeconfig of this cluster, replaced with the actual path after downloading to the local
View cluster information to determine whether to connect to the cluster
kubectl get pod
4. Prepare local warehouse files
These shell scripts are required for local pressure testing. The execution ./start_test.sh $HOME/xxx.jmx
is to execute the pressure test script, the execution ./stop_test.sh
is to stop the cluster, and the execution ./upload_file_to_slave.sh $HOME/xxx.csv
is to copy the data file to the cluster. $HOME/xxx.jmx is the script path, $HOME/xxx.csv data file path
5. Start the cluster execution script
After executing commands in these shell script directories, ./start_test.sh ../demo/Test.jmx
the scripts start running in the cluster
It can also be seen in grafana
In addition, open a terminal window to ensure that the command is executed when the cluster is connected ./stop_test.sh
, and the cluster stops running
Summarize
The above is the case of running the cluster locally, and the steps are relatively simple. The test can be completed according to the steps I wrote.
[Message: Software testing and learning, get free learning tutorials]
That's all for today's article, friends who think it's well written, please support it three times!