Skip to content

Implementing smoke tests with TAP-compliant output format #3521

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

pulimsr
Copy link
Contributor

@pulimsr pulimsr commented Aug 20, 2025

Description of changes: added a .sh and .py file for implementing smoke tests

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@@ -67,7 +67,7 @@ if (LEGACY_BUILD)
option(BUILD_OPTEL_OTLP_BENCHMARKS "Enables building the benchmark tests with open telemetry OTLP clients" OFF)
option(USE_TLS_V1_2 "Set http client to enforce TLS 1.2" ON)
option(USE_TLS_V1_3 "Set http client to enforce TLS 1.3" OFF)
option(ENABLE_SMOKE_TESTS "Enable smoke tests" OFF)
option(ENABLE_SMOKE_TESTS "Enable smoke tests" ON)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should still leave this off by default, we should enable it in our CI by passing -DENABLE_SMOKE_TESTS=ON to the cmake command found here

@@ -16,7 +16,7 @@ int main(int argc, char** argv)
// Created dir by this process will be set with mode 0777, so that multiple users can build on the same machine
umask(0);
#endif
Aws::Testing::RedirectHomeToTempIfAppropriate();
//Aws::Testing::RedirectHomeToTempIfAppropriate();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets just remove it instead of commenting it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this file from the PR, it gets re-shuffled each time it code gens, we should fix that, but lets leave it out of this PR

@@ -14,7 +14,7 @@ dependencyResolutionManagement {
versionCatalogs {
create("codegen") {
// Smithy dependencies
version("smithy", "1.57.1") // Centralize the version for Smithy-related dependencies
version("smithy", "1.61.0") // Centralize the version for Smithy-related dependencies
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import subprocess
import argparse

GREEN = '\033[32m'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Green, Bold, and Reset are used to color/format output in a terminal if used in a print statement i.e.

GREEN = '\033[32m'
RESET = '\033[0m'

print(GREEN + "This text will be green." + RESET)
print("This text will be in the default color.")

however these variables are unused -- why do we define then never use them?


def should_run_service(service):
service_ids = os.environ.get('AWS_SMOKE_TEST_SERVICE_IDS', '')
if not service_ids:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldnt we hard fail if the env var AWS_SMOKE_TEST_SERVICE_IDS isnt present? i

stdout_lines = test_result.stdout.strip().split('\n') if test_result.stdout.strip() else []
error_msg = None

# Look for failure message in stdout
Copy link
Contributor

@sbiscigl sbiscigl Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets leave std::cout checking out of this, and remove writing from std::cout from the tests.This actually will break our format because both gtest and our custom test logic will all write to the same place corrupting the output, instead we should use the gtest output format feature to make this easier for the example

#include <gmock/gmock.h>
#include <gtest/gtest.h>

using namespace testing;

class SolutionTest : public Test {};

TEST_F(SolutionTest, ShouldWork) {
  ASSERT_TRUE(true);
}

TEST_F(SolutionTest, ShouldAlsoWork) {
  ASSERT_FALSE(true);
}

if we invoke this with

./test_executable --gtest_output=json:output.json > /dev/null

in output.json we will see

{
  "tests": 2,
  "failures": 1,
  "disabled": 0,
  "errors": 0,
  "timestamp": "2025-08-21T10:53:01Z",
  "time": "0s",
  "name": "AllTests",
  "testsuites": [
    {
      "name": "SolutionTest",
      "tests": 2,
      "failures": 1,
      "disabled": 0,
      "errors": 0,
      "timestamp": "2025-08-21T10:53:01Z",
      "time": "0s",
      "testsuite": [
        {
          "name": "ShouldWork",
          "file": "\/Users\/sbiscigl\/untitled\/test\/ltest.cpp",
          "line": 12,
          "status": "RUN",
          "result": "COMPLETED",
          "timestamp": "2025-08-21T10:53:01Z",
          "time": "0s",
          "classname": "SolutionTest"
        },
        {
          "name": "ShouldAlsoWork",
          "file": "\/Users\/sbiscigl\/untitled\/test\/test.cpp",
          "line": 16,
          "status": "RUN",
          "result": "COMPLETED",
          "timestamp": "2025-08-21T10:53:01Z",
          "time": "0s",
          "classname": "SolutionTest",
          "failures": [
            {
              "failure": "\/Users\/sbiscigl\/untitled\/test\test.cpp:17\nValue of: true\n  Actual: true\nExpected: false\n",
              "type": ""
            }
          ]
        }
      ]
    }
  ]
}

so the idea here would be to run the test with --gtest_output=json:output.json > /dev/null then parse the resulting json, transforming it into the TAP output format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants