Browse code

Chore: fix invalid cache registration in plugin.xml

Thomas Cataldo authored on 03/08/2019 09:01:12 • David Phan committed on 05/08/2019 08:49:03
Showing 7 changed files
... ...
@@ -36,6 +36,7 @@ import com.google.common.collect.Lists;
36 36
 
37 37
 import net.bluemind.backend.cyrus.CyrusService;
38 38
 import net.bluemind.backend.cyrus.replication.testhelper.CyrusReplicationHelper;
39
+import net.bluemind.backend.cyrus.replication.testhelper.SyncServerHelper;
39 40
 import net.bluemind.cli.inject.imap.ImapInjector;
40 41
 import net.bluemind.core.container.model.ItemValue;
41 42
 import net.bluemind.core.context.SecurityContext;
... ...
@@ -108,6 +109,8 @@ public class ImapInjectorTests {
108 109
 
109 110
 		MQ.init().get(30, TimeUnit.SECONDS);
110 111
 
112
+		SyncServerHelper.waitFor();
113
+
111 114
 		cyrusReplication.startReplication().get(5, TimeUnit.SECONDS);
112 115
 
113 116
 		for (int i = 0; i < 10; i++) {
... ...
@@ -30,6 +30,7 @@ import com.google.common.collect.Lists;
30 30
 
31 31
 import net.bluemind.backend.cyrus.CyrusService;
32 32
 import net.bluemind.backend.cyrus.replication.testhelper.CyrusReplicationHelper;
33
+import net.bluemind.backend.cyrus.replication.testhelper.SyncServerHelper;
33 34
 import net.bluemind.backend.mail.replica.indexing.RecordIndexActivator;
34 35
 import net.bluemind.core.container.model.ItemValue;
35 36
 import net.bluemind.core.elasticsearch.ElasticsearchTestHelper;
... ...
@@ -171,7 +172,10 @@ public class CliTestHelper {
171 172
 			System.err.println("Reloading index support...");
172 173
 			RecordIndexActivator.reload();
173 174
 			System.err.println("Starting replication if needed...");
174
-			return replication.map(helper -> helper.startReplication()).orElse(CompletableFuture.completedFuture(null));
175
+			return replication.map(helper -> {
176
+				SyncServerHelper.waitFor();
177
+				return helper.startReplication();
178
+			}).orElse(CompletableFuture.completedFuture(null));
175 179
 		}).thenApply(replicationStarted -> {
176 180
 			for (String domUid : domains) {
177 181
 				for (int i = 0; i < toProvision.userCount; i++) {
... ...
@@ -194,7 +198,7 @@ public class CliTestHelper {
194 198
 	public void afterTest() throws Exception {
195 199
 		outAndErr.reset();
196 200
 	}
197
-	
201
+
198 202
 	public void afterClassTest() throws Exception {
199 203
 		System.setOut(origOut);
200 204
 		System.setErr(origErr);
... ...
@@ -16,7 +16,9 @@ Require-Bundle: org.eclipse.core.runtime,
16 16
  net.bluemind.core.container.api;bundle-version="4.1.0",
17 17
  net.bluemind.server.api,
18 18
  net.bluemind.backend.cyrus.replication.observers;bundle-version="4.1.0",
19
- net.bluemind.backend.cyrus.replication.server;bundle-version="4.1.0"
19
+ net.bluemind.backend.cyrus.replication.server;bundle-version="4.1.0",
20
+ net.bluemind.system.stateobserver.testhelper,
21
+ net.bluemind.network.utils
20 22
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
21 23
 Bundle-ActivationPolicy: lazy
22 24
 Export-Package: net.bluemind.backend.cyrus.replication.testhelper
23 25
new file mode 100644
... ...
@@ -0,0 +1,36 @@
1
+/* BEGIN LICENSE
2
+ * Copyright © Blue Mind SAS, 2012-2018
3
+ *
4
+ * This file is part of BlueMind. BlueMind is a messaging and collaborative
5
+ * solution.
6
+ *
7
+ * This program is free software; you can redistribute it and/or modify
8
+ * it under the terms of either the GNU Affero General Public License as
9
+ * published by the Free Software Foundation (version 3 of the License).
10
+ *
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
+ *
16
+ * See LICENSE.txt
17
+ * END LICENSE
18
+ */
19
+package net.bluemind.backend.cyrus.replication.testhelper;
20
+
21
+import java.util.concurrent.TimeUnit;
22
+
23
+import net.bluemind.network.utils.NetworkHelper;
24
+import net.bluemind.system.stateobserver.testhelper.StateTestHelper;
25
+
26
+public class SyncServerHelper {
27
+
28
+	private SyncServerHelper() {
29
+	}
30
+
31
+	public static void waitFor() {
32
+		StateTestHelper.blockUntilRunning();
33
+		new NetworkHelper("127.0.0.1").waitForListeningPort(2501, 10, TimeUnit.SECONDS);
34
+	}
35
+
36
+}
... ...
@@ -33,6 +33,7 @@ import com.google.common.collect.Lists;
33 33
 
34 34
 import net.bluemind.backend.cyrus.CyrusService;
35 35
 import net.bluemind.backend.cyrus.replication.testhelper.CyrusReplicationHelper;
36
+import net.bluemind.backend.cyrus.replication.testhelper.SyncServerHelper;
36 37
 import net.bluemind.core.container.model.ItemValue;
37 38
 import net.bluemind.core.elasticsearch.ElasticsearchTestHelper;
38 39
 import net.bluemind.core.jdbc.JdbcActivator;
39 40
deleted file mode 100644
... ...
@@ -1,70 +0,0 @@
1
-/* BEGIN LICENSE
2
- * Copyright © Blue Mind SAS, 2012-2018
3
- *
4
- * This file is part of BlueMind. BlueMind is a messaging and collaborative
5
- * solution.
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of either the GNU Affero General Public License as
9
- * published by the Free Software Foundation (version 3 of the License).
10
- *
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
- *
16
- * See LICENSE.txt
17
- * END LICENSE
18
- */
19
-package net.bluemind.backend.mail.replica.service.tests;
20
-
21
-import java.util.concurrent.CountDownLatch;
22
-import java.util.concurrent.TimeUnit;
23
-import java.util.concurrent.atomic.AtomicBoolean;
24
-
25
-import org.vertx.java.core.json.JsonObject;
26
-
27
-import net.bluemind.backend.cyrus.replication.client.SyncClient;
28
-import net.bluemind.lib.vertx.VertxPlatform;
29
-import net.bluemind.system.api.SystemState;
30
-
31
-public class SyncServerHelper {
32
-
33
-	public static void waitFor() throws InterruptedException {
34
-
35
-		VertxPlatform.eventBus().publish(SystemState.BROADCAST,
36
-				new JsonObject().putString("operation", SystemState.CORE_STATE_RUNNING.operation()));
37
-
38
-		CountDownLatch latch = new CountDownLatch(1);
39
-		check(latch);
40
-		latch.await();
41
-	}
42
-
43
-	private static void check(CountDownLatch latch) throws InterruptedException {
44
-		AtomicBoolean connected = new AtomicBoolean();
45
-		for (int i = 0; i < 5; i++) {
46
-			if (connected.get()) {
47
-				break;
48
-			}
49
-			SyncClient sc = new SyncClient("127.0.0.1", 2501);
50
-			try {
51
-				sc.connect().thenCompose(v -> {
52
-					latch.countDown();
53
-					connected.set(true);
54
-					return sc.disconnect();
55
-				}).exceptionally(e -> {
56
-					// not connected
57
-					return null;
58
-				}).get(2, TimeUnit.SECONDS);
59
-			} catch (Exception e) {
60
-			}
61
-			if (!connected.get()) {
62
-				Thread.sleep(1000);
63
-			} else {
64
-				return;
65
-			}
66
-		}
67
-
68
-	}
69
-
70
-}
... ...
@@ -183,7 +183,7 @@
183 183
             impl="net.bluemind.backend.mail.replica.service.internal.CacheRegistration">
184 184
       </reg>
185 185
       <reg
186
-            impl="net.bluemind.backend.mail.replica.service.CacheRegistration2">
186
+            impl="net.bluemind.backend.mail.replica.service.internal.hooks.DeletedDataMementos$Registration">
187 187
       </reg>
188 188
    </extension>
189 189