removed e2e core tests (#1215)

This commit is contained in:
Victor Vazquez 2020-12-18 19:02:10 +00:00 committed by GitHub
parent 0d312028ce
commit 78df96ab6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 0 additions and 655 deletions

View File

@ -63,10 +63,6 @@ include(${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/az_version.cmake)
# add_subdirectory(sdk/core/performance-stress)
add_subdirectory(sdk/core/azure-core)
if(BUILD_TESTING)
add_subdirectory(sdk/core/azure-core/test/e2e)
endif()
add_subdirectory(sdk/identity/azure-identity)
add_subdirectory(sdk/storage)

View File

@ -1,48 +0,0 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
if (BUILD_TRANSPORT_CURL)
cmake_minimum_required (VERSION 3.13)
set(TARGET_NAME "azure_core_with_curl")
set(TARGET_NAME_STREAM "azure_core_with_curl_stream")
set(TARGET_NAME_STORAGE_ISSUE_249 "azure_core_storage_issue_249")
set(TARGET_NAME_STORAGE_ISSUE_248 "azure_core_storage_issue_248")
set(TARGET_NAME_STORAGE_REUSE_CONNECTION "azure_hang")
project(${TARGET_NAME} LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
add_executable (
${TARGET_NAME}
azure_core_with_curl_bodyBuffer
)
add_executable (
${TARGET_NAME_STREAM}
azure_core_with_curl_bodyStream
)
add_executable (
${TARGET_NAME_STORAGE_ISSUE_249}
azure_core_storage_test_sample
)
add_executable (
${TARGET_NAME_STORAGE_ISSUE_248}
azure_core_storage_list_containers_sample
)
#add_executable (
# ${TARGET_NAME_STORAGE_REUSE_CONNECTION}
# azure_hang
#)
target_link_libraries(${TARGET_NAME} PRIVATE azure-core)
target_link_libraries(${TARGET_NAME_STREAM} PRIVATE azure-core)
target_link_libraries(${TARGET_NAME_STORAGE_ISSUE_249} PRIVATE azure-core)
target_link_libraries(${TARGET_NAME_STORAGE_ISSUE_248} PRIVATE azure-core)
#target_link_libraries(${TARGET_NAME_STORAGE_REUSE_CONNECTION} PRIVATE azure-core azure::storage::files::datalake azure-storage-common)
endif()

View File

@ -1,40 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#include <azure/core/http/curl/curl.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/http/pipeline.hpp>
#include <array>
#include <iostream>
#include <memory>
#include <vector>
using namespace Azure::Core;
using namespace Azure::Core::Http;
using namespace std;
int main()
{
std::vector<std::unique_ptr<HttpPolicy>> policies;
// Add the transport policy
policies.push_back(std::make_unique<TransportPolicy>());
auto httpPipeline = Http::HttpPipeline(policies);
auto context = Azure::Core::GetApplicationContext();
Azure::Core::Http::Url host("http://anglesharp.azurewebsites.net/Chunked");
auto request = Http::Request(Http::HttpMethod::Get, host);
auto response = httpPipeline.Send(context, request);
auto response_bodystream = response->GetBodyStream();
auto response_body = BodyStream::ReadToEnd(context, *response_bodystream);
cout << response_body.data() << endl;
return 0;
}

View File

@ -1,53 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
#if defined(_MSC_VER)
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <azure/core/http/curl/curl.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/http/pipeline.hpp>
#include <array>
#include <iostream>
#include <memory>
#include <vector>
using namespace Azure::Core;
using namespace Azure::Core::Http;
using namespace std;
int main()
{
std::vector<std::unique_ptr<HttpPolicy>> policies;
// Add the transport policy
policies.push_back(std::make_unique<TransportPolicy>());
auto httpPipeline = Http::HttpPipeline(policies);
auto context = Azure::Core::GetApplicationContext();
// STORAGE_BLOB_WITH_SAS = like
// "https://account.windows.net/azure/container/blob?sv=...&ss=...&..."
Azure::Core::Http::Url host(std::getenv("STORAGE_BLOB_WITH_SAS"));
std::vector<uint8_t> request_bodydata(500 * 1024 * 1024, '1');
cout << request_bodydata.size() << endl;
MemoryBodyStream requestBodyStream(request_bodydata.data(), request_bodydata.size());
auto request = Http::Request(Http::HttpMethod::Put, host, &requestBodyStream);
request.AddHeader("Content-Length", std::to_string(request_bodydata.size()));
request.AddHeader("x-ms-version", "2019-07-07");
request.AddHeader("x-ms-blob-type", "BlockBlob");
auto response = httpPipeline.Send(context, request);
auto bodyS = response->GetBodyStream();
auto body = BodyStream::ReadToEnd(context, *bodyS);
cout << body.data() << endl;
return 0;
}

View File

@ -1,244 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief Simulates customer application that is linked with azure-core and azure-transport-curl
*
*/
#include <azure/core/http/pipeline.hpp>
#include <azure/core/platform.hpp>
#if defined(AZ_PLATFORM_POSIX)
#include <fcntl.h>
#elif defined(AZ_PLATFORM_WINDOWS)
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#include <windows.h>
#endif
#include <azure/core/http/curl/curl.hpp>
#include <azure/core/http/http.hpp>
#include <iostream>
#include <memory>
using namespace Azure::Core;
using namespace Azure::Core::Http;
using namespace std;
constexpr auto BufferSize = 50;
std::vector<uint8_t> buffer(BufferSize);
void doGetRequest(Context const& context, HttpPipeline& pipeline);
void doPutRequest(Context const& context, HttpPipeline& pipeline);
void doHeadRequest(Context const& context, HttpPipeline& pipeline);
void doDeleteRequest(Context const& context, HttpPipeline& pipeline);
void doPatchRequest(Context const& context, HttpPipeline& pipeline);
void printRespose(std::unique_ptr<Http::RawResponse> response);
void doFileRequest(Context const& context, HttpPipeline& pipeline);
int main()
{
try
{
std::vector<std::unique_ptr<HttpPolicy>> policies;
policies.push_back(std::make_unique<RequestIdPolicy>());
RetryOptions retryOptions;
policies.push_back(std::make_unique<RetryPolicy>(retryOptions));
// Add the transport policy
policies.push_back(std::make_unique<TransportPolicy>());
auto httpPipeline = Http::HttpPipeline(policies);
auto context = Azure::Core::GetApplicationContext();
// Both requests uses a body buffer to be uploaded that would produce responses with bodyBuffer
doHeadRequest(context, httpPipeline);
doFileRequest(context, httpPipeline);
doGetRequest(context, httpPipeline);
doPutRequest(context, httpPipeline);
doDeleteRequest(context, httpPipeline);
doPatchRequest(context, httpPipeline);
}
catch (Azure::Core::RequestFailedException const& e)
{
cout << e.what() << endl;
}
return 0;
}
#if defined(AZ_PLATFORM_POSIX)
void doFileRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/put");
cout << "Creating a Put From File request to" << endl
<< "Host: " << host.GetAbsoluteUrl() << endl;
// Open a file that contains: {{"key":"value"}, {"key2":"value2"}, {"key3":"value3"}}
int fd = open("/home/vivazqu/workspace/a", O_RDONLY);
// Create Stream from file starting with offset 18 to 100
auto requestBodyStream = FileBodyStream(fd, 18, 100);
// Limit stream to read up to 17 positions ( {"key2","value2"} )
auto limitedStream = LimitBodyStream(&requestBodyStream, 17);
// Send request
auto request = Http::Request(Http::HttpMethod::Put, host, &limitedStream, true);
request.AddHeader("Content-Length", std::to_string(limitedStream.Length()));
request.AddHeader("File", "fileeeeeeeeeee");
auto response = pipeline.Send(context, request);
// File can be closed at this point
close(fd);
// Response Stream
auto bodyStreamResponse = response->GetBodyStream();
// limit to read response
auto limitedResponse = LimitBodyStream(bodyStreamResponse.get(), 300);
auto body = Http::BodyStream::ReadToEnd(context, limitedResponse);
cout << body.data() << endl << body.size() << endl;
}
#elif defined(AZ_PLATFORM_WINDOWS)
void doFileRequest(Context const& context, HttpPipeline& pipeline)
{
(void)pipeline;
Azure::Core::Http::Url host("https://httpbin.org/put");
cout << "Creating a File request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
// NOTE: To run the sample: Create folder 'home' on main hard drive (like C:/) and then add a file
// `a` in there
//
HANDLE hFile = CreateFile(
"/home/a",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_SEQUENTIAL_SCAN,
NULL);
auto requestBodyStream = std::make_unique<FileBodyStream>(hFile, 20, 200);
auto body = Http::BodyStream::ReadToEnd(context, *requestBodyStream);
cout << body.data() << endl << body.size() << endl;
CloseHandle(hFile);
}
#endif
void doGetRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/get");
cout << "Creating a GET request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
auto requestBodyStream = std::make_unique<MemoryBodyStream>(buffer.data(), buffer.size());
auto request = Http::Request(Http::HttpMethod::Get, host, requestBodyStream.get(), true);
request.AddHeader("one", "GetHeader");
request.AddHeader("other", "GetHeader2");
request.AddHeader("header", "GetValue");
request.AddHeader("Host", "httpbin.org");
cout << endl << "GET:";
printRespose(pipeline.Send(context, request));
}
void doPutRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/put");
cout << "Creating a PUT request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
std::fill(buffer.begin(), buffer.end(), 'x');
buffer[0] = '{';
buffer[1] = '\"';
buffer[3] = '\"';
buffer[4] = ':';
buffer[5] = '\"';
buffer[BufferSize - 2] = '\"';
buffer[BufferSize - 1] = '}'; // set buffer to look like a Json `{"x":"xxx...xxx"}`
auto requestBodyStream = std::make_unique<MemoryBodyStream>(buffer.data(), buffer.size());
auto request = Http::Request(Http::HttpMethod::Put, host, requestBodyStream.get(), true);
request.AddHeader("PUT", "header");
request.AddHeader("PUT2", "header2");
request.AddHeader("PUT3", "value");
request.AddHeader("Host", "httpbin.org");
request.AddHeader("Content-Length", std::to_string(BufferSize));
printRespose(pipeline.Send(context, request));
}
void printRespose(std::unique_ptr<Http::RawResponse> response)
{
if (response == nullptr)
{
cout << "Error. Response returned as null";
throw;
}
cout << endl
<< static_cast<typename std::underlying_type<Http::HttpStatusCode>::type>(
response->GetStatusCode())
<< endl;
cout << response->GetReasonPhrase() << endl;
cout << "headers:" << endl;
for (auto header : response->GetHeaders())
{
cout << header.first << " : " << header.second << endl;
}
cout << "Body (buffer):" << endl;
auto bodyStream = response->GetBodyStream();
if (bodyStream == nullptr)
{
// No body in response
return;
}
Context context;
auto responseBodyVector = Http::BodyStream::ReadToEnd(context, *bodyStream);
// print body only if response has a body. Head Response won't have body
cout << std::string(responseBodyVector.begin(), responseBodyVector.end()) << endl;
// std::cin.ignore();
return;
}
void doPatchRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/patch");
cout << "Creating an PATCH request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
auto request = Http::Request(Http::HttpMethod::Patch, host, true);
cout << endl << "PATCH:";
printRespose(pipeline.Send(context, request));
}
void doDeleteRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/delete");
cout << "Creating an DELETE request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
auto request = Http::Request(Http::HttpMethod::Delete, host, true);
// request.AddHeader("deleteeeee", "httpbin.org");
cout << endl << "DELETE:";
printRespose(pipeline.Send(context, request));
}
void doHeadRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/get");
cout << "Creating an HEAD request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
auto request = Http::Request(Http::HttpMethod::Head, host, true);
request.AddHeader("HEAD", "httpbin.org");
cout << endl << "HEAD:";
printRespose(pipeline.Send(context, request));
}

