SammyVimes commented on code in PR #1023:
URL: https://github.com/apache/ignite-3/pull/1023#discussion_r950146164
##########
modules/runner/src/test/java/org/apache/ignite/internal/configuration/storage/DistributedConfigurationStorageTest.java:
##########
@@ -74,6 +93,145 @@ void stop() throws Exception {
vaultManager.stop();
}
+ /**
+ * Dummy configuration.
+ */
+ @ConfigurationRoot(rootName = "someKey", type = DISTRIBUTED)
+ public static class DistributedTestConfigurationSchema {
+ @Value(hasDefault = true)
+ public final int foobar = 0;
+ }
+
+ /**
+ * Tests that distributed configuration storage correctly picks up latest
configuration MetaStorage revision
+ * during recovery process.
+ *
+ * @throws Exception If failed.
+ */
+ @Test
+ public void testMetaStorageRevisionDifferentFromConfigurationOnRestart()
throws Exception {
+ RootKey<DistributedTestConfiguration, DistributedTestView> rootKey =
DistributedTestConfiguration.KEY;
+
+ ConfigurationAsmGenerator cgen = new ConfigurationAsmGenerator();
+
+ MetaStorageMockWrapper wrapper = new MetaStorageMockWrapper();
+
+ int configurationChangesCount = 7;
+
+ try (var storage = new
DistributedConfigurationStorage(wrapper.metaStorageManager(), vaultManager)) {
+ var changer = new TestConfigurationChanger(cgen, List.of(rootKey),
Collections.emptyMap(),
+ storage, Collections.emptyList(), Collections.emptyList());
+
+ changer.start();
+
+ for (int i = 0; i < configurationChangesCount; i++) {
+ ConfigurationSource source = source(
+ rootKey,
+ (DistributedTestChange change) ->
change.changeFoobar(1)
+ );
+
+ CompletableFuture<Void> change = changer.change(source);
+
+ change.get();
+ }
+
+ changer.stop();
+ }
+
+ // Put a value to the configuration, so we start on non-empty vault.
+ vaultManager.put(MetaStorageMockWrapper.TEST_KEY, new byte[]{4, 1, 2,
3, 4}).get();
+
+ // This emulates a change in MetaStorage that is not related to the
configuration.
+ vaultManager.put(MetaStorageManager.APPLIED_REV,
ByteUtils.longToBytes(configurationChangesCount + 1)).get();
+
+ try (var storage = new
DistributedConfigurationStorage(wrapper.metaStorageManager(), vaultManager)) {
+ var changer = new TestConfigurationChanger(cgen, List.of(rootKey),
Collections.emptyMap(),
+ storage, Collections.emptyList(), Collections.emptyList());
+
+ changer.start();
+
+ CompletableFuture<Long> longCompletableFuture =
storage.lastRevision();
+
+ // Should return last configuration change, not last MetaStorage
change.
+ Long lastConfigurationChangeRevision = longCompletableFuture.get();
+
+ assertEquals(configurationChangesCount,
lastConfigurationChangeRevision);
+
+ changer.stop();
+ }
+ }
+
+ /**
+ * This class stores data for {@link MetaStorageManager}'s mock.
+ */
+ private static class MetaStorageMockWrapper {
+ private static final String DISTRIBUTED_PREFIX = "dst-cfg.";
+
+ /**
+ * This and previous field are copy-pasted intentionally, so in case
if something changes,
+ * this test should fail and be reviewed and re-wrote.
Review Comment:
whoops
--
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]