You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "github-actions[bot] (via GitHub)" <gi...@apache.org> on 2023/06/21 11:06:22 UTC

[GitHub] [doris] github-actions[bot] commented on a diff in pull request #21085: Move memtable

github-actions[bot] commented on code in PR #21085:
URL: https://github.com/apache/doris/pull/21085#discussion_r1236807083


##########
be/test/runtime/sink_stream_mgr_test.cpp:
##########
@@ -0,0 +1,375 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gen_cpp/Types_types.h>

Review Comment:
   warning: 'gen_cpp/Types_types.h' file not found [clang-diagnostic-error]
   ```cpp
   #include <gen_cpp/Types_types.h>
            ^
   ```
   



##########
be/test/runtime/sink_stream_mgr_test.cpp:
##########
@@ -0,0 +1,375 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <gen_cpp/Types_types.h>
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+#include <unistd.h>
+
+#include "common/config.h"
+#include "common/status.h"
+#include "gen_cpp/BackendService_types.h"
+#include "gen_cpp/FrontendService_types.h"
+#include "gtest/gtest_pred_impl.h"
+#include "runtime/exec_env.h"
+#include "runtime/sink_stream_mgr.h"
+#include <gflags/gflags.h>
+#include <butil/logging.h>
+#include <brpc/channel.h>
+#include <brpc/stream.h>
+#include <brpc/server.h>
+#include <gen_cpp/internal_service.pb.h>
+#include <service/internal_service.h>
+#include <functional>
+#include <olap/storage_engine.h>
+
+namespace doris {
+
+static const uint32_t MAX_PATH_LEN = 1024;
+StorageEngine* z_engine = nullptr;
+static const std::string zTestDir = "./data_test/data/sink_stream_mgr_test";
+
+class SinkStreamMgrTest: public testing::Test {
+public:
+
+    class Handler : public StreamInputHandler {
+    public:
+        int on_received_messages(StreamId id, butil::IOBuf* const messages[], size_t size) override {
+            std::cerr << "on_received_messages" << std::endl;
+            for (size_t i = 0; i < size; ++i) {
+                    std::cerr << "message[" << i << "]: " << messages[i]->to_string() << std::endl;
+            }
+            return 0;
+        }
+        void on_idle_timeout(StreamId id) override {
+            std::cerr << "on_idle_timeout" << std::endl;
+        }
+        void on_closed(StreamId id) override {
+            std::cerr << "on_closed" << std::endl;
+        }
+    };
+
+    class MockSinkClient {
+    public:
+        MockSinkClient() = default;
+        ~MockSinkClient() = default;
+
+        class MockClosure : public google::protobuf::Closure {
+        public:
+            MockClosure(std::function<void ()> cb) : _cb(cb) {}
+            void Run() override {
+                _cb();
+                delete this;
+            }
+        private:
+            std::function<void ()> _cb;
+        };
+
+        Status connect_stream() {
+            brpc::Channel channel;
+            std::cerr << "connect_stream" << std::endl;
+            // Initialize the channel, NULL means using default options.
+            brpc::ChannelOptions options;
+            options.protocol = brpc::PROTOCOL_BAIDU_STD;
+            options.connection_type = "single";
+            options.timeout_ms = 10000/*milliseconds*/;
+            options.max_retry = 3;
+            CHECK_EQ(0, channel.Init("127.0.0.1:18947", nullptr));
+
+            // Normally, you should not call a Channel directly, but instead construct
+            // a stub Service wrapping it. stub can be shared by all threads as well.
+            PBackendService_Stub stub(&channel);
+
+            _stream_options.handler = &_handler;
+            if (brpc::StreamCreate(&_stream, _cntl, &_stream_options) != 0) {
+                LOG(ERROR) << "Fail to create stream";
+                return Status::InternalError("Fail to create stream");
+            }
+
+            POpenStreamSinkRequest* request = new POpenStreamSinkRequest();
+            POpenStreamSinkResponse* response = new POpenStreamSinkResponse();
+            std::shared_ptr<PUniqueId> id = std::make_shared<PUniqueId>();
+            id->set_hi(1);
+            id->set_lo(1);
+            request->set_allocated_id(id.get());
+            stub.open_stream_sink(&_cntl, request, response, nullptr);
+            request->release_id();
+            delete request;
+            delete response;
+            if (_cntl.Failed()) {
+                std::cerr << "open_stream_sink failed" << std::endl;
+                LOG(ERROR) << "Fail to open stream sink";
+                return Status::InternalError("Fail to open stream sink");
+            }
+
+            return Status::OK();
+        }
+
+        StreamId get_stream_id() {
+            return _stream;
+        }
+
+        void disconnect() {

Review Comment:
   warning: method 'disconnect' can be made const [readability-make-member-function-const]
   
   ```suggestion
           void disconnect() const {
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org