@@ -154,16 +154,26 @@ private void runValidatePolicyNameTest(Function<Admin, TableDescriptor> descript
154154
155155 @ Test
156156 public void testCreateTableErasureCodingSync () throws IOException {
157- try (Admin admin = UTIL .getAdmin (); Table table = UTIL .getConnection ().getTable (EC_TABLE )) {
158- admin .createTable (EC_TABLE_DESC );
159- UTIL .loadTable (table , FAMILY );
157+ try (Admin admin = UTIL .getAdmin ()) {
158+ recreateTable (admin , EC_TABLE_DESC );
160159 UTIL .flush (EC_TABLE );
161160 Path rootDir = CommonFSUtils .getRootDir (UTIL .getConfiguration ());
162161 DistributedFileSystem dfs = (DistributedFileSystem ) FileSystem .get (UTIL .getConfiguration ());
163162 checkRegionDirAndFilePolicies (dfs , rootDir , EC_TABLE , "XOR-2-1-1024k" , "XOR-2-1-1024k" );
164163 }
165164 }
166165
166+ private void recreateTable (Admin admin , TableDescriptor desc ) throws IOException {
167+ if (admin .tableExists (desc .getTableName ())) {
168+ admin .disableTable (desc .getTableName ());
169+ admin .deleteTable (desc .getTableName ());
170+ }
171+ admin .createTable (desc );
172+ try (Table table = UTIL .getConnection ().getTable (desc .getTableName ())) {
173+ UTIL .loadTable (table , FAMILY );
174+ }
175+ }
176+
167177 @ Test
168178 public void testModifyTableErasureCodingSync () throws IOException , InterruptedException {
169179 try (Admin admin = UTIL .getAdmin ()) {
@@ -230,14 +240,7 @@ public void testRestoreSnapshot() throws IOException {
230240 DistributedFileSystem dfs = (DistributedFileSystem ) FileSystem .get (UTIL .getConfiguration ());
231241
232242 // recreate EC test table and load it
233- if (admin .tableExists (EC_TABLE )) {
234- admin .disableTable (EC_TABLE );
235- admin .deleteTable (EC_TABLE );
236- }
237- admin .createTable (EC_TABLE_DESC );
238- try (Table table = UTIL .getConnection ().getTable (EC_TABLE )) {
239- UTIL .loadTable (table , FAMILY );
240- }
243+ recreateTable (admin , EC_TABLE_DESC );
241244
242245 // Take a snapshot, then clone it into a new table
243246 admin .snapshot (snapshotName , EC_TABLE );
0 commit comments