fgerlits commented on code in PR #1586:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1586#discussion_r1234048245
##########
docker/test/integration/cluster/checkers/AwsChecker.py:
##########
@@ -29,6 +29,18 @@ def check_s3_server_object_data(self, container_name,
test_data):
(code, file_data) =
self.container_communicator.execute_command(container_name, ["cat", s3_mock_dir
+ "/binaryData"])
return code == 0 and file_data == test_data
+ @retry_check()
+ def check_s3_server_object_hash(self, container_name: str,
expected_file_hash: str):
+ (code, output) =
self.container_communicator.execute_command(container_name, ["find",
"/s3mockroot/test_bucket", "-mindepth", "1", "-maxdepth", "1", "-type", "d"])
+ if code != 0:
+ return False
+ s3_mock_dir = output.strip()
+ (code, md5_output) =
self.container_communicator.execute_command(container_name, ["md5sum",
s3_mock_dir + "/binaryData"])
+ if code != 0:
+ return False
+ file_hash = md5_output.split(' ')[0].strip()
+ return code == 0 and file_hash == expected_file_hash
Review Comment:
we could remove the second `code == 0` check now:
```suggestion
if code != 0:
return False
file_hash = md5_output.split(' ')[0].strip()
return file_hash == expected_file_hash
```
##########
extensions/aws/s3/MultipartUploadStateStorage.cpp:
##########
@@ -0,0 +1,165 @@
+/**
+ * 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 "MultipartUploadStateStorage.h"
+
+#include <unordered_map>
+
+#include "utils/StringUtils.h"
+
+namespace org::apache::nifi::minifi::aws::s3 {
+
+MultipartUploadStateStorage::MultipartUploadStateStorage(const std::string&
state_directory, const std::string& state_id) {
+ if (state_directory.empty()) {
+ char format[] = "/var/tmp/nifi-minifi-cpp.s3-multipart-upload.XXXXXX";
+ state_file_path_ =
minifi::utils::file::FileUtils::create_temp_directory(format);
+ } else {
+ state_file_path_ = std::filesystem::path(state_directory) /
std::string(state_id + "-s3-multipart-upload-state.properties");
+ if (!std::filesystem::exists(state_file_path_)) {
+ std::filesystem::create_directories(state_file_path_.parent_path());
+ std::ofstream ofs(state_file_path_);
Review Comment:
it's commented out now; it would be better to delete the line
##########
extensions/aws/s3/S3Wrapper.cpp:
##########
@@ -297,4 +404,57 @@ FetchObjectResult S3Wrapper::fillFetchObjectResult(const
GetObjectRequestParamet
return result;
}
+void S3Wrapper::addListMultipartUploadResults(const
Aws::Vector<Aws::S3::Model::MultipartUpload>& uploads,
std::optional<std::chrono::milliseconds> max_upload_age,
+ std::vector<MultipartUpload>& filtered_uploads) {
+ const auto now = Aws::Utils::DateTime::Now();
+ for (const auto& upload : uploads) {
+ if (max_upload_age && now - upload.GetInitiated() <= *max_upload_age) {
+ logger_->log_debug("Multipart upload with key '%s' and upload id '%s'
did not meet the age limit", upload.GetKey(), upload.GetUploadId());
+ continue;
+ }
Review Comment:
So `multipartUploadExistsInS3()`, `listMultipartUploads()` and
`addListMultipartUploadResults()` only list/check uploads which have aged off?
In that case, the names of the functions, and also local variables like
`result` and `filtered_upload` should reflect this, to make the logic clearer.
Also, it would help people reading the code if the log message was something
like "... has not aged off yet" instead of the vaguer ".. did not meet the age
limit".
##########
extensions/aws/tests/PutS3ObjectTests.cpp:
##########
@@ -71,7 +87,7 @@ TEST_CASE_METHOD(PutS3ObjectTestsFixture, "Test AWS
credential setting", "[awsCr
setCredentialsService();
}
- test_controller.runSession(plan, true);
+ test_controller.runSession(plan);
Review Comment:
that's weird, but not important
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]