34
34
import static org .junit .jupiter .api .Assertions .assertTrue ;
35
35
36
36
import java .io .File ;
37
- import java .util .UUID ;
38
37
39
38
import org .apache .accumulo .core .Constants ;
40
- import org .apache .accumulo .core .data .InstanceId ;
41
39
import org .apache .accumulo .core .fate .zookeeper .ZooUtil ;
42
40
import org .apache .accumulo .core .fate .zookeeper .ZooUtil .NodeMissingPolicy ;
43
41
import org .apache .accumulo .core .volume .Volume ;
@@ -69,8 +67,6 @@ public class UpgradeProgressTrackerIT {
69
67
@ TempDir
70
68
private static File tempDir ;
71
69
72
- private static final String zRoot = ZooUtil .getRoot (InstanceId .of (UUID .randomUUID ()));
73
-
74
70
private static ZooKeeperTestingServer testZk = null ;
75
71
private static ZooSession zk = null ;
76
72
private static Volume volume ;
@@ -81,7 +77,6 @@ public class UpgradeProgressTrackerIT {
81
77
public static void setup () throws Exception {
82
78
testZk = new ZooKeeperTestingServer (tempDir );
83
79
zk = testZk .newClient ();
84
- zk .asReaderWriter ().mkdirs (zRoot );
85
80
volume = new VolumeImpl (new Path (tempDir .toURI ()), new Configuration ());
86
81
}
87
82
@@ -103,7 +98,6 @@ public void beforeTest() {
103
98
ctx = createMock (ServerContext .class );
104
99
sd = createMock (ServerDirs .class );
105
100
vm = createMock (VolumeManagerImpl .class );
106
- expect (ctx .getZooKeeperRoot ()).andReturn (zRoot ).anyTimes ();
107
101
expect (ctx .getZooSession ()).andReturn (zk ).anyTimes ();
108
102
expect (ctx .getServerDirs ()).andReturn (sd ).anyTimes ();
109
103
expect (ctx .getVolumeManager ()).andReturn (vm ).anyTimes ();
@@ -116,8 +110,7 @@ public void beforeTest() {
116
110
@ AfterEach
117
111
public void afterTest () throws KeeperException , InterruptedException {
118
112
verify (ctx , sd , vm );
119
- zk .asReaderWriter ().recursiveDelete (zRoot + Constants .ZUPGRADE_PROGRESS ,
120
- NodeMissingPolicy .SKIP );
113
+ zk .asReaderWriter ().recursiveDelete (Constants .ZUPGRADE_PROGRESS , NodeMissingPolicy .SKIP );
121
114
}
122
115
123
116
private void expectVersion (int version ) {
@@ -127,7 +120,7 @@ private void expectVersion(int version) {
127
120
}
128
121
129
122
private boolean upgradeNodeExists () throws KeeperException , InterruptedException {
130
- return zk .exists (zRoot + Constants .ZUPGRADE_PROGRESS , null ) != null ;
123
+ return zk .exists (Constants .ZUPGRADE_PROGRESS , null ) != null ;
131
124
}
132
125
133
126
@ Test
@@ -136,7 +129,7 @@ public void testUpgradeAlreadyStarted() throws KeeperException, InterruptedExcep
136
129
assertFalse (upgradeNodeExists ());
137
130
var progress =
138
131
new UpgradeProgress (AccumuloDataVersion .get () - 2 , AccumuloDataVersion .get () - 1 );
139
- zk .create (zRoot + Constants .ZUPGRADE_PROGRESS , GSON .get ().toJson (progress ).getBytes (UTF_8 ),
132
+ zk .create (Constants .ZUPGRADE_PROGRESS , GSON .get ().toJson (progress ).getBytes (UTF_8 ),
140
133
ZooUtil .PUBLIC , CreateMode .PERSISTENT );
141
134
assertTrue (upgradeNodeExists ());
142
135
var ise =
@@ -161,7 +154,7 @@ public void testGetInitial() throws KeeperException, InterruptedException {
161
154
assertEquals (AccumuloDataVersion .get (), progress .getZooKeeperVersion ());
162
155
assertEquals (AccumuloDataVersion .get (), progress .getRootVersion ());
163
156
assertEquals (AccumuloDataVersion .get (), progress .getMetadataVersion ());
164
- byte [] serialized = zk .asReader ().getData (zRoot + Constants .ZUPGRADE_PROGRESS );
157
+ byte [] serialized = zk .asReader ().getData (Constants .ZUPGRADE_PROGRESS );
165
158
assertArrayEquals (GSON .get ().toJson (progress ).getBytes (UTF_8 ), serialized );
166
159
}
167
160
@@ -176,15 +169,15 @@ public void testUpdates() throws KeeperException, InterruptedException {
176
169
assertEquals (AccumuloDataVersion .get () - 1 , progress .getZooKeeperVersion ());
177
170
assertEquals (AccumuloDataVersion .get () - 1 , progress .getRootVersion ());
178
171
assertEquals (AccumuloDataVersion .get () - 1 , progress .getMetadataVersion ());
179
- byte [] serialized = zk .asReader ().getData (zRoot + Constants .ZUPGRADE_PROGRESS );
172
+ byte [] serialized = zk .asReader ().getData (Constants .ZUPGRADE_PROGRESS );
180
173
assertArrayEquals (GSON .get ().toJson (progress ).getBytes (UTF_8 ), serialized );
181
174
182
175
// Test updating out of order
183
176
assertThrows (IllegalArgumentException .class ,
184
177
() -> progressTracker .updateMetadataVersion (AccumuloDataVersion .get ()));
185
178
assertThrows (IllegalArgumentException .class ,
186
179
() -> progressTracker .updateRootVersion (AccumuloDataVersion .get ()));
187
- serialized = zk .asReader ().getData (zRoot + Constants .ZUPGRADE_PROGRESS );
180
+ serialized = zk .asReader ().getData (Constants .ZUPGRADE_PROGRESS );
188
181
assertArrayEquals (GSON .get ().toJson (progress ).getBytes (UTF_8 ), serialized );
189
182
190
183
progressTracker .updateZooKeeperVersion (AccumuloDataVersion .get ());
@@ -195,7 +188,7 @@ public void testUpdates() throws KeeperException, InterruptedException {
195
188
assertEquals (AccumuloDataVersion .get (), progress2 .getZooKeeperVersion ());
196
189
assertEquals (AccumuloDataVersion .get () - 1 , progress2 .getRootVersion ());
197
190
assertEquals (AccumuloDataVersion .get () - 1 , progress2 .getMetadataVersion ());
198
- serialized = zk .asReader ().getData (zRoot + Constants .ZUPGRADE_PROGRESS );
191
+ serialized = zk .asReader ().getData (Constants .ZUPGRADE_PROGRESS );
199
192
assertArrayEquals (GSON .get ().toJson (progress2 ).getBytes (UTF_8 ), serialized );
200
193
201
194
progressTracker .updateRootVersion (AccumuloDataVersion .get ());
@@ -206,7 +199,7 @@ public void testUpdates() throws KeeperException, InterruptedException {
206
199
assertEquals (AccumuloDataVersion .get (), progress2 .getZooKeeperVersion ());
207
200
assertEquals (AccumuloDataVersion .get (), progress2 .getRootVersion ());
208
201
assertEquals (AccumuloDataVersion .get () - 1 , progress2 .getMetadataVersion ());
209
- serialized = zk .asReader ().getData (zRoot + Constants .ZUPGRADE_PROGRESS );
202
+ serialized = zk .asReader ().getData (Constants .ZUPGRADE_PROGRESS );
210
203
assertArrayEquals (GSON .get ().toJson (progress2 ).getBytes (UTF_8 ), serialized );
211
204
212
205
progressTracker .updateMetadataVersion (AccumuloDataVersion .get ());
@@ -217,7 +210,7 @@ public void testUpdates() throws KeeperException, InterruptedException {
217
210
assertEquals (AccumuloDataVersion .get (), progress2 .getZooKeeperVersion ());
218
211
assertEquals (AccumuloDataVersion .get (), progress2 .getRootVersion ());
219
212
assertEquals (AccumuloDataVersion .get (), progress2 .getMetadataVersion ());
220
- serialized = zk .asReader ().getData (zRoot + Constants .ZUPGRADE_PROGRESS );
213
+ serialized = zk .asReader ().getData (Constants .ZUPGRADE_PROGRESS );
221
214
assertArrayEquals (GSON .get ().toJson (progress2 ).getBytes (UTF_8 ), serialized );
222
215
}
223
216
@@ -232,11 +225,11 @@ public void testCompleteUpgrade() throws KeeperException, InterruptedException {
232
225
assertEquals (AccumuloDataVersion .get (), progress .getZooKeeperVersion ());
233
226
assertEquals (AccumuloDataVersion .get (), progress .getRootVersion ());
234
227
assertEquals (AccumuloDataVersion .get (), progress .getMetadataVersion ());
235
- byte [] serialized = zk .asReader ().getData (zRoot + Constants .ZUPGRADE_PROGRESS );
228
+ byte [] serialized = zk .asReader ().getData (Constants .ZUPGRADE_PROGRESS );
236
229
assertArrayEquals (GSON .get ().toJson (progress ).getBytes (UTF_8 ), serialized );
237
230
238
231
progressTracker .upgradeComplete ();
239
- assertFalse (zk .asReader ().exists (zRoot + Constants .ZUPGRADE_PROGRESS ));
232
+ assertFalse (zk .asReader ().exists (Constants .ZUPGRADE_PROGRESS ));
240
233
assertFalse (upgradeNodeExists ());
241
234
}
242
235
0 commit comments