Skip to content

Commit

Permalink
Helm charts (#3841)
Browse files Browse the repository at this point in the history
* helm chart

* first pipe setup

* poi

* magiks

* ewewe

* stress

* cleanup

* pr

* QFE and readme

* clang

* stupid clang , waste of time

* ewqwewewrqrewewrqewrqwrqr

* stupid clang

* cspell

* PR

* try try again

* clang again
  • Loading branch information
gearama authored Jul 25, 2022
1 parent 6c74e57 commit 992a3a9
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"*.exe",
"*.a",
"*.lib",
"*.yaml",
"**/libcurl-stress-test/README.md",
".github/CODEOWNERS",
".gitignore",
".vscode/cspell.json",
Expand Down
7 changes: 0 additions & 7 deletions sdk/core/azure-core/test/libcurl-stress-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,3 @@ target_link_libraries(azure-core-libcurl-stress-test PRIVATE azure-core)
create_map_file(azure-core-libcurl-stress-test azure-core-libcurl-stress-test.map)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/Dockerfile
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)

find_program(DOCKER_EXECUTABLE docker)
#if docker is found try to build the docker image in the defined docker_build stage which should be run after build
if(DOCKER_EXECUTABLE)
add_custom_target(docker_build
COMMAND ${DOCKER_EXECUTABLE} build --build-arg targetTest=azure-core-libcurl-stress-test --build-arg build=on --tag=azuresdkforcpp/curlstress -f Dockerfile .)
endif()
16 changes: 16 additions & 0 deletions sdk/core/azure-core/test/libcurl-stress-test/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT

apiVersion: v2
name: libcurl-stress-test
description: An example of c++ stress test
version: 0.0.1
appVersion: v0.1
annotations:
stressTest: 'true' # enable auto-discovery of this test via `find-all-stress-packages.ps1`
namespace: 'azuresdkforcpp'

dependencies:
- name: stress-test-addons
version: 0.1.19
repository: https://stresstestcharts.blob.core.windows.net/helm/
5 changes: 3 additions & 2 deletions sdk/core/azure-core/test/libcurl-stress-test/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT

FROM mcr.microsoft.com/mirror/docker/library/ubuntu:22.04

ARG targetTest
Expand All @@ -11,5 +14,3 @@ RUN chmod +x ./$targetTest
RUN apt-get update -y
RUN apt-get install valgrind -y

# execute under memcheck tool
RUN valgrind --tool=memcheck -s ./$targetTest $build
29 changes: 29 additions & 0 deletions sdk/core/azure-core/test/libcurl-stress-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Stress test prototype
This is work in progress. It's a prototype of how a stress test would look. This PR is to park the work in progress while being dealing with higher priority issues.
## Components
### Code (https://en.wikipedia.org/wiki/C%2B%2B)
The cpp file represents the code for the test, it will generate a number of invalid URLs and then issue CURL send commands. The requests are expected to fail. The point was that it exposes memory leaks in handling the error cases, which we fixed since.

### Dockerfile (https://www.docker.com/)
Represents the build file for the container in which the test runs, it is based on ubuntu 22.04 , from mcr.
The main change from default ubuntu is making sure we have the valgrind tool installed. Valgrind is a heap monitoring tool that helps identify potential stack traces that might leak memory. While not 100% effective is is great at reducing the surface are for investigations.

