Skip to content

Commit

Permalink
Initial cut at AMQP protocol implementation. (#4498)
Browse files Browse the repository at this point in the history
* Sync eng/common directory with azure-sdk-tools for PR 5608 (#4411)

* ongoing

* Move get-codeowners scripts and tests to their own dirs

* address PR remarks

* Fix CodeOwnerFileLocation path, fix casing, and dedup param defaults

* fix param names

* add todos on needed changes in cpp repo

* Add CodeownersFileLocation to Get-Codeowners and use $null for default param values

* move get-codeowners back to scripts/ and rename -functions to .lib

* fix: use empty string as defaults instead of $nulls, to fix invocation

* fix bug with invocation of Get-Codeowners + add support for passing IncludeNonUserAliases as switch

* fix path iin Metadata-Helpers.ps1

* fix typo

* Update archetype-cpp-release.yml

---------

Co-authored-by: Konrad Jamrozik <[email protected]>

* First attempt at fixing nlohmann doctest compilation error (#4499)

* First attempt at fixing nlohmann doctest compilation error

* fixed compilation issue

* Fixed ApiView generation for azure core

* update doctest lib to 2.4.11 (#4501)

* Migrate Ubuntu 18 to 22 directly in the matricses (#4442)

* First cut at migrating Ubuntu 18 to 22 directly in the matricses

* Try 20.04

* Remove azure.list from apt configuration on 22.04

* Parens

* gpp-8 on Ubuntu 20.04

* Remove g++-5

* Move config changes to steps/

* Remove g++-5 from live tests

* Update eng/pipelines/templates/steps/fix-linux-1es-configs.yml

Co-authored-by: Ben Broderick Phillips <[email protected]>

* Review feedback

* Finish renaming

* Setting line coverage target to 91%

---------

Co-authored-by: Ben Broderick Phillips <[email protected]>

* Initial population of azure-core-amqp

* cspell

* AMQP specific cspell dictionary

* CI pipeline fixes

* azure-uamqp-c cannot work on UWP builds

* Final cspell error; added amqp package to artifacts

* clang-format; added copyright notices to everything

* Added required files

* more CI fixes

* Renamed some files

* Renamed some files

* fixed case of amqp directory

* Renamed models directory

* Renamed network directory

* Most filenames are now lower case

* Hopefully fix CI pipeline failures

* Sort lines in cmakelists.txt

* Fixed name of message_target.cp

* Fixed name of transfer_instance.cpp

* Added preset for AMQP builds; reverted change from cmakesettings.json

* Add AMQP to doxygen generation; fixed clang-format issue

* Case folding fixes

* Correctly set up for DLL builds; removed diagnostic code

* Fixed socket listener to initialize platform

* clang-format

* clang-format

* clang-format; clang compilation fix

* Moved message sender implementation to shared pointer to enable copy and move semantics

* Don't forward declare enums with underlying type

* MOved MessageReceiver into an implementation class

* A couple of clang compiler fixes

* Moved all connection and session code to shared pointers

* Converted network callbacks to use events; restructured network to use shared pointer

* clang-format fixes

* case sensitivity

* clang fixes 4

random port for socket listener echo tests

clang-format

Random port for two more tests

Null event handler before destroying messagereceiver

clang-format

Random port for ReceiverOpenClose

Random port for LinkAttachDetach

Use random port for session tests

gcc warnings again 3

gcc warnings again 2

gcc warnings again

Print errno on socket listener start error

gcc warnings; enabled code coverage for amqp

clang-format

Missed file

clang fixes 8

clang fixes 7

clang fixes 6

clang fixes 5

clang fixes 3

clang fixes 2

clang fixes

* Catch exception thrown from worker thread

* Sample fixes

* Added context to wait for polled result

* clang build fix

clang build fix

* wait until listener thread completes before starting message receiver

* wait until listener thread completes before starting message receiver 2

* more thread cleanup changes

* more linux diagnostics 5

more linux diagnostics 13

more linux diagnostics 12

more linux diagnostics 11

more linux diagnostics 10

more linux diagnostics 9

more linux diagnostics 8

more linux diagnostics 7

more linux diagnostics 6

more linux diagnostics 4

more linux diagnostics 3

more linux diagnostics 2

more linux diagnostics

* Search for ports at 5000, not 0x5000; clang-format changes

* Fixed AV in MessageSenderReceiver when test is cancelled;

* Diagnostics for FindAvailableSOcket

* Diagnostics for FindAvailableSOcket

* Diagnostics for FindAvailableSOcket

* pull request feedback

* Added cbs test

* Finished snake case rename

* Fixed copyright and license text

* Undid accidental checkin

* Moved common and models types to _internal terminal namespace

* Basic CBS authentication test

* removed test resource name

* Fixed SAS token samples

* Sanitized token writer sample

* CI pipeline fixes

* Clear event callback when destroying message sender; close sender and receiver when done with test thread

* ApiView fixes; clang-format

* Fixed a coupe of CI pipeline issues

* Moved credenial type to a member variable not a virtual method returnign a constant

* Full mock implementation of claims based security

* Renamed ClaimBasedSecurity to ClaimsBasedSecurity; clang-format; clang fixes

* Improved code coverage.

* clang fix

* unit test fix

* Improved code coverage for connection string tests

* Added test for authenticated sender and receiver

* Added message source and target tests

Use better constructor for tokencredential

Use better constructor for tokencredential

crlf at the end of every file; made ClaimBasedSecurity class a _detail class

More code coverage fixes

Improved coe coverage for amqp message

Message->Value conversion 3

Message->Value conversion 2

Try casting message to value

Try casting message to value

Reverted attestation chagnes 2

Added more tests

Fixed doxygen issue

Don't use sender unless sender is set

Removed incorrect test

* More code coverage fixes

* Removed 2 param ctor

* More code coverage

* clang-format

* Hopefully final code coverage fixes

* clang-format

* Moved all amqp types to _internal terminal namespace

* Undid attestation change

* clang-format fixes

* Renamed Azure::Core::Amqp::Value to Azure::Core::Amqp::AmqpValue because Value is too generic a type name when you have 'using namespace' directives

* clang-format

* clang-format2

* turn crash into failure

* Try using async send rather than sync send for responding to CBS operations

* It helps to build the code you write

* Trigger CI

---------

Co-authored-by: Azure SDK Bot <[email protected]>
Co-authored-by: Konrad Jamrozik <[email protected]>
Co-authored-by: Victor Vazquez <[email protected]>
Co-authored-by: Daniel Jurek <[email protected]>
Co-authored-by: Ben Broderick Phillips <[email protected]>
  • Loading branch information
6 people authored Apr 3, 2023
1 parent 0726d84 commit 881552e
Show file tree
Hide file tree
Showing 110 changed files with 13,226 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"Adls",
"ahojnnes",
"Aloctl",
"AMQP",
"AMQPS",
"AMQPVALUE",
"azcore",
"azsdk",
"azsdkengsys",
Expand All @@ -47,6 +50,7 @@
"cmake",
"CMOCKA",
"Cobertura",
"countof",
"ctest",
"cuse",
"CUSEUAP",
Expand All @@ -57,10 +61,10 @@
"Deserializes",
"DFETCH",
"DMSVC",
"DVCPKG",
"docfx",
"DPAPI",
"DRUN",
"DVCPKG",
"DWARNINGS",
"easia",
"eastus",
Expand Down Expand Up @@ -139,6 +143,7 @@
"stoull",
"STREQ",
"uaenorth",
"uamqp",
"uksouth",
"undeleted",
"unscoped",
Expand Down
40 changes: 37 additions & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 4,
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 13,
Expand Down Expand Up @@ -59,7 +59,8 @@
"inherits": "windows-default",
"hidden": true,
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows"
"VCPKG_TARGET_TRIPLET": "x64-windows",
"BUILD_SHARED_LIBS": true
},
"architecture": {
"value": "x64",
Expand All @@ -73,7 +74,8 @@
"inherits": "windows-default",
"hidden": true,
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x86-windows"
"VCPKG_TARGET_TRIPLET": "x86-windows",
"BUILD_SHARED_LIBS": true
},
"architecture": {
"value": "x86",
Expand Down Expand Up @@ -184,6 +186,20 @@
"BUILD_TRANSPORT_CURL": true
}
},
{
"name": "x64-debug-tests",
"displayName": "X64 Debug With Tests, static, winhttp",
"description": "Windows X64 Debug build with Tests configured",
"inherits": "x64-debug",
"cacheVariables": {
"BUILD_TESTING": true,
"ENABLE_PROXY_TESTS": false,
"BUILD_SAMPLES": true,
"BUILD_PERFORMANCE_TESTS": true,
"BUILD_TRANSPORT_WINHTTP": true,
"BUILD_TRANSPORT_CURL": true
}
},
{
"name": "x64-static-debug-tests",
"displayName": "X64 Debug With Tests, static, winhttp",
Expand All @@ -197,6 +213,24 @@
"BUILD_TRANSPORT_WINHTTP": true
}
},
{
"name": "x64-static-debug-amqp-tests",
"displayName": "X64 Debug With Tests, static, AMQP",
"description": "Windows X64 Debug build with Tests and AMQP configured",
"inherits": "x64-static-debug-tests",
"cacheVariables": {
"ENABLE_AZURE_CORE_AMQP": true
}
},
{
"name": "x64-debug-amqp-tests",
"displayName": "X64 Debug With Tests, AMQP",
"description": "Windows X64 Debug build with Tests and AMQP configured",
"inherits": "x64-debug-tests",
"cacheVariables": {
"ENABLE_AZURE_CORE_AMQP": true
}
},
{
"name": "x64-static-debug-tests-curl",
"displayName": "X64 Debug With Tests, static, libcurl",
Expand Down
1 change: 1 addition & 0 deletions eng/pipelines/templates/jobs/archetype-sdk-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ jobs:
-DBUILD_TESTING=OFF
-DBUILD_TRANSPORT_CURL=OFF
-DBUILD_DOCUMENTATION=YES
-DENABLE_AZURE_CORE_AMQP=ON
- pwsh: npm install -g moxygen
displayName: Install Moxygen to generate markdown for docs.microsoft.com
Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/templates/stages/platform-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
},
"TargetPlatform": {
"Win32Api_debug_tests": {
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON -DBUILD_TRANSPORT_WINHTTP=ON -DMSVC_USE_STATIC_CRT=ON",
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON -DBUILD_TRANSPORT_WINHTTP=ON -DMSVC_USE_STATIC_CRT=ON -DENABLE_AZURE_CORE_AMQP=ON",
"BuildArgs": "--parallel 8 --config Debug",
"PublishMapFiles": "true"
}
Expand Down Expand Up @@ -151,7 +151,7 @@
},
"included_coverage": {
"AptDependencies": "gcovr lcov",
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_CODE_COVERAGE=ON -DCMAKE_VERBOSE_MAKEFILE=ON",
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_CODE_COVERAGE=ON -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_AZURE_CORE_AMQP=ON",
"CODE_COVERAGE_COLLECT_ONLY": "1",
"CODE_COVERAGE": "enabled",
"PublishMapFiles": "true"
Expand Down Expand Up @@ -195,7 +195,7 @@
"BuildArgs": "-j 10",
"CC": "/usr/bin/clang-11",
"CXX": "/usr/bin/clang++-11",
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON",
"CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DENABLE_AZURE_CORE_AMQP=ON",
"PublishMapFiles": "true",
"RunProxyTests": true
}
Expand Down
5 changes: 5 additions & 0 deletions sdk/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ if (NOT DISABLE_AZURE_CORE_OPENTELEMETRY)
add_subdirectory(azure-core-tracing-opentelemetry)
endif()

# AMQP is an optional feature, don't include it unless explicitly enabled.
if (ENABLE_AZURE_CORE_AMQP)
add_subdirectory(azure-core-amqp)
endif()

if (BUILD_PERFORMANCE_TESTS)
add_subdirectory(perf)
endif()
Expand Down
7 changes: 7 additions & 0 deletions sdk/core/azure-core-amqp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Release History

## 1.0.0-beta.1 (Unreleased)

### Features Added

- Initial release
136 changes: 136 additions & 0 deletions sdk/core/azure-core-amqp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT

# setting CMAKE_TOOLCHAIN_FILE must happen before creating the project
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../cmake-modules")
include(AzureVcpkg)
az_vcpkg_integrate()

# Azure core is compatible with CMake 3.12
cmake_minimum_required (VERSION 3.12)
project(azure-core-amqp LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)

include(AzureVersion)
include(AzureCodeCoverage)
include(AzureTransportAdapters)
include(AzureDoxygen)
include(AzureGlobalCompileOptions)
include(AzureConfigRTTI)
# Add create_map_file function
include(CreateMapFile)

find_package(Threads REQUIRED)
if(NOT AZ_ALL_LIBRARIES)
find_package(azure-core-cpp CONFIG QUIET)
if(NOT azure-core-cpp_FOUND)
find_package(azure-core-cpp REQUIRED)
endif()
endif()

find_package(uamqp CONFIG REQUIRED)
find_package(umock_c)
find_package(azure_macro_utils_c CONFIG REQUIRED)
find_package(azure_c_shared_utility CONFIG REQUIRED)

set (AZURE_CORE_AMQP_HEADER
inc/azure/core/amqp/cancellable.hpp
inc/azure/core/amqp/claims_based_security.hpp
inc/azure/core/amqp/common/async_operation_queue.hpp
inc/azure/core/amqp/common/completion_operation.hpp
inc/azure/core/amqp/common/global_state.hpp
inc/azure/core/amqp/connection.hpp
inc/azure/core/amqp/connection_string_credential.hpp
inc/azure/core/amqp/link.hpp
inc/azure/core/amqp/message_receiver.hpp
inc/azure/core/amqp/message_sender.hpp
inc/azure/core/amqp/models/amqp_header.hpp
inc/azure/core/amqp/models/amqp_message.hpp
inc/azure/core/amqp/models/amqp_properties.hpp
inc/azure/core/amqp/models/amqp_value.hpp
inc/azure/core/amqp/models/message_source.hpp
inc/azure/core/amqp/models/message_target.hpp
inc/azure/core/amqp/models/messaging_values.hpp
inc/azure/core/amqp/session.hpp
)

set(AZURE_CORE_AMQP_SOURCE
src/amqp/cancellable.cpp
src/amqp/claim_based_security.cpp
src/amqp/connection.cpp
src/amqp/connection_string_credential.cpp
src/amqp/link.cpp
src/amqp/message_receiver.cpp
src/amqp/message_sender.cpp
src/amqp/session.cpp
src/common/global_state.cpp
src/models/amqp_header.cpp
src/models/amqp_message.cpp
src/models/amqp_properties.cpp
src/models/amqp_value.cpp
src/models/message_source.cpp
src/models/message_target.cpp
src/models/messaging_values.cpp
src/network/amqp_header_transport.cpp
src/network/sasl_transport.cpp
src/network/socket_listener.cpp
src/network/socket_transport.cpp
src/network/tls_transport.cpp
src/network/transport.cpp
)

add_library(azure-core-amqp ${AZURE_CORE_AMQP_SOURCE} ${AZURE_CORE_AMQP_HEADER})

target_include_directories(
azure-core-amqp
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
$<INSTALL_INTERFACE:include>
)

# make sure that users can consume the project as a library.
add_library(Azure::azure-core-amqp ALIAS azure-core-amqp)

# coverage. Has no effect if BUILD_CODE_COVERAGE is OFF
create_code_coverage(core azure-core-amqp azure-core-amqp-tests "tests?/*;samples?/*")

target_link_libraries(azure-core-amqp PRIVATE uamqp umock_c azure_macro_utils_c PUBLIC Azure::azure-core)

if (CMAKE_VERSION VERSION_GREATER 3.12)
set_property(TARGET azure-core-amqp PROPERTY CXX_STANDARD 14)
endif()


get_az_version("${CMAKE_CURRENT_SOURCE_DIR}/src/private/package_version.hpp")
generate_documentation(azure-core-amqp ${AZ_LIBRARY_VERSION})

az_vcpkg_export(
azure-core-amqp
CORE_AMQP
azure/core/amqp/dll_import_export.hpp
)

az_rtti_setup(
azure-core-amqp
CORE_AMQP
azure/core/amqp/rtti.hpp
)

if(BUILD_TESTING)
# define a symbol that enables some test hooks in code
add_compile_definitions(TESTING_BUILD)

if (NOT AZ_ALL_LIBRARIES)
include(AddGoogleTest)
enable_testing ()
endif()

add_subdirectory(test/ut)
endif()

if(BUILD_SAMPLES)
add_subdirectory ("samples")
endif()
Loading

0 comments on commit 881552e

Please sign in to comment.