View File

@ -1,192 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief Simulates customer application that is linked with azure-core and azure-transport-curl
* with Stream Body
*
*/
#include <azure/core/http/curl/curl.hpp>
#include <azure/core/http/http.hpp>
#include <azure/core/http/pipeline.hpp>
#include <array>
#include <iostream>
#include <memory>
#include <vector>
using namespace Azure::Core;
using namespace Azure::Core::Http;
using namespace std;
// For bodyBuffer
constexpr auto BufferSize = 50;
std::vector<uint8_t> buffer(BufferSize);
// For StreamBody
constexpr auto StreamSize = 1024; // 100 MB
std::array<uint8_t, StreamSize> bufferStream;
void doGetRequest(Context const& context, HttpPipeline& pipeline);
void doNoPathGetRequest(Context const& context, HttpPipeline& pipeline);
void doPutRequest(Context const& context, HttpPipeline& pipeline);
void doPutStreamRequest(Context const& context, HttpPipeline& pipeline);
void printStream(Azure::Core::Context const& context, std::unique_ptr<Http::RawResponse> response);
int main()
{
try
{
std::vector<std::unique_ptr<HttpPolicy>> policies;
policies.push_back(std::make_unique<RequestIdPolicy>());
RetryOptions retryOptions;
policies.push_back(std::make_unique<RetryPolicy>(retryOptions));
// Add the transport policy
policies.push_back(std::make_unique<TransportPolicy>());
auto httpPipeline = Http::HttpPipeline(policies);
std::unique_ptr<Http::RawResponse> response;
auto context = Azure::Core::GetApplicationContext();
doGetRequest(context, httpPipeline);
doPutStreamRequest(context, httpPipeline);
doNoPathGetRequest(context, httpPipeline);
doPutRequest(context, httpPipeline);
}
catch (Azure::Core::RequestFailedException const& e)
{
cout << e.what() << endl;
}
return 0;
}
// Request GET with no path
void doNoPathGetRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org");
cout << "Creating a GET request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
auto request = Http::Request(Http::HttpMethod::Get, host);
request.AddHeader("Host", "httpbin.org");
printStream(context, pipeline.Send(context, request));
}
// Request GET with no body that produces stream response
void doGetRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/get//////?arg=1&arg2=2");
cout << "Creating a GET request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
auto request = Http::Request(Http::HttpMethod::Get, host);
request.AddHeader("one", "header");
request.AddHeader("other", "header2");
request.AddHeader("header", "value");
request.AddHeader("Host", "httpbin.org");
request.GetUrl().AppendQueryParameter("dynamicArg", "3");
request.GetUrl().AppendQueryParameter("dynamicArg2", "4");
auto response = pipeline.Send(context, request);
printStream(context, std::move(response));
}
// Put Request with bodyBufferBody that produces stream
void doPutRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://httpbin.org/put/?a=1");
cout << "Creating a PUT request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
std::fill(buffer.begin(), buffer.end(), 'x');
buffer[0] = '{';
buffer[1] = '\"';
buffer[3] = '\"';
buffer[4] = ':';
buffer[5] = '\"';
buffer[BufferSize - 2] = '\"';
buffer[BufferSize - 1] = '}'; // set buffer to look like a Json `{"x":"xxx...xxx"}`
MemoryBodyStream requestBodyStream(buffer.data(), buffer.size());
auto request = Http::Request(Http::HttpMethod::Put, host, &requestBodyStream);
request.AddHeader("one", "header");
request.AddHeader("other", "header2");
request.AddHeader("header", "value");
request.AddHeader("Content-Length", std::to_string(BufferSize));
printStream(context, pipeline.Send(context, request));
}
// Put Request with stream body that produces stream
void doPutStreamRequest(Context const& context, HttpPipeline& pipeline)
{
Azure::Core::Http::Url host("https://putsreq.com/SDywlz7z6j90bJFNvyTO");
cout << "Creating a PUT request to" << endl << "Host: " << host.GetAbsoluteUrl() << endl;
bufferStream.fill('1');
bufferStream[0] = '{';
bufferStream[1] = '\"';
bufferStream[3] = '\"';
bufferStream[4] = ':';
bufferStream[5] = '\"';
bufferStream[StreamSize - 2] = '\"';
bufferStream[StreamSize - 1] = '}'; // set buffer to look like a Json `{"1":"111...111"}`
auto requestBodyStream
= std::make_unique<MemoryBodyStream>(bufferStream.data(), bufferStream.size());
auto request = Http::Request(Http::HttpMethod::Put, host, requestBodyStream.get());
request.AddHeader("one", "header");
request.AddHeader("other", "header2");
request.AddHeader("header", "value");
request.AddHeader("Content-Length", std::to_string(StreamSize));
request.GetUrl().AppendQueryParameter("dynamicArg", "1");
request.GetUrl().AppendQueryParameter("dynamicArg2", "1");
request.GetUrl().AppendQueryParameter("dynamicArg3", "1");
printStream(context, pipeline.Send(context, request));
}
void printStream(Context const& context, std::unique_ptr<Http::RawResponse> response)
{
if (response == nullptr)
{
cout << "Error. Response returned as null";
// std::cin.ignore();
return;
}
cout << static_cast<typename std::underlying_type<Http::HttpStatusCode>::type>(
response->GetStatusCode())
<< endl;
cout << response->GetReasonPhrase() << endl;
cout << "headers:" << endl;
for (auto header : response->GetHeaders())
{
cout << header.first << " : " << header.second << endl;
}
cout << "Body (stream):" << endl;
uint8_t b[100];
auto bodyStream = response->GetBodyStream();
int64_t readCount;
do
{
readCount = bodyStream->Read(context, b, 10);
cout << std::string(b, b + readCount);
} while (readCount > 0);
cout << endl << "Press any key to continue..." << endl;
// std::cin.ignore();
return;
}

