@@ -132,3 +132,51 @@ TEST_P(RegressionTest, MB_26828_SetIsFixed) {
132132 conn.executeCommand (cmd, resp);
133133 EXPECT_TRUE (resp.isSuccess ());
134134}
135+
136+ /* *
137+ * https://issues.couchbase.com/browse/MB-31070
138+ *
139+ * Expiry time becomes 0 after append.
140+ *
141+ * This test validates that it is fixed by:
142+ * 1. Store a document with 30 seconds expiry time
143+ * 2. Fetch the expiry time of the document (absolute time)
144+ * 3. Performs an append
145+ * 4. Fetch the expiry time of the document and verifies that it is unchanged
146+ */
147+ TEST_P (RegressionTest, MB_31070) {
148+ auto & conn = getConnection ();
149+
150+ Document document;
151+ document.info .cas = mcbp::cas::Wildcard;
152+ document.info .flags = 0xcaffee ;
153+ document.info .id = name;
154+ document.info .expiration = 30 ;
155+ document.value = " hello" ;
156+
157+ conn.mutate (document, 0 , MutationType::Set);
158+
159+ BinprotSubdocMultiLookupCommand cmd;
160+ cmd.setKey (name);
161+ cmd.addGet (" $document.exptime" , SUBDOC_FLAG_XATTR_PATH);
162+
163+ BinprotSubdocMultiLookupResponse multiResp;
164+ conn.executeCommand (cmd, multiResp);
165+
166+ auto & results = multiResp.getResults ();
167+
168+ EXPECT_EQ (PROTOCOL_BINARY_RESPONSE_SUCCESS, multiResp.getStatus ());
169+ EXPECT_EQ (PROTOCOL_BINARY_RESPONSE_SUCCESS, results[0 ].status );
170+ const auto exptime = std::stol (results[0 ].value );
171+ EXPECT_LT (0 , exptime);
172+
173+ document.value = " world" ;
174+ document.info .expiration = 0 ;
175+ conn.mutate (document, 0 , MutationType::Append);
176+
177+ conn.executeCommand (cmd, multiResp);
178+
179+ EXPECT_EQ (PROTOCOL_BINARY_RESPONSE_SUCCESS, multiResp.getStatus ());
180+ EXPECT_EQ (PROTOCOL_BINARY_RESPONSE_SUCCESS, results[0 ].status );
181+ EXPECT_EQ (exptime, std::stol (results[0 ].value ));
182+ }
0 commit comments