Fixed tests
This commit is contained in:
parent
32ac1fa872
commit
75c5f0e4f5
|
@ -37,20 +37,23 @@ public class ContextTest {
|
|||
public static final String DEVSEC;
|
||||
public static final String DEVVRE;
|
||||
|
||||
private static final String ROOT_PRE;
|
||||
private static final String VO_PREPROD;
|
||||
protected static final String PREPROD_VRE_GRSF_PRE;
|
||||
protected static final String ROOT_PRE;
|
||||
protected static final String VO_PREPROD;
|
||||
protected static final String PREPROD_GRSF_PRE;
|
||||
|
||||
private static final String ROOT_PROD;
|
||||
protected static final String ROOT_PROD;
|
||||
protected static final String FARM_VO;
|
||||
protected static final String PROD_VRE_GRSF_PRE;
|
||||
protected static final String PRODUCTION_GRSF;
|
||||
protected static final String PRODUCTION_GRSF_ADMIN;
|
||||
protected static final String PRODUCTION_GRSF_PRE;
|
||||
|
||||
protected static final Properties properties;
|
||||
|
||||
public static final String TYPE_PROPERTY_KEY = "type";
|
||||
public static final String USERNAME_PROPERTY_KEY = "username";
|
||||
public static final String PASSWORD_PROPERTY_KEY = "password";
|
||||
public static final String CLIENT_ID_PROPERTY_KEY = "clientId";
|
||||
public static final String CLIENT_ID_PROPERTY_KEY = "clientId";
|
||||
|
||||
|
||||
static {
|
||||
GCUBE = "/gcube";
|
||||
|
@ -61,15 +64,15 @@ public class ContextTest {
|
|||
|
||||
ROOT_PRE = "/pred4s";
|
||||
VO_PREPROD = ROOT_PRE + "/preprod";
|
||||
PREPROD_VRE_GRSF_PRE = VO_PREPROD + "/GRSF_Pre";
|
||||
PREPROD_GRSF_PRE = VO_PREPROD + "/GRSF_Pre";
|
||||
|
||||
ROOT_PROD = "/d4science.research-infrastructures.eu";
|
||||
FARM_VO = ROOT_PROD + "/FARM";
|
||||
PROD_VRE_GRSF_PRE = FARM_VO + "/GRSF_Pre";
|
||||
PRODUCTION_GRSF = FARM_VO + "/GRSF";
|
||||
PRODUCTION_GRSF_ADMIN = FARM_VO + "/GRSF_Admin";
|
||||
PRODUCTION_GRSF_PRE = FARM_VO + "/GRSF_Pre";
|
||||
|
||||
|
||||
DEFAULT_TEST_SCOPE = PROD_VRE_GRSF_PRE;
|
||||
// DEFAULT_TEST_SCOPE = VRE_GRSF_PRE;
|
||||
DEFAULT_TEST_SCOPE = PREPROD_GRSF_PRE;
|
||||
|
||||
properties = new Properties();
|
||||
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(CONFIG_INI_FILENAME);
|
||||
|
|
|
@ -180,7 +180,7 @@ public class RecordTest extends ContextTest {
|
|||
return record;
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void testFisheryRecords() throws Exception {
|
||||
List<String> types = new ArrayList<>();
|
||||
|
@ -220,7 +220,7 @@ public class RecordTest extends ContextTest {
|
|||
testRecords(types, restart, restartFromSource, restartFromFile, maxTestRecords, maxTestRecordsPerSource);
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void testTraceabilityUnitRecords() throws Exception {
|
||||
List<String> types = new ArrayList<>();
|
||||
|
@ -237,16 +237,16 @@ public class RecordTest extends ContextTest {
|
|||
testRecords(types, restart, restartFromSource, restartFromFile, maxTestRecords, maxTestRecordsPerSource);
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void testAll() throws Exception {
|
||||
ContextTest.setContextByName(PREPROD_VRE_GRSF_PRE);
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
List<String> types = new ArrayList<>();
|
||||
types.add(FISHERY);
|
||||
types.add(STOCK);
|
||||
types.add(TRACEABILITY_UNIT);
|
||||
int maxTestRecords = Integer.MAX_VALUE;
|
||||
// maxTestRecords = 1;
|
||||
maxTestRecords = 1;
|
||||
int maxTestRecordsPerSource = Integer.MAX_VALUE;
|
||||
maxTestRecordsPerSource = 25;
|
||||
boolean restart = false;
|
||||
|
@ -476,10 +476,31 @@ public class RecordTest extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void removeSpecificRecord() throws Exception {
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
MultivaluedMap<String, String> mvm = new MultivaluedHashMap<String,String>();
|
||||
@SuppressWarnings("unused")
|
||||
UriInfo uriInfo = getUriInfo(mvm);
|
||||
// Record record = getRecordByType(STOCK);
|
||||
// record.setUriInfo(uriInfo);
|
||||
// record.setName("");
|
||||
// record.purge();
|
||||
// Record record = getRecordByType(FISHERY);
|
||||
// record.setUriInfo(uriInfo);
|
||||
// record.setName("");
|
||||
// record.purge();
|
||||
// Record record = getRecordByType(TRACEABILITY_UNIT);
|
||||
// record.setUriInfo(uriInfo);
|
||||
// record.setName("");
|
||||
// record.purge();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testDeleteAll() throws Exception {
|
||||
// ContextTest.setContextByName(DEVVRE);
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
|
||||
MultivaluedMap<String, String> mvm = new MultivaluedHashMap<String,String>();
|
||||
UriInfo uriInfo = getUriInfo(mvm);
|
||||
|
@ -490,7 +511,8 @@ public class RecordTest extends ContextTest {
|
|||
|
||||
String[] types = new String[] { FISHERY, STOCK, TRACEABILITY_UNIT };
|
||||
|
||||
long sleepTime = TimeUnit.MILLISECONDS.toMillis(200);
|
||||
long sleepTimeBetweenRecords = TimeUnit.MILLISECONDS.toMillis(200);
|
||||
long sleepTimeBetweenRecordPoll = TimeUnit.MILLISECONDS.toMillis(500);
|
||||
|
||||
for (String type : types) {
|
||||
boolean go = true;
|
||||
|
@ -513,11 +535,13 @@ public class RecordTest extends ContextTest {
|
|||
record.setName(name);
|
||||
|
||||
logger.info("Going to delete {} with GRSF UUID {}", record.getType(), name);
|
||||
record.purge();
|
||||
// record.purge();
|
||||
|
||||
logger.trace("Going to sleep for {} millis", sleepTime);
|
||||
Thread.sleep(sleepTime);
|
||||
logger.trace("Going to sleep for {} millis", sleepTimeBetweenRecords);
|
||||
Thread.sleep(sleepTimeBetweenRecords);
|
||||
}
|
||||
logger.trace("Going to sleep for {} millis", sleepTimeBetweenRecordPoll);
|
||||
Thread.sleep(sleepTimeBetweenRecordPoll);
|
||||
}else {
|
||||
go = false;
|
||||
}
|
||||
|
@ -527,11 +551,15 @@ public class RecordTest extends ContextTest {
|
|||
|
||||
@Ignore
|
||||
@Test
|
||||
public void emptyThrash() throws Exception {
|
||||
ContextTest.setContextByName(PROD_VRE_GRSF_PRE);
|
||||
public void emptyPackageThrash() throws Exception {
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
// ContextTest.setContextByName(PRODUCTION_GRSF_PRE);
|
||||
// ContextTest.setContextByName(PRODUCTION_GRSF_ADMIN);
|
||||
// ContextTest.setContextByName(PRODUCTION_GRSF);
|
||||
GRSFCatalogueConfiguration conf = GRSFCatalogueConfigurationFactory.getInstance();
|
||||
CKANPackageTrash ckanPackageTrash = new CKANPackageTrash(conf);
|
||||
ckanPackageTrash.setOwnOnly(false);
|
||||
ckanPackageTrash.empty();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,12 +34,6 @@ public class GRSFUtilities extends ContextTest {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(GRSFUtilities.class);
|
||||
|
||||
public static final String PRODUCTION_GRSF = "/d4science.research-infrastructures.eu/FARM/GRSF";
|
||||
public static final String PRODUCTION_GRSF_ADMIN = "/d4science.research-infrastructures.eu/FARM/GRSF_Admin";
|
||||
public static final String PRODUCTION_GRSF_PRE = "/d4science.research-infrastructures.eu/FARM/GRSF_Pre";
|
||||
|
||||
public static final String PREPROD_GRSF_PRE = "/pred4s/preprod/GRSF_Pre";
|
||||
|
||||
public static final Map<String,String> SOURCE_TO_ID;
|
||||
public static final Map<String,String> ID_TO_SOURCE;
|
||||
|
||||
|
@ -125,12 +119,12 @@ public class GRSFUtilities extends ContextTest {
|
|||
return Arrays.asList(groupArray);
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void createGRSFGroups() throws ObjectNotFound, Exception {
|
||||
|
||||
// Reading groups from a CKAN related to a VRE
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
ContextTest.setContextByName(PRODUCTION_GRSF);
|
||||
|
||||
String key = CKANUtility.getSysAdminAPI();
|
||||
|
||||
|
@ -148,7 +142,7 @@ public class GRSFUtilities extends ContextTest {
|
|||
Set<String> createdGroup = new HashSet<>();
|
||||
|
||||
// Creating groups in another related to another VRE
|
||||
ContextTest.setContextByName(PRODUCTION_GRSF_PRE);
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||
|
||||
for(String name : groupNames) {
|
||||
|
@ -222,10 +216,10 @@ public class GRSFUtilities extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
//@Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void createNewGRSFGroups() throws ObjectNotFound, Exception {
|
||||
ContextTest.setContextByName(PROD_VRE_GRSF_PRE);
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
|
||||
String[] usernames = getUsers();
|
||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||
|
@ -244,9 +238,9 @@ public class GRSFUtilities extends ContextTest {
|
|||
String json = objectMapper.writeValueAsString(node);
|
||||
logger.info(json);
|
||||
ckanGroupToCreate.create(json);
|
||||
for(String username : usernames) {
|
||||
addUserToGroup(username, name, sysAdminAPI);
|
||||
}
|
||||
// for(String username : usernames) {
|
||||
// addUserToGroup(username, name, sysAdminAPI);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,10 +265,10 @@ public class GRSFUtilities extends ContextTest {
|
|||
}
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void deleteGRSFGroups() throws ObjectNotFound, Exception {
|
||||
ContextTest.setContextByName(PROD_VRE_GRSF_PRE);
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
|
||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||
boolean fromCKAN = true;
|
||||
|
@ -283,15 +277,15 @@ public class GRSFUtilities extends ContextTest {
|
|||
logger.debug(SecretManagerProvider.instance.get().getContext());
|
||||
|
||||
for(String name : groupNames) {
|
||||
CKANGroup ckanGroupToCreate = new CKANGroup();
|
||||
ckanGroupToCreate.setApiKey(sysAdminAPI);
|
||||
CKANGroup ckanGroupToPurge = new CKANGroup();
|
||||
ckanGroupToPurge.setApiKey(sysAdminAPI);
|
||||
if(!fromCKAN) {
|
||||
name = getGroupId(name);
|
||||
}
|
||||
ckanGroupToCreate.setName(name);
|
||||
ckanGroupToPurge.setName(name);
|
||||
|
||||
try {
|
||||
ckanGroupToCreate.purge();
|
||||
// ckanGroupToPurge.purge();
|
||||
}catch (Exception e) {
|
||||
logger.error("Error while purging group with name {}", name, e);
|
||||
}
|
||||
|
@ -327,10 +321,10 @@ public class GRSFUtilities extends ContextTest {
|
|||
return usernames;
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void associateUserToAllCKANGroupsAndOrganization() throws ObjectNotFound, Exception {
|
||||
ContextTest.setContextByName(PROD_VRE_GRSF_PRE);
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
String[] usernames = getUsers();
|
||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||
boolean fromCKAN = true;
|
||||
|
@ -359,10 +353,10 @@ public class GRSFUtilities extends ContextTest {
|
|||
|
||||
}
|
||||
|
||||
// @Ignore
|
||||
@Ignore
|
||||
@Test
|
||||
public void manageOrganizations() throws Exception {
|
||||
ContextTest.setContextByName(PROD_VRE_GRSF_PRE);
|
||||
ContextTest.setContextByName(PREPROD_GRSF_PRE);
|
||||
String sysAdminAPI = CKANUtility.getSysAdminAPI();
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
@ -382,11 +376,11 @@ public class GRSFUtilities extends ContextTest {
|
|||
node.put("name", ckanOrganization.getName());
|
||||
String json = objectMapper.writeValueAsString(node);
|
||||
logger.info("Going to create organization {} : {}", ckanOrganization.getName(), json);
|
||||
ckanOrganization.create(json);
|
||||
// ckanOrganization.create(json);
|
||||
logger.info("Organization {} created successfully", ckanOrganization.getName());
|
||||
}else {
|
||||
logger.info("Going to purge organization {}", ckanOrganization.getName());
|
||||
ckanOrganization.purge();
|
||||
// ckanOrganization.purge();
|
||||
logger.info("Organization {} purged successfully", ckanOrganization.getName());
|
||||
}
|
||||
}catch (Exception e) {
|
||||
|
|
Loading…
Reference in New Issue