From cc9523d413ae12a744b3126f8967f2104d9e69e5 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 23 Apr 2019 13:17:17 +0000 Subject: [PATCH] Setting the default workspace JDK as project JDK git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/private/luca.frosini/infrastructure-tests@179127 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 2 +- .project | 1 + .settings/org.eclipse.jdt.core.prefs | 3 - pom.xml | 143 +++++----- .../ContextAuthorizationTest.java | 17 +- .../gcube/authorization/ContextUtility.java | 6 + .../CodeExamplesDeliverablesD65.java | 150 +++++++++++ .../deliverable65/context-examples.json | 106 ++++++++ .../deliverable65/instances-examples.json | 252 ++++++++++++++++++ .../deliverable65/query-examples.json | 118 ++++++++ .../deliverable65/schema-examples.json | 104 ++++++++ .../java/org/gcube/phd/ContextStatistic.java | 21 +- .../org/gcube/phd/StatisticsGenerator.java | 1 - src/test/resources/logback-test.xml | 2 +- 14 files changed, 844 insertions(+), 82 deletions(-) create mode 100644 src/test/java/org/gcube/informationsystem/deliverable65/CodeExamplesDeliverablesD65.java create mode 100644 src/test/java/org/gcube/informationsystem/deliverable65/context-examples.json create mode 100644 src/test/java/org/gcube/informationsystem/deliverable65/instances-examples.json create mode 100644 src/test/java/org/gcube/informationsystem/deliverable65/query-examples.json create mode 100644 src/test/java/org/gcube/informationsystem/deliverable65/schema-examples.json diff --git a/.classpath b/.classpath index fae1a2b..8e795b1 100644 --- a/.classpath +++ b/.classpath @@ -22,7 +22,7 @@ - + diff --git a/.project b/.project index 7ae32be..5b325d4 100644 --- a/.project +++ b/.project @@ -3,6 +3,7 @@ infrastructure-tests + resource-registry-context-client diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 714351a..4ede96d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,5 +1,2 @@ eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/pom.xml b/pom.xml index 330bd84..51af0a6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,17 +1,19 @@ - - 4.0.0 - - org.gcube.tools - maven-parent - 1.0.0 - - - infrastructure-tests - 1.0.0-SNAPSHOT - Infrastructure Tests - Tests involving infrastructure interaction - - + + 4.0.0 + + org.gcube.tools + maven-parent + 1.0.0 + + + infrastructure-tests + 1.0.0-SNAPSHOT + Infrastructure Tests + Tests involving infrastructure interaction + + UTF-8 ${project.basedir}/distro @@ -49,13 +51,17 @@ - + org.gcube.common context-enumeration [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) - + + org.apache.commons + commons-math3 + 3.6.1 + org.gcube.common authorization-client @@ -79,36 +85,44 @@ [1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT) test - + org.gcube.data.publishing document-store-lib-accounting-service [1.0.1-SNAPSHOT, 2.0.0-SNAPSHOT) test - + - - + + + org.gcube.information-system + resource-registry-context-client + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + org.gcube.information-system + resource-registry-schema-client + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + org.gcube.information-system + resource-registry-publisher + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + org.gcube.information-system + resource-registry-context-client + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + org.gcube.common home-library-jcr @@ -119,38 +133,32 @@ home-library [2.0.0-SNAPSHOT,3.0.0-SNAPSHOT) - - + + org.gcube.accounting accounting-lib test - + org.gcube.accounting accounting-analytics [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) test - org.gcube.accounting - accounting-analytics-persistence-couchdb - [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) - test - - --> - - org.gcube.accounting - accounting-analytics-persistence-couchbase + accounting-analytics-persistence-couchbase [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) test - - + + org.gcube.vremanagement smart-executor @@ -161,10 +169,10 @@ org.gcube.vremanagement smart-executor-client - [2.0.0-SNAPSHOT,3.0.0-SNAPSHOT) + 1.6.0-SNAPSHOT test - + org.acme HelloWorldPlugin @@ -173,7 +181,7 @@ org.gcube.accounting - accounting-aggregator-se-plugin + accounting-aggregator-se-plugin [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) test @@ -183,23 +191,18 @@ [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) test - + org.gcube.information-system is-exporter-se-plugin [1.0.0-SNAPSHOT,2.0.0-SNAPSHOT) test - - - - + + + + org.gcube.core common-scope @@ -215,7 +218,7 @@ common-encryption test - + org.slf4j slf4j-api @@ -227,7 +230,7 @@ 1.0.13 test - + junit junit @@ -236,5 +239,5 @@ - + \ No newline at end of file diff --git a/src/test/java/org/gcube/authorization/ContextAuthorizationTest.java b/src/test/java/org/gcube/authorization/ContextAuthorizationTest.java index 0734a1d..6e9331c 100644 --- a/src/test/java/org/gcube/authorization/ContextAuthorizationTest.java +++ b/src/test/java/org/gcube/authorization/ContextAuthorizationTest.java @@ -32,13 +32,18 @@ public class ContextAuthorizationTest extends ContextTest { @Test public void generateApplicationToken() throws Exception { ContextTest.setContextByName("/d4science.research-infrastructures.eu"); + //ContextTest.setContextByName("/pred4s"); + // ContextTest.setContextByName("/gcube"); + + String context = "/d4science.research-infrastructures.eu/ParthenosVO/PARTHENOS_Registry"; + //String context = "/pred4s/preprod/preVRE"; + // String context = "/gcube/devNext/NextNext"; - String context = "/d4science.research-infrastructures.eu"; UserInfo userInfo = new UserInfo("luca.frosini",new ArrayList<>()); String userToken = authorizationService().generateUserToken(userInfo, context); SecurityTokenProvider.instance.set(userToken); - String applicationName = "nagios.check"; + String applicationName = "gCat"; String generatedToken = authorizationService().generateExternalServiceToken(applicationName); logger.trace("Application Token for application {} in Context {} is {}", applicationName, @@ -48,9 +53,11 @@ public class ContextAuthorizationTest extends ContextTest { @Test public void generateHostToken() throws Exception { - String currentContext = ContextUtility.getCurrentContext(); - String host = "pc-frosini.isti.cnr.it"; - int port = 8080; + ContextTest.setContextByName("/d4science.research-infrastructures.eu"); + String currentContext = "/d4science.research-infrastructures.eu/ParthenosVO/PARTHENOS_Registry"; //ContextUtility.getCurrentContext(); + + String host = "gcat.d4science.org"; + int port = 80; ContainerInfo containerInfo = new ContainerInfo(host, port); String tokenNode = authorizationService().requestActivation(containerInfo, currentContext); diff --git a/src/test/java/org/gcube/authorization/ContextUtility.java b/src/test/java/org/gcube/authorization/ContextUtility.java index d5e103d..258262a 100644 --- a/src/test/java/org/gcube/authorization/ContextUtility.java +++ b/src/test/java/org/gcube/authorization/ContextUtility.java @@ -9,6 +9,7 @@ import org.gcube.common.authorization.library.provider.ClientInfo; import org.gcube.common.authorization.library.provider.SecurityTokenProvider; import org.gcube.common.authorization.library.utils.Caller; import org.gcube.common.scope.api.ScopeProvider; +import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -78,4 +79,9 @@ public class ContextUtility { } } + + @Test + public void testToken() throws Exception { + ContextUtility.setContext("853c52cb-293e-4c76-b9f3-b36583e190d9-843339462"); + } } diff --git a/src/test/java/org/gcube/informationsystem/deliverable65/CodeExamplesDeliverablesD65.java b/src/test/java/org/gcube/informationsystem/deliverable65/CodeExamplesDeliverablesD65.java new file mode 100644 index 0000000..a6671b8 --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/deliverable65/CodeExamplesDeliverablesD65.java @@ -0,0 +1,150 @@ +package org.gcube.informationsystem.deliverable65; + +import java.util.UUID; + +import org.gcube.common.authorization.library.provider.SecurityTokenProvider; +import org.gcube.informationsystem.model.impl.entities.ContextImpl; +import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl; +import org.gcube.informationsystem.model.impl.relations.IsIdentifiedByImpl; +import org.gcube.informationsystem.model.reference.entities.Context; +import org.gcube.informationsystem.model.reference.entities.Facet; +import org.gcube.informationsystem.model.reference.entities.Resource; +import org.gcube.informationsystem.model.reference.properties.PropagationConstraint; +import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint; +import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint; +import org.gcube.informationsystem.model.reference.relations.IsIdentifiedBy; +import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient; +import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory; +import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisher; +import org.gcube.informationsystem.resourceregistry.publisher.ResourceRegistryPublisherFactory; +import org.gcube.informationsystem.resourceregistry.schema.ResourceRegistrySchemaClient; +import org.gcube.informationsystem.resourceregistry.schema.ResourceRegistrySchemaClientFactory; +import org.gcube.resourcemanagement.model.impl.entities.facets.CPUFacetImpl; +import org.gcube.resourcemanagement.model.impl.entities.facets.NetworkingFacetImpl; +import org.gcube.resourcemanagement.model.impl.entities.resources.HostingNodeImpl; +import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.ActivatesImpl; +import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.HostsImpl; +import org.gcube.resourcemanagement.model.reference.entities.facets.CPUFacet; +import org.gcube.resourcemanagement.model.reference.entities.facets.ContactFacet; +import org.gcube.resourcemanagement.model.reference.entities.facets.NetworkingFacet; +import org.gcube.resourcemanagement.model.reference.entities.resources.Actor; +import org.gcube.resourcemanagement.model.reference.entities.resources.EService; +import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode; +import org.gcube.resourcemanagement.model.reference.properties.AccessPolicy; +import org.gcube.resourcemanagement.model.reference.relations.consistsof.HasContact; +import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Activates; +import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Hosts; + +public class CodeExamplesDeliverablesD65 { + + public void contextClientExamples() throws Exception { + SecurityTokenProvider.instance.set("Your-Token-Here"); + ResourceRegistryContextClient resourceRegistryContextClient = ResourceRegistryContextClientFactory.create(); + + Context parthenosInfrastructure = new ContextImpl("ParthenosInfrastructure"); + resourceRegistryContextClient.create(parthenosInfrastructure); + + Context parthenosVO = new ContextImpl("ParthenosVO"); + parthenosVO.setParent(parthenosInfrastructure); + resourceRegistryContextClient.create(parthenosVO); + + resourceRegistryContextClient.read("30f6254c-c87a-451e-bc0f-7cfcbd94a84a"); + + // resourceRegistryContextClient.exists("30f6254c-c87a-451e-bc0f-7cfcbd94a84a"); + + + parthenosVO.setName("ParthenosCommunity"); + Context parthenosCommunity = resourceRegistryContextClient.update(parthenosVO); + + parthenosCommunity.setParent((Context) null); + resourceRegistryContextClient.update(parthenosCommunity); + + + resourceRegistryContextClient.delete(parthenosCommunity); + } + + public void schemaClientExamples() throws Exception { + SecurityTokenProvider.instance.set("Your-Token-Here"); + ResourceRegistrySchemaClient resourceRegistrySchemaClient = ResourceRegistrySchemaClientFactory.create(); + + resourceRegistrySchemaClient.create(Actor.class); + + resourceRegistrySchemaClient.create(ContactFacet.class); + + resourceRegistrySchemaClient.create(Hosts.class); + + resourceRegistrySchemaClient.create(HasContact.class); + + resourceRegistrySchemaClient.create(AccessPolicy.class); + + resourceRegistrySchemaClient.read("Actor", true); + + } + + public void instancesExamples() throws Exception { + SecurityTokenProvider.instance.set("Your-Token-Here"); + ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create(); + + CPUFacet cpuFacet = new CPUFacetImpl(); + cpuFacet.setClockSpeed("1 GHz"); + cpuFacet.setModel("Opteron"); + cpuFacet.setVendor("AMD"); + + CPUFacet createdCpuFacet = resourceRegistryPublisher.create(cpuFacet); + UUID uuid = createdCpuFacet.getHeader().getUUID(); // 69f0b376-38d2-4a85-bc63-37f9fa323f82 + + createdCpuFacet.setClockSpeed("2 GHz"); + CPUFacet updatedCpuFacet = resourceRegistryPublisher.update(createdCpuFacet); + + boolean deleted = resourceRegistryPublisher.delete(createdCpuFacet); + + } + + public void instancesExamples2() throws Exception { + SecurityTokenProvider.instance.set("Your-Token-Here"); + ResourceRegistryPublisher resourceRegistryPublisher = ResourceRegistryPublisherFactory.create(); + + EService eService = null; + + NetworkingFacet networkingFacet = new NetworkingFacetImpl(); + networkingFacet.setIPAddress("146.48.87.183"); + networkingFacet.setHostName("pc-frosini.isti.cnr.it"); + networkingFacet.setDomainName("isti.cnr.it"); + networkingFacet.setMask("255.255.248.0"); + networkingFacet.setBroadcastAddress("146.48.87.255"); + + networkingFacet = resourceRegistryPublisher.createFacet(networkingFacet); + + HostingNode hostingNode = new HostingNodeImpl(); + + CPUFacet cpuFacet = new CPUFacetImpl(); + cpuFacet.setClockSpeed("2 GHz"); + cpuFacet.setModel("Opteron"); + cpuFacet.setVendor("AMD"); + hostingNode.addFacet(cpuFacet); + + IsIdentifiedByImpl isIdentifiedBy = new IsIdentifiedByImpl(hostingNode, networkingFacet, null); + hostingNode.addFacet(isIdentifiedBy); + + PropagationConstraint propagationConstraint = new PropagationConstraintImpl(); + propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade); + propagationConstraint.setAddConstraint(AddConstraint.unpropagate); + + Activates hosts = new ActivatesImpl(hostingNode, eService, propagationConstraint); + hostingNode.attachResource(hosts); + + hostingNode = resourceRegistryPublisher.createResource(hostingNode); + + + /* update */ + + networkingFacet = (NetworkingFacet) hostingNode.getIdentificationFacets().get(0); + networkingFacet.setAdditionalProperty("username", "luca.frosini"); + cpuFacet = hostingNode.getFacets(CPUFacet.class).get(0); + cpuFacet.setClockSpeed("1 GHz"); + + hostingNode = resourceRegistryPublisher.updateResource(hostingNode); + + boolean deleted = resourceRegistryPublisher.deleteResource(hostingNode); + } +} diff --git a/src/test/java/org/gcube/informationsystem/deliverable65/context-examples.json b/src/test/java/org/gcube/informationsystem/deliverable65/context-examples.json new file mode 100644 index 0000000..5c2f83f --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/deliverable65/context-examples.json @@ -0,0 +1,106 @@ +{ + "@class": "Context", + "name": "ParthenosInfrastructure", + "header": { + "@class": "Header", + "uuid": "2705dd32-c857-444b-818a-3ec69e339e5d" + } +} + +{ + "@class": "Context", + "name": "ParthenosInfrastructure", + "header": { + "@class": "Header", + "uuid": "2705dd32-c857-444b-818a-3ec69e339e5d", + "creator": "luca.frosini", + "modifiedBy": "luca.frosini", + "creationTime": "2017-03-1711:47:55", + "lastUpdateTime": "2017-03-17 11:47:55" + } +} + +{ + "@class": "Context", + "name": "ParthenosVO", + "header": { + "@class": "Header", + "uuid": "30f6254c-c87a-451e-bc0f-7cfcbd94a84a" }, + "parent" : "2705dd32-c857-444b-818a-3ec69e339e5d" +} + +{ + "@class": "Context", + "name": "ParthenosVO", + "header": { + "@class": "Header", + "uuid": "30f6254c-c87a-451e-bc0f-7cfcbd94a84a", + "creator": "luca.frosini", + "modifiedBy": "luca.frosini", + "creationTime": "2017-03-17 11:47:56", + "lastUpdateTime": "2017-03-17 11:47:56" + }, + "parent" : "2705dd32-c857-444b-818a-3ec69e339e5d" +} + +{ + "@class": "Context", + "name": "ParthenosVO", + "header": { + "@class": "Header", + "uuid": "30f6254c-c87a-451e-bc0f-7cfcbd94a84a", + "creator": "luca.frosini", + "modifiedBy": "luca.frosini", + "creationTime": "2017-03-17 11:47:56", + "lastUpdateTime": "2017-03-17 11:47:56" + }, + "parent" : "2705dd32-c857-444b-818a-3ec69e339e5d" +} + + +{ + "@class": "Context", + "name": "ParthenosCommunity", + "header": { + "@class": "Header", + "uuid": "30f6254c-c87a-451e-bc0f-7cfcbd94a84a" + }, + "parent" : "2705dd32-c857-444b-818a-3ec69e339e5d" +} + +{ + "@class": "Context", + "name": "ParthenosCommunity", + "header": { + "@class": "Header", + "uuid": "30f6254c-c87a-451e-bc0f-7cfcbd94a84a", + "creator": "luca.frosini", + "modifiedBy": "luca.frosini", + "creationTime": "2017-03-17 11:47:56", + "lastUpdateTime": "2017-03-17 11:57:36" + }, + "parent" : "2705dd32-c857-444b-818a-3ec69e339e5d" +} + +{ + "@class": "Context", + "name": "ParthenosCommunity", + "header": { + "@class": "Header", + "uuid": "30f6254c-c87a-451e-bc0f-7cfcbd94a84a" + }, + "parent" : null +} + +{ + "@class": "Context", + "name": "ParthenosCommunity", + "header": { + "@class": "Header", + "uuid": "30f6254c-c87a-451e-bc0f-7cfcbd94a84a", + "creator": "luca.frosini", + "modifiedBy": "luca.frosini", + "creationTime": "2017-03-17 11:47:56", + "lastUpdateTime": "2017-03-17 11:58:21" + } +} diff --git a/src/test/java/org/gcube/informationsystem/deliverable65/instances-examples.json b/src/test/java/org/gcube/informationsystem/deliverable65/instances-examples.json new file mode 100644 index 0000000..e7470fd --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/deliverable65/instances-examples.json @@ -0,0 +1,252 @@ +{ + "@class": "CPUFacet", + "header": { + "@class": "Header", + "uuid": "69f0b376-38d2-4a85-bc63-37f9fa323f82" + }, + "model": "Opteron", + "vendor": "AMD", + "clockSpeed": "1 GHz" +}{ + "@class": "CPUFacet", + "header": { + "@class": "Header", + "uuid": "69f0b376-38d2-4a85-bc63-37f9fa323f82", + "creator": "luca.frosini", + "modifiedBy": "luca.frosini", + "creationTime": "2016-10-05 11:16:24", + "lastUpdateTime": "2016-10-05 11:16:24" + }, + "model": "Opteron", + "vendor": "AMD", + "clockSpeed": "1 GHz" +}{ + "@class": "CPUFacet", + "header": { + "uuid": "69f0b376-38d2-4a85-bc63-37f9fa323f82" + }, + /* only the UUID is checked and must be the same of the UUID provided in the URL*/ + "model": "Opteron", + "vendor": "AMD", + "clockSpeed": "2 GHz" +}{ + "@class": "CPUFacet", + "header": { + "@class": "Header", + "uuid": "69f0b376-38d2-4a85-bc63-37f9fa323f82", + "creator": "luca.frosini", + "modifiedBy": "luca.frosini", + "creationTime": "2016-10-05 11:16:24", + "lastUpdateTime": "2016-10-05 11:18:33" + }, + "model": "Opteron", + "vendor": "AMD", + "clockSpeed": "2 GHz" +}{ + "@class": "HostingNode", + "header": { + "uuid": "670eeabf-76c7-493f-a449-4e6e139a2e84", + ... + }"consistsOf": [ + { + "@class": "ConsistsOf", + "target": { + "@class": "CPUFacet", + "model": "Opteron", + "vendor": "AMD", + "clockSpeed": "3 GHz" + } + }, + { + "@class": "IsIdentifiedBy", + "target": { + "@class": "NetworkingFacet", + "ipAddress": "146.48.87.183", + "hostName": "pc-frosini.isti.cnr.it", + "domainName": "isti.cnr.it", + "mask": "255.255.248.0", + "broadcastAddress": "146.48.87.255" + } + } + ], + "isRelatedTo": [ + { + "@class": "Hosts", + "propagationConstraint": { + "add": "unpropagate", + "remove": "cascade" + }, + "target": { + "@class": " EService", + "header": { + "uuid": "9bff49c8-c0a7-45de-827c-accb71defbd3" + } /* The EService was already created, so the UUID is enough to attach it by using Hosts relation */ + + } + } + ] +}{ + "@class": "HostingNode", + "header": { + "uuid": "670eeabf-76c7-493f-a449-4e6e139a2e84", + ... + }, + "consistsOf": [ + { + "@class": "ConsistsOf", + "header": { + "uuid": "9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca", + ... + }, + "target": { + "@class": "CPUFacet", + "header": { + "uuid": "1daef6a8-5ca4-4700-844b-2a2d784e17b0", + ... + }, + "model": "Opteron", + "vendor": "AMD", + "clockSpeed": "1 GHz" + } + }, + { + "@class": "IsIdentifiedBy", + "header": { + "uuid": "02a7072c-4f72-4568-945b-9ddccc881e9f", + ... + }, + "target": { + "@class": "NetworkingFacet", + "header": { + "uuid": "59617b01-5856-4d8e-b85c-590a42039933", + ... + }, + "ipAddress": "146.48.87.183", + "hostName": "pc-frosini.isti.cnr.it", + "domainName": "isti.cnr.it", + "mask": "255.255.248.0", + "broadcastAddress": "146.48.87.255" + } + } + ], + "isRelatedTo": [ + { + "@class": "Hosts", + "header": { + "uuid": "47494ad0-e606-4630-9def-4c607761ae14", + ... + }, + "propagationConstraint": { + "add": "unpropagate", + "remove": "cascade" + }, + "target": { + "@class": "EService", + "header": { + "uuid": "9bff49c8-c0a7-45de-827c-accb71defbd3", + ... + } + } + } + ] +}{ + "@class": "HostingNode", + "header": { + "uuid": "670eeabf-76c7-493f-a449-4e6e139a2e84", + ... + }, + "consistsOf": [ + { + "@class": "ConsistsOf", + "header": { + "uuid": "9d0b1b2b-ac4e-40a9-8dea-bec90076e0ca", + ... + }, + "target": { + "@class": "CPUFacet", + "header": { + "uuid": "1daef6a8-5ca4-4700-844b-2a2d784e17b0", + ... + }, + "model": "Opteron", + "vendor": "AMD", + /* Updated the following property */ + "clockSpeed": "1 GHz" + } + }, + { + "@class": "IsIdentifiedBy", + "header": { + "uuid": "02a7072c-4f72-4568-945b-9ddccc881e9f", + ... + }, + "target": { + "@class": "NetworkingFacet", + "header": { + "uuid": "59617b01-5856-4d8e-b85c-590a42039933", + ... + }, + "ipAddress": "146.48.87.183", + "hostName": "pc-frosini.isti.cnr.it", + "domainName": "isti.cnr.it", + "mask": "255.255.248.0", + "broadcastAddress": "146.48.87.255", + /* Added the following property */ + "username": "luca.frosini" + } + } + ] +} + +{ + "@class": "IsIdentifiedBy", + "header": { + "uuid": "02a7072c-4f72-4568-945b-9ddccc881e9f", + ... + }, + "source": { + "@class": "HostingNode", + // The HostingNode must be already created. The header with UUID is enough. + "header": { + "uuid": "670eeabf-76c7-493f-a449-4e6e139a2e84" + } + }, + "target": { + "@class": "NetworkingFacet", + /* The NetworkingFacet already exists, so the UUID is enough to attach it by using IsIdentifiedBy relation */ + "header": { + "uuid": "59617b01-5856-4d8e-b85c-590a42039933" + }, + } +} + + +{ + "@class": "IsIdentifiedBy", + "header": { + "uuid": "02a7072c-4f72-4568-945b-9ddccc881e9f", + ... + }, + "propagationConstraint": { + "add": "propagate", + "remove": "cascadeWhenOrphan" + }, + "source": { + "@class": "HostingNode", + "header": { + "uuid": "670eeabf-76c7-493f-a449-4e6e139a2e84" + } + }, + "target": { + "@class": "NetworkingFacet", + "header": { + "uuid": "59617b01-5856-4d8e-b85c-590a42039933", + ... + }, + "ipAddress": "146.48.87.183", + "hostName": "pc-frosini.isti.cnr.it", + "domainName": "isti.cnr.it", + "mask": "255.255.248.0", + "broadcastAddress": "146.48.87.255" + } +} diff --git a/src/test/java/org/gcube/informationsystem/deliverable65/query-examples.json b/src/test/java/org/gcube/informationsystem/deliverable65/query-examples.json new file mode 100644 index 0000000..91f54d1 --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/deliverable65/query-examples.json @@ -0,0 +1,118 @@ +[ + { + "@class": "EService", + "header": { + "uuid": "0717b450-a698-11e2-900a-a46c6ff57f05", + ... + }, + "consistsOf": [ + ... + ], + "isRelatedTo": [ + ... + ], + }, + ..., + { + "@class": "EService", + "header": { + "uuid": "3b6061f9-e2ab-4c01-b3b2-48b470a5b8a", + ... + }, + "consistsOf": [ + ... + ], + "isRelatedTo": [ + ... + ], + } +] + + +[ + { + "@class": "RunningPlugin", + "header": { + "uuid": "66d69dab-203e-45ff-b49e-a8fa4126a392", + ... + }, + , + "consistsOf": [ + ... + ], + "isRelatedTo": [ + ... + ], + }, + ..., + { + "@class": "EService", + "header": { + "uuid": "0717b450-a698-11e2-900a-a46c6ff57f05", + ... + }, + , + "consistsOf": [ + ... + ], + "isRelatedTo": [ + ... + ], + } +] + + + +{ + "result": [ + { + "@type": "d", + "@rid": "#99:5", + "@version": 12, + "@class": "SoftwareFacet", + "header": { + "@type": "d", + "@version": 0, + "@class": "Header", + "uuid": "6b724a7c-9f51-4a4e-8e8e-1636ca2e9d29", + "creator": "VREManagement:WhnManager:pc-frosini.isti.cnr.it_8080", + "creationTime": "2017-10-05 16:09:02.618 +0200", + "lastUpdateTime": "2017-10-05 17:23:44.191 +0200", + "@fieldTypes": "creationTime=t,lastUpdateTime=t" + }, + "name": "WhnManager", + "description": "Web Hosting Node Service", + "optional": false, + "version": "2.0.0-SNAPSHOT", + "group": "VREManagement", + "in_IsIdentifiedBy": [ + "#168:5" + ] + }, + { + "@type": "d", + "@rid": "#99:6", + "@version": 5, + "@class": "SoftwareFacet", + "header": { + "@type": "d", + "@version": 0, + "@class": "Header", + "uuid": "bc98eec4-4365-49fd-83b3-2cacaf17f8bf", + "creator": "VREManagement:SmartExecutor:pc-frosini.isti.cnr.it_8080", + "creationTime": "2017-10-05 17:22:06.351 +0200", + "lastUpdateTime": "2017-10-05 17:23:44.206 +0200", + "@fieldTypes": "creationTime=t,lastUpdateTime=t" + }, + "name": "SmartExecutor", + "description": "Smart Executor Service", + "optional": false, + "version": "1.7.0-SNAPSHOT", + "group": "VREManagement", + "in_IsIdentifiedBy": [ + "#168:6" + ] + } + ], + "notification": "Query executed in 0.147 sec. Returned 2 record(s)" +} diff --git a/src/test/java/org/gcube/informationsystem/deliverable65/schema-examples.json b/src/test/java/org/gcube/informationsystem/deliverable65/schema-examples.json new file mode 100644 index 0000000..de479e7 --- /dev/null +++ b/src/test/java/org/gcube/informationsystem/deliverable65/schema-examples.json @@ -0,0 +1,104 @@ +{ + "name": "Actor", + "description": "Any entity (human or machine) playing an active role.", + "abstractType": true, + "superclasses": ["Resource"], + "facets": [ + /*...*/ + ], + "resources": [ + /*...*/ + ] +} + +{ + "name": "ContactFacet", + "description": "This facet is expected to capture contact information", + "abstractType": false, + "superclasses":["Facet"], + "properties":[ + { + "name": "name", + "description": "First Name", + "mandatory": true, + "readonly": false, + "notnull": true, + "max": null, + "min": null, + "regexpr": null, + "linkedType": null, + "linkedClass": null, + "type": 7 /* String*/ + }, + { + "name": "eMail", + "description": "A restricted range of RFC 822 compliant email address. ... ", + "mandatory": true, + "readonly": false, + "notnull": true, + "max": null, + "min": null, + "regexpr":"^[a-z0-9._%+-]{1,128}@[a-z0-9.-]{1,128}$", + "linkedType": null, + "linkedClass": null, + "type":7 /* String */ + }, + ... + ] +} + +{ + "name": "Hosts", + "description": "…", + "abstractType": false, + "superclasses": ["IsRelatedTo"], + "properties": null, + "source": "Site", + "target": "Service" +} + +{ + "name": "HasContact", + "description": "…", + "abstractType": false, + "superclasses": ["ConsistsOf"], + "properties": null, + "source": "Resource", + "target": "ContactFacet" +} + + +{ + "name": "AccessPolicy", + "description": "", + "abstractType": false, + "superclasses": ["Embedded"], + "properties":[ + { + "name": "policy", + "description": "", + "mandatory": false, + "readonly": false, + "notnull": false, + "max": null, + "min": null, + "regexpr": null, + "linkedType": null, + "linkedClass": "ValueSchema", + "type": 9 /* Embedded */ + }, + { + "name": "note", + "description": "", + "mandatory": false, + "readonly": false, + "notnull": false, + "max": null, + "min": null, + "regexpr": null, + "linkedType": null, + "linkedClass": null, + "type":7 /* String */ + } + ] +} diff --git a/src/test/java/org/gcube/phd/ContextStatistic.java b/src/test/java/org/gcube/phd/ContextStatistic.java index 0931e80..095835d 100644 --- a/src/test/java/org/gcube/phd/ContextStatistic.java +++ b/src/test/java/org/gcube/phd/ContextStatistic.java @@ -81,6 +81,25 @@ public class ContextStatistic { List instances = client.submit(query); for(R r : instances) { ResourceInfo resourceInfo = new ResourceInfo(r); + if(r instanceof HostingNode) { + HostingNode hn = (HostingNode) r; + if(hn.profile().description().status().compareTo("certified")!=0) { + continue; + } + + Calendar now = Calendar.getInstance(); + now.add(Calendar.DAY_OF_MONTH, -1); + if(hn.profile().description().lastUpdate().before(now)) { + continue; + } + } + + if(r instanceof GCoreEndpoint) { + GCoreEndpoint gce = (GCoreEndpoint) r; + if(gce.profile().deploymentData().status().compareTo("ready")!=0) { + continue; + } + } resources.add(resourceInfo); } } @@ -100,8 +119,8 @@ public class ContextStatistic { if(resourceMap == null) { resourceMap = new HashMap<>(); List> classes = new ArrayList<>(); - classes.add(GCoreEndpoint.class); classes.add(HostingNode.class); + classes.add(GCoreEndpoint.class); classes.add(ServiceEndpoint.class); classes.add(GenericResource.class); classes.add(Software.class); diff --git a/src/test/java/org/gcube/phd/StatisticsGenerator.java b/src/test/java/org/gcube/phd/StatisticsGenerator.java index 2e55427..06fb254 100644 --- a/src/test/java/org/gcube/phd/StatisticsGenerator.java +++ b/src/test/java/org/gcube/phd/StatisticsGenerator.java @@ -88,7 +88,6 @@ public class StatisticsGenerator { stringBuffer.append("Standard Deviation"); stringBuffer.append(","); stringBuffer.append("Geometric Mean"); - stringBuffer.append(","); printLineToFile(stringBuffer.toString(), statisticsFile); } diff --git a/src/test/resources/logback-test.xml b/src/test/resources/logback-test.xml index 7aee35e..4f36cc8 100644 --- a/src/test/resources/logback-test.xml +++ b/src/test/resources/logback-test.xml @@ -7,7 +7,7 @@ - +