Program: 7236
Project: 7236
Buggy source:
@Test public void testUpgrade() throws Exception {
  String dummyPath=tmpFolder.newFolder().getAbsolutePath();
  createStream("String_Node_Str");
  Id.DatasetInstance kvID=Id.DatasetInstance.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str");
  datasetFramework.addInstance(KeyValueTable.class.getName(),kvID,DatasetProperties.EMPTY);
  Id.DatasetInstance filesetID=Id.DatasetInstance.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str");
  Schema schema=Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.STRING)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.LONG)));
  datasetFramework.addInstance(TimePartitionedFileSet.class.getName(),filesetID,FileSetProperties.builder().setBasePath("String_Node_Str").setEnableExploreOnCreate(true).setSerDe("String_Node_Str").setExploreInputFormat("String_Node_Str").setExploreOutputFormat("String_Node_Str").setTableProperty("String_Node_Str",schema.toString()).build());
  TimePartitionedFileSet tpfs=datasetFramework.getDataset(filesetID,Collections.<String,String>emptyMap(),null);
  Transaction tx1=transactionManager.startShort(100);
  TransactionAware txTpfs=(TransactionAware)tpfs;
  txTpfs.startTx(tx1);
  tpfs.addPartition(0L,"String_Node_Str");
  tpfs.addPartition(86400000L,"String_Node_Str");
  Map<PartitionKey,String> partitions=tpfs.getPartitions(null);
  txTpfs.commitTx();
  transactionManager.canCommit(tx1,txTpfs.getTxChanges());
  transactionManager.commit(tx1);
  txTpfs.postTxCommit();
  waitForCompletion(Lists.newArrayList(exploreTableService.disableStream(Id.Stream.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str")),exploreTableService.disableDataset(kvID,datasetFramework.getDatasetSpec(kvID)),exploreTableService.disableDataset(filesetID,datasetFramework.getDatasetSpec(filesetID))));
  String createOldStream="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + dummyPath + "String_Node_Str";
  String createOldRecordScannable="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  String createOldFileset="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + dummyPath + "String_Node_Str"+ "String_Node_Str"+ schema.toString()+ "String_Node_Str";
  String createNonCDAP="String_Node_Str";
  waitForCompletion(Lists.newArrayList(((BaseHiveExploreService)exploreService).execute("String_Node_Str",createNonCDAP),((BaseHiveExploreService)exploreService).execute("String_Node_Str",createOldFileset),((BaseHiveExploreService)exploreService).execute("String_Node_Str",createOldRecordScannable),((BaseHiveExploreService)exploreService).execute("String_Node_Str",createOldStream)));
  exploreService.upgrade();
  TableInfo tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertTrue(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertTrue(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertTrue(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertFalse(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  Iterator<PartitionKey> partitionKeyIter=partitions.keySet().iterator();
  String expected1=stringify(partitionKeyIter.next());
  String expected2=stringify(partitionKeyIter.next());
  runCommand(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str",true,Lists.newArrayList(new ColumnDesc("String_Node_Str","String_Node_Str",1,"String_Node_Str")),Lists.newArrayList(new QueryResult(Lists.<Object>newArrayList(expected1)),new QueryResult(Lists.<Object>newArrayList(expected2))));
  Assert.assertEquals(4,exploreService.getTables("String_Node_Str").size());
}

Fixed version (ground truth):
@Test public void testUpgrade() throws Exception {
  String dummyPath=tmpFolder.newFolder().getAbsolutePath();
  createStream("String_Node_Str");
  Id.DatasetInstance kvID=Id.DatasetInstance.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str");
  datasetFramework.addInstance(KeyValueTable.class.getName(),kvID,DatasetProperties.EMPTY);
  Id.DatasetInstance filesetID=Id.DatasetInstance.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str");
  Schema schema=Schema.recordOf("String_Node_Str",Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.STRING)),Schema.Field.of("String_Node_Str",Schema.of(Schema.Type.LONG)));
  datasetFramework.addInstance(TimePartitionedFileSet.class.getName(),filesetID,FileSetProperties.builder().setBasePath("String_Node_Str").setEnableExploreOnCreate(true).setSerDe("String_Node_Str").setExploreInputFormat("String_Node_Str").setExploreOutputFormat("String_Node_Str").setTableProperty("String_Node_Str",schema.toString()).build());
  TimePartitionedFileSet tpfs=datasetFramework.getDataset(filesetID,Collections.<String,String>emptyMap(),null);
  Transaction tx1=transactionManager.startShort(100);
  TransactionAware txTpfs=(TransactionAware)tpfs;
  txTpfs.startTx(tx1);
  tpfs.addPartition(0L,"String_Node_Str");
  Map<PartitionKey,String> partitions=tpfs.getPartitions(null);
  txTpfs.commitTx();
  transactionManager.canCommit(tx1,txTpfs.getTxChanges());
  transactionManager.commit(tx1);
  txTpfs.postTxCommit();
  waitForCompletion(Lists.newArrayList(exploreTableService.disableStream(Id.Stream.from(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str")),exploreTableService.disableDataset(kvID,datasetFramework.getDatasetSpec(kvID)),exploreTableService.disableDataset(filesetID,datasetFramework.getDatasetSpec(filesetID))));
  String createOldStream="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + dummyPath + "String_Node_Str";
  String createOldRecordScannable="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str";
  String createOldFileset="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str" + dummyPath + "String_Node_Str"+ "String_Node_Str"+ schema.toString()+ "String_Node_Str";
  String createNonCDAP="String_Node_Str";
  waitForCompletion(Lists.newArrayList(((BaseHiveExploreService)exploreService).execute("String_Node_Str",createNonCDAP),((BaseHiveExploreService)exploreService).execute("String_Node_Str",createOldFileset),((BaseHiveExploreService)exploreService).execute("String_Node_Str",createOldRecordScannable),((BaseHiveExploreService)exploreService).execute("String_Node_Str",createOldStream)));
  exploreService.upgrade();
  TableInfo tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertTrue(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertTrue(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertTrue(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  tableInfo=exploreService.getTableInfo("String_Node_Str","String_Node_Str");
  Assert.assertFalse(tableInfo.getParameters().containsKey(Constants.Explore.CDAP_VERSION));
  Iterator<PartitionKey> partitionKeyIter=partitions.keySet().iterator();
  String expected=stringify(partitionKeyIter.next());
  runCommand(Constants.DEFAULT_NAMESPACE_ID,"String_Node_Str",true,Lists.newArrayList(new ColumnDesc("String_Node_Str","String_Node_Str",1,"String_Node_Str")),Lists.newArrayList(new QueryResult(Lists.<Object>newArrayList(expected))));
  Assert.assertEquals(4,exploreService.getTables("String_Node_Str").size());
}