lordgamez commented on code in PR #1586:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1586#discussion_r1231973493


##########
extensions/aws/tests/MultipartUploadStateStorageTest.cpp:
##########
@@ -0,0 +1,141 @@
+/**
+ *
+ * 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 "TestBase.h"
+#include "Catch.h"
+#include "s3/MultipartUploadStateStorage.h"
+
+namespace org::apache::nifi::minifi::test {
+
+class MultipartUploadStateStorageTestFixture {
+ public:
+  MultipartUploadStateStorageTestFixture()
+    : upload_storage_(test_controller.createTempDirectory().string(), 
"test_id") {
+  }
+
+ protected:
+  TestController test_controller;
+  minifi::aws::s3::MultipartUploadStateStorage upload_storage_;
+};
+
+TEST_CASE_METHOD(MultipartUploadStateStorageTestFixture, "Store and get 
current key state", "[s3StateStorage]") {
+  REQUIRE(upload_storage_.getState("test_bucket", "key") == std::nullopt);
+  minifi::aws::s3::MultipartUploadState state;
+  state.upload_id = "id1";
+  state.uploaded_parts = 2;
+  state.uploaded_size = 100_MiB;
+  state.part_size = 50_MiB;
+  state.full_size = 200_MiB;
+  state.upload_time = Aws::Utils::DateTime::CurrentTimeMillis();
+  state.uploaded_etags = {"etag1", "etag2"};
+  upload_storage_.storeState("test_bucket", "key", state);
+  REQUIRE(*upload_storage_.getState("test_bucket", "key") == state);
+}
+
+TEST_CASE_METHOD(MultipartUploadStateStorageTestFixture, "Get key upload state 
from multiple keys and buckets", "[s3StateStorage]") {
+  minifi::aws::s3::MultipartUploadState state1;
+  state1.upload_id = "id1";
+  state1.uploaded_parts = 3;
+  state1.uploaded_size = 150_MiB;
+  state1.part_size = 50_MiB;
+  state1.full_size = 200_MiB;
+  state1.upload_time = Aws::Utils::DateTime::CurrentTimeMillis();
+  state1.uploaded_etags = {"etag1", "etag2", "etag3"};
+  upload_storage_.storeState("old_bucket", "key1", state1);

Review Comment:
   You are right, I updated the test with the overwrite, but also kept the 
different bucket and key id state to check if those are not overwritten in 
a63cb4a856a9ed576f994dc849c57a29a8044ae0



##########
extensions/aws/processors/PutS3Object.cpp:
##########
@@ -77,7 +78,31 @@ void PutS3Object::onSchedule(const 
std::shared_ptr<core::ProcessContext> &contex
     use_virtual_addressing_ = !*use_path_style_access;
   }
 
+  context->getProperty(MultipartThreshold.getName(), multipart_threshold_);
+  if (multipart_threshold_ > getMaxUploadSize() || multipart_threshold_ < 
getMinPartSize()) {
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Multipart Threshold is not 
between the valid 5MB and 5GB range!");
+  }
+  logger_->log_debug("PutS3Object: Multipart Threshold %" PRIu64, 
multipart_threshold_);
+  context->getProperty(MultipartPartSize.getName(), multipart_size_);
+  if (multipart_size_ > getMaxUploadSize() || multipart_size_ < 
getMinPartSize()) {
+    throw Exception(PROCESS_SCHEDULE_EXCEPTION, "Multipart Part Size is not 
between the valid 5MB and 5GB range!");
+  }
+  logger_->log_debug("PutS3Object: Multipart Size %" PRIu64, multipart_size_);
+
+
+  multipart_upload_ageoff_interval_ = 
minifi::utils::getRequiredPropertyOrThrow<core::TimePeriodValue>(*context, 
MultipartUploadAgeOffInterval.getName()).getMilliseconds();
+  logger_->log_debug("PutS3Object: Multipart Upload Ageoff Interval %" PRIu64 
" ms", multipart_upload_ageoff_interval_.count());
+
+  multipart_upload_max_age_threshold_ = 
minifi::utils::getRequiredPropertyOrThrow<core::TimePeriodValue>(*context, 
MultipartUploadMaxAgeThreshold.getName()).getMilliseconds();
+  logger_->log_debug("PutS3Object: Multipart Upload Max Age Threshold %" 
PRIu64 " ms", multipart_upload_max_age_threshold_.count());
+

Review Comment:
   Thanks, updated in a63cb4a856a9ed576f994dc849c57a29a8044ae0



##########
extensions/aws/processors/PutS3Object.h:
##########
@@ -81,7 +96,7 @@ class PutS3Object : public S3Processor {
   EXTENSIONAPI static constexpr bool SupportsDynamicProperties = true;
   EXTENSIONAPI static constexpr bool SupportsDynamicRelationships = false;
   EXTENSIONAPI static constexpr core::annotation::Input InputRequirement = 
core::annotation::Input::INPUT_REQUIRED;
-  EXTENSIONAPI static constexpr bool IsSingleThreaded = false;
+  EXTENSIONAPI static constexpr bool IsSingleThreaded = true;

Review Comment:
   Good catch, I forgot to revert this after discussing it, updated in 
a63cb4a856a9ed576f994dc849c57a29a8044ae0



-- 
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]

Reply via email to