torwig commented on PR #1342:
URL: 
https://github.com/apache/incubator-kvrocks/pull/1342#issuecomment-1480745024

   @PragmaTwice For testing new features I have the following tests, you can 
add them:
   
   ```
   TEST(Metadata, Metadata64bitExpiration) {
     auto expire_at = Util::GetTimeStampMS() + 1000;
     Metadata md_src(kRedisString, true, true);
     EXPECT_TRUE(md_src.Is64BitEncoded());
     md_src.expire = expire_at;
     std::string encoded_bytes;
     md_src.Encode(&encoded_bytes);
   
     Metadata md_decoded(kRedisNone, false, true);
     md_decoded.Decode(encoded_bytes);
     EXPECT_TRUE(md_decoded.Is64BitEncoded());
     EXPECT_EQ(md_decoded.Type(), kRedisString);
     EXPECT_EQ(md_decoded.expire, expire_at);
   }
   
   TEST(Metadata, Metadata64bitSize) {
     uint64_t big_size = 100000000000;
     Metadata md_src(kRedisHash, true, true);
     EXPECT_TRUE(md_src.Is64BitEncoded());
     md_src.size = big_size;
     std::string encoded_bytes;
     md_src.Encode(&encoded_bytes);
   
     Metadata md_decoded(kRedisNone, false, true);
     md_decoded.Decode(encoded_bytes);
     EXPECT_TRUE(md_decoded.Is64BitEncoded());
     EXPECT_EQ(md_decoded.Type(), kRedisHash);
     EXPECT_EQ(md_decoded.size, big_size);
   }
   ```
   
   To test backward compatibility, I have the following two ones, but they are 
failing:
   
   ```
   TEST(Metadata, MetadataDecodingBackwardCompatibleSimpleKey) {
     auto expire_at = Util::GetTimeStamp() + 10; // <-- assign seconds here
     Metadata md_old(kRedisString, true, false);
     EXPECT_FALSE(md_old.Is64BitEncoded());
     md_old.expire = expire_at;
     std::string encoded_bytes;
     md_old.Encode(&encoded_bytes);
   
     Metadata md_new(kRedisNone, false, true);
     md_new.Decode(encoded_bytes);
     EXPECT_FALSE(md_new.Is64BitEncoded());
     EXPECT_EQ(md_new.Type(), kRedisString);
     EXPECT_EQ(md_new.expire, expire_at*1000);
   }
   
   TEST(Metadata, MetadataDecodingBackwardCompatibleComplexKey) {
     auto expire_at = Util::GetTimeStamp() + 100; // <-- assign seconds here
     uint32_t size = 1000000000;
     Metadata md_old(kRedisHash, true, false);
     EXPECT_FALSE(md_old.Is64BitEncoded());
     md_old.expire = expire_at;
     md_old.size = size;
     std::string encoded_bytes;
     md_old.Encode(&encoded_bytes);
   
     Metadata md_new(kRedisHash, false, true);
     md_new.Decode(encoded_bytes);
     EXPECT_FALSE(md_new.Is64BitEncoded());
     EXPECT_EQ(md_new.Type(), kRedisHash);
     EXPECT_EQ(md_new.expire, expire_at*1000);
     EXPECT_EQ(md_new.size, size);
   }
   ```
   
   But fixing them by assigning milliseconds instead of seconds won't work 
because in this case, they would not test backward compatibility anymore. So 
these two tests can be discarded.
   


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