View File

@ -1,74 +0,0 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: MIT
/**
* @brief Performs upload and download for n times trying to catch long running bugs.
* Originally set to use 50Mb for 2000 times, which takes ~2.5hours to complete.
*
*/
#if defined(_MSC_VER)
// this option is used to allow the application to use std::getenv without getting a compilation
// warning about it on MSVC.
#define _CRT_SECURE_NO_WARNINGS
#endif
#include <iostream>
#include <azure/storage/blobs/blob.hpp>
#define BLOB_SIZE 50 * 1024ULL * 1024
#define REPEAT_FOR 2000
#define CONCURRENCY 16
int main()
{
using namespace Azure::Storage::Blobs;
std::string containerName = "sample-container";
std::string blobName = "sample-blob";
std::string blobContent;
blobContent.resize(BLOB_SIZE, 'c');
std::string connString(std::getenv("STORAGE_CONNECTION_STRING"));
auto containerClient = BlobContainerClient::CreateFromConnectionString(connString, containerName);
try
{
containerClient.Create();
}
catch (std::runtime_error& e)
{
// The container may already exist
std::cout << e.what() << std::endl;
}
BlockBlobClient blobClient = containerClient.GetBlockBlobClient(blobName);
for (int i = 0; i < REPEAT_FOR; ++i)
{
{
UploadBlockBlobFromOptions options;
options.Concurrency = CONCURRENCY;
blobClient.UploadFrom(
reinterpret_cast<const uint8_t*>(blobContent.data()), blobContent.size(), options);
}
{
std::string download;
download.resize(BLOB_SIZE, '.');
DownloadBlobToOptions options;
options.Concurrency = CONCURRENCY;
blobClient.DownloadTo(reinterpret_cast<uint8_t*>(&download[0]), download.size(), options);
// make sure download content is the one expected
if (download != blobContent)
{
std::cout << "Downloaded content is not the same" << std::endl;
return 1;
}
}
std::cout << i << std::endl;
}
}