23
23
import static org .apache .hadoop .hdds .scm .ScmConfigKeys .OZONE_SCM_DEADNODE_INTERVAL ;
24
24
import static org .apache .hadoop .hdds .scm .ScmConfigKeys .OZONE_SCM_STALENODE_INTERVAL ;
25
25
import static org .apache .hadoop .ozone .container .TestHelper .waitForContainerClose ;
26
+ import static org .apache .hadoop .ozone .container .TestHelper .waitForContainerStateInSCM ;
26
27
import static org .assertj .core .api .Assertions .assertThat ;
27
28
import static org .junit .jupiter .api .Assertions .assertEquals ;
28
29
import static org .junit .jupiter .api .Assertions .assertNotNull ;
29
30
import static org .junit .jupiter .api .Assertions .assertTrue ;
30
- import static org .junit .jupiter .api .Assertions .fail ;
31
31
32
32
import java .io .IOException ;
33
33
import java .io .OutputStream ;
34
34
import java .nio .file .Path ;
35
35
import java .nio .file .Paths ;
36
36
import java .util .List ;
37
37
import java .util .concurrent .TimeUnit ;
38
+ import java .util .concurrent .TimeoutException ;
38
39
import org .apache .hadoop .fs .FileUtil ;
39
40
import org .apache .hadoop .hdds .client .RatisReplicationConfig ;
40
41
import org .apache .hadoop .hdds .conf .OzoneConfiguration ;
41
42
import org .apache .hadoop .hdds .protocol .proto .HddsProtos ;
42
43
import org .apache .hadoop .hdds .scm .container .ContainerID ;
43
44
import org .apache .hadoop .hdds .scm .container .ContainerManager ;
44
- import org .apache .hadoop .hdds .scm .container . ContainerNotFoundException ;
45
+ import org .apache .hadoop .hdds .scm .server . StorageContainerManager ;
45
46
import org .apache .hadoop .ozone .HddsDatanodeService ;
46
47
import org .apache .hadoop .ozone .MiniOzoneCluster ;
47
48
import org .apache .hadoop .ozone .MiniOzoneHAClusterImpl ;
53
54
import org .apache .hadoop .ozone .om .helpers .OmKeyInfo ;
54
55
import org .apache .hadoop .ozone .om .helpers .OmKeyLocationInfo ;
55
56
import org .apache .hadoop .ozone .om .helpers .OmKeyLocationInfoGroup ;
56
- import org .apache .ozone .test .GenericTestUtils ;
57
- import org .apache .ozone .test .tag .Flaky ;
58
57
import org .junit .jupiter .params .ParameterizedTest ;
59
58
import org .junit .jupiter .params .provider .EnumSource ;
60
59
61
60
/**
62
61
* Tests for container report handling with SCM High Availability.
63
62
*/
64
- @ Flaky ("HDDS-12535" )
65
63
public class TestContainerReportHandlingWithHA {
66
64
private static final String VOLUME = "vol1" ;
67
65
private static final String BUCKET = "bucket1" ;
@@ -99,6 +97,8 @@ void testDeletingOrDeletedContainerTransitionsToClosedWhenNonEmptyReplicaIsRepor
99
97
ContainerID containerID = ContainerID .valueOf (keyLocation .getContainerID ());
100
98
waitForContainerClose (cluster , containerID .getId ());
101
99
100
+ waitForContainerStateInAllSCMs (cluster , containerID , HddsProtos .LifeCycleState .CLOSED );
101
+
102
102
// move the container to DELETING
103
103
ContainerManager containerManager = cluster .getScmLeader ().getContainerManager ();
104
104
containerManager .updateContainerState (containerID , HddsProtos .LifeCycleEvent .DELETE );
@@ -113,23 +113,8 @@ void testDeletingOrDeletedContainerTransitionsToClosedWhenNonEmptyReplicaIsRepor
113
113
// restart a DN and wait for the container to get CLOSED in all SCMs
114
114
HddsDatanodeService dn = cluster .getHddsDatanode (keyLocation .getPipeline ().getFirstNode ());
115
115
cluster .restartHddsDatanode (dn .getDatanodeDetails (), false );
116
- ContainerManager [] array = new ContainerManager [numSCM ];
117
- for (int i = 0 ; i < numSCM ; i ++) {
118
- array [i ] = cluster .getStorageContainerManager (i ).getContainerManager ();
119
- }
120
- GenericTestUtils .waitFor (() -> {
121
- try {
122
- for (ContainerManager manager : array ) {
123
- if (manager .getContainer (containerID ).getState () != HddsProtos .LifeCycleState .CLOSED ) {
124
- return false ;
125
- }
126
- }
127
- return true ;
128
- } catch (ContainerNotFoundException e ) {
129
- fail (e );
130
- }
131
- return false ;
132
- }, 2000 , 20000 );
116
+
117
+ waitForContainerStateInAllSCMs (cluster , containerID , HddsProtos .LifeCycleState .CLOSED );
133
118
134
119
assertEquals (HddsProtos .LifeCycleState .CLOSED , containerManager .getContainer (containerID ).getState ());
135
120
}
@@ -177,4 +162,12 @@ private void createTestData(OzoneClient client) throws IOException {
177
162
}
178
163
}
179
164
165
+ private static void waitForContainerStateInAllSCMs (MiniOzoneHAClusterImpl cluster , ContainerID containerID ,
166
+ HddsProtos .LifeCycleState desiredState )
167
+ throws TimeoutException , InterruptedException {
168
+ for (StorageContainerManager scm : cluster .getStorageContainerManagersList ()) {
169
+ waitForContainerStateInSCM (scm , containerID , desiredState );
170
+ }
171
+ }
172
+
180
173
}
0 commit comments