Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Integration Test by Generating TLS/mTLS Certificates via MSBuild #5818

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

sandy2008
Copy link

@sandy2008 sandy2008 commented Sep 9, 2024

Fixes #2009
Based on PR #4731

Changes

This PR introduces an improvement in how integration tests handle TLS/mTLS certificates by generating them at build time via MSBuild. The generated certificates are stored in the build output directory.

Key Changes:

  • Added MSBuild tasks to generate certificates/keys during the build process.
  • Certificates are generated via PowerShell on Windows and Bash on Unix.

Merge requirement checklist

  • CONTRIBUTING guidelines followed (license requirements, nullable enabled, static analysis, etc.)
  • Unit tests added/updated
  • Appropriate CHANGELOG.md files updated for non-trivial changes
  • Changes in public API reviewed (if applicable)

License Information

THIS SOFTWARE IS CONTRIBUTED SUBJECT TO THE TERMS OF THE APACHE LICENSE V.2.0. YOU MAY OBTAIN A COPY OF THE LICENSE AT https://github.com/open-telemetry/opentelemetry-python/blob/master/LICENSE.

THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE MAY BE REDISTRIBUTED TO OTHERS ONLY BY EFFECTIVELY USING THIS OR ANOTHER EQUIVALENT DISCLAIMER IN ADDITION TO ANY OTHER REQUIRED LICENSE TERMS.

@sandy2008 sandy2008 requested a review from a team September 9, 2024 02:44
@github-actions github-actions bot added the pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package label Sep 9, 2024
@sandy2008 sandy2008 mentioned this pull request Sep 9, 2024
4 tasks
Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.21%. Comparing base (6250307) to head (f6c4b00).
Report is 321 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5818      +/-   ##
==========================================
+ Coverage   83.38%   86.21%   +2.83%     
==========================================
  Files         297      257      -40     
  Lines       12531    11168    -1363     
==========================================
- Hits        10449     9629     -820     
+ Misses       2082     1539     -543     
Flag Coverage Δ
unittests ?
unittests-Project-Experimental 86.19% <ø> (?)
unittests-Project-Stable 86.17% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 223 files with indirect coverage changes

@sandy2008
Copy link
Author

@reyang Hi! Fixed accordingly.

@sandy2008
Copy link
Author

@reyang Do you know what's the next step to get it merged, so that we can work on the remaining PRs to support mTLS? 🥹

@reyang
Copy link
Member

reyang commented Sep 11, 2024

@reyang Do you know what's the next step to get it merged, so that we can work on the remaining PRs to support mTLS? 🥹

@sandy2008
Copy link
Author

@reyang @alanwest Please kindly review again!

@alanwest
Copy link
Member

@sandy2008 try running the test locally. The CI does not pass.

@sandy2008
Copy link
Author

@sandy2008 try running the test locally. The CI does not pass.

Sorry sorry, I forgot to push one change..

@sandy2008
Copy link
Author

@alanwest Hmm, seems I need to give one fix, will fix it tmr.

@sandy2008
Copy link
Author

Sorry, I was little busy during the weekend, I will work on it again today.

@sandy2008 sandy2008 requested a review from a team as a code owner September 20, 2024 04:23
@sandy2008
Copy link
Author

@alanwest Please review again, all fixed :)

@alanwest
Copy link
Member

@sandy2008 The test is still failing.

The certs are not being written to the necessary directory

Screenshot 2024-09-20 at 2 25 49 PM

To validate that things will work, you can run this integration test locally in the same way the CI runs it

run: docker compose --file=test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/docker-compose.yml --file=build/docker-compose.${{ matrix.version }}.yml --project-directory=. up --exit-code-from=tests --build

Be sure to run this command from the root of the repository:

docker compose --file=test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/docker-compose.yml --file=build/docker-compose.net8.0.yml --project-directory=. up --exit-code-from=tests --build

@sandy2008
Copy link
Author

sandy2008 commented Sep 25, 2024

```shell
docker compose --file=test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/docker-compose.yml --file=build/docker-compose.net8.0.yml --project-directory=. up --exit-code-from=tests --build

Hi, it seems that the tests are successfully locally, is it a way that I can trigger my own tests on cloud?

opentelemetry-dotnet-tests-1           | Test Run Successful.
opentelemetry-dotnet-tests-1           | Total tests: 26
opentelemetry-dotnet-tests-1           |      Passed: 26
opentelemetry-dotnet-tests-1           |  Total time: 1.0136 Minutes
opentelemetry-dotnet-tests-1 exited with code 0
Aborting on container exit...
[+] Stopping 2/0
 ✔ Container opentelemetry-dotnet-tests-1           Stopped                0.0s 
 ✔ Container opentelemetry-dotnet-otel-collector-1  Stopped                0.1

@sandy2008
Copy link
Author

```shell
docker compose --file=test/OpenTelemetry.Exporter.OpenTelemetryProtocol.Tests/IntegrationTest/docker-compose.yml --file=build/docker-compose.net8.0.yml --project-directory=. up --exit-code-from=tests --build

Hi, it seems that the tests are successfully locally, is it a way that I can trigger my own tests on cloud?

opentelemetry-dotnet-tests-1           | Test Run Successful.
opentelemetry-dotnet-tests-1           | Total tests: 26
opentelemetry-dotnet-tests-1           |      Passed: 26
opentelemetry-dotnet-tests-1           |  Total time: 1.0136 Minutes
opentelemetry-dotnet-tests-1 exited with code 0
Aborting on container exit...
[+] Stopping 2/0
 ✔ Container opentelemetry-dotnet-tests-1           Stopped                0.0s 
 ✔ Container opentelemetry-dotnet-otel-collector-1  Stopped                0.1

Oh I re-produced the error, let me fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:OpenTelemetry.Exporter.OpenTelemetryProtocol Issues related to OpenTelemetry.Exporter.OpenTelemetryProtocol NuGet package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add OTLP Exporter TLS/mTLS configuration options
5 participants