### Helm chart (https://helm.sh/)
Chart.yaml together with the bicep file(https://docs.microsoft.com/azure/azure-resource-manager/bicep/overview?tabs=bicep) and the deploy job file , represent the helm chart needed to deploy to the docker image built from the dockerfile to the stress cluster and execute the stress test.

The helm chart creates a pod with a container based on the docker image, and executes the test under valgrind.

To deploy the chart you will need to run "azure-sdk-for-cpp\eng\common\scripts\stress-testing> .\deploy-stress-tests.ps1 -Namespace azuresdkforcpp -SearchDirectory E:\src\azure-sdk-for-cpp\sdk\core\azure-core\test -PushImage"

Where namaspace will be created if missing , search directory can be any folder where it will search for charts in it and all it's sub dirs, push image will call it to build the docker image.

ATM the docker image is build by hand and harcoded in the chart to simplify matters.

To build the image run "docker build -t stresstesttbiruti6oi24k.acr.io/azuresdkforcpp/curlstress:v8 --build-arg targetTest=azure-core-libcurl-stress-test --build-arg build=on ."

To push to mcr : "docker push stresstesttbiruti6oi24k.acr.io/azuresdkforcpp/curlstress:v8"
Obviously after logging in to the acr "az acr login -n stresspgs7b6dif73rup6.azurecr.io"

To use another image you will need to go to line 12 in deploy job and update with your new file.

Once the deploy succeeds run " kubectl logs -n azuresdkforcpp -f libcurl-stress-test" to grab the logs in real time .
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,19 @@
* the instructions to install and run the server before running this test.
*
*/

#define REQUESTS 100
#define WARMUP 100
#define ROUNDS 100

#include <azure/core.hpp>
#include <azure/core/http/curl_transport.hpp>
#include <fstream>
#include <ios>
#include <iostream>
#include <memory>
#include <stdlib.h>
#include <string>
#include <vector>

void SendRequest(std::string target)
{
std::cout << target << std::endl;
/* The transport adapter must allow insecure SSL certs.
If both curl and winHttp are available, curl is preferred for this test*/

// The transport adapter must allow insecure SSL certs.
Azure::Core::Http::CurlTransportOptions curlOptions;
curlOptions.SslVerifyPeer = false;
auto implementationClient = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
Expand All @@ -37,16 +30,15 @@ void SendRequest(std::string target)
{

Azure::Core::Context context;
// auto duration = std::chrono::milliseconds(1000);
// auto deadline = std::chrono::system_clock::now() + duration;
auto request
= Azure::Core::Http::Request(Azure::Core::Http::HttpMethod::Get, Azure::Core::Url(target));
auto response = implementationClient->Send(request, context); //.WithDeadline(deadline));
auto response = implementationClient->Send(request, context);
// Make sure to pull all bytes from network.
auto body = response->ExtractBodyStream()->ReadToEnd();
}
catch (std::exception const&)
{
// don't print exceptions, they are happening at each request, this is the point of the test
}
}

Expand All @@ -60,11 +52,11 @@ void Operation(int repetitions)
}
}

int main(int argc, char** argv) // i can have either 0 or 2 params here
int main(int argc, char**)
{
(void)argv; // to get rid of the unused warning
// some param was passed to the program , which happens only in build mode, not run of the docker
// file. thus we will run a quick test to make sure the executable runs.
// some param was passed to the program, doesn't matter what it is,
// it is meant for the moment to just run a quick iteration to check for sanity of the test.
// since prototype TODO: pass in warmup/rounds/requests as params.
if (argc != 1)
{
std::cout << "--------------\tBUILD TEST\t--------------" << std::endl;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
//
// Dummy parameter to handle defaults the script passes in
param testApplicationOid string = ''

resource config 'Microsoft.AppConfiguration/configurationStores@2020-07-01-preview' = {
name: 'config-${resourceGroup().name}'
location: resourceGroup().location
sku: {
name: 'Standard'
}
}

output RESOURCE_GROUP string = resourceGroup().name
output AZURE_CLIENT_OID string = testApplicationOid
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
{{- include "stress-test-addons.deploy-job-template.from-pod" (list . "stress.deploy-example") -}}
{{- define "stress.deploy-example" -}}
metadata:
labels:
testName: "libcurl-stress-test"
name: "libcurl-stress-test"
spec:
containers:
- name: libcurl-stress-test
image: stresspgs7b6dif73rup6.azurecr.io/azuresdkforcpp/curlstress:latest
imagePullPolicy: Always
command:
[
"valgrind",
"--tool=memcheck",
"-s",
"./azure-core-libcurl-stress-test",
]
{{- include "stress-test-addons.container-env" . | nindent 6 }}
{{- end -}}

0 comments on commit 992a3a9

Please sign in to comment.