You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by xy...@apache.org on 2023/02/13 01:59:53 UTC

[pulsar-client-cpp] branch branch-3.1 updated: Fix the broken master by the upgrade of GTest (#133)

This is an automated email from the ASF dual-hosted git repository.

xyz pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/pulsar-client-cpp.git


The following commit(s) were added to refs/heads/branch-3.1 by this push:
     new 6d14fee  Fix the broken master by the upgrade of GTest (#133)
6d14fee is described below

commit 6d14fee065d56284f20561de03b1115fc98ad4ae
Author: Yunze Xu <xy...@163.com>
AuthorDate: Thu Dec 1 15:31:54 2022 +0800

    Fix the broken master by the upgrade of GTest (#133)
    
    (cherry picked from commit 91a97eb124e3174a465a483556d1d769df4c2962)
---
 .github/workflows/ci-pr-validation.yaml |  2 +-
 tests/KeyValueSchemaTest.cc             | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.github/workflows/ci-pr-validation.yaml b/.github/workflows/ci-pr-validation.yaml
index 6c2524d..c7a60a5 100644
--- a/.github/workflows/ci-pr-validation.yaml
+++ b/.github/workflows/ci-pr-validation.yaml
@@ -59,7 +59,7 @@ jobs:
 
   unit-tests:
     name: Run unit tests
-    runs-on: ubuntu-latest
+    runs-on: ubuntu-22.04
     timeout-minutes: 120
 
     steps:
diff --git a/tests/KeyValueSchemaTest.cc b/tests/KeyValueSchemaTest.cc
index 02b55ee..d0375b9 100644
--- a/tests/KeyValueSchemaTest.cc
+++ b/tests/KeyValueSchemaTest.cc
@@ -25,10 +25,14 @@ using namespace pulsar;
 
 static const std::string lookupUrl = "pulsar://localhost:6650";
 
-class KeyValueSchemaTest : public ::testing::TestWithParam<KeyValueEncodingType> {
+// NOTE: Here we use int instead of KeyValueEncodingType because of a bug of GTest with GCC 11, see
+// https://github.com/google/googletest/issues/4079
+class KeyValueSchemaTest : public ::testing::TestWithParam<int> {
    public:
     void TearDown() override { client.close(); }
 
+    KeyValueEncodingType getEncodingType() const { return static_cast<KeyValueEncodingType>(GetParam()); }
+
     void createProducer(const std::string& topic, Producer& producer) {
         ProducerConfiguration configProducer;
         configProducer.setSchema(getKeyValueSchema());
@@ -45,7 +49,7 @@ class KeyValueSchemaTest : public ::testing::TestWithParam<KeyValueEncodingType>
     SchemaInfo getKeyValueSchema() {
         SchemaInfo keySchema(JSON, "key-json", jsonSchema);
         SchemaInfo valueSchema(JSON, "value-json", jsonSchema);
-        return SchemaInfo(keySchema, valueSchema, GetParam());
+        return SchemaInfo(keySchema, valueSchema, getEncodingType());
     }
 
    private:
@@ -55,7 +59,7 @@ class KeyValueSchemaTest : public ::testing::TestWithParam<KeyValueEncodingType>
 };
 
 TEST_P(KeyValueSchemaTest, testKeyValueSchema) {
-    auto encodingType = GetParam();
+    auto encodingType = getEncodingType();
     const std::string topicName =
         "testKeyValueSchema-" + std::string(strEncodingType(encodingType)) + std::to_string(time(nullptr));
 
@@ -85,5 +89,5 @@ TEST_P(KeyValueSchemaTest, testKeyValueSchema) {
     ASSERT_EQ(keyValueData.getValueAsString(), valueData);
 }
 
-INSTANTIATE_TEST_CASE_P(Pulsar, KeyValueSchemaTest,
-                        ::testing::Values(KeyValueEncodingType::INLINE, KeyValueEncodingType::SEPARATED));
+INSTANTIATE_TEST_SUITE_P(Pulsar, KeyValueSchemaTest,
+                         ::testing::Values(KeyValueEncodingType::INLINE, KeyValueEncodingType::SEPARATED));