cancel
Showing results for 
Search instead for 
Did you mean: 

[TEST] [LTS-2023] missing directories when testing with local contribution

cheshire
Champ on-the-rise
Champ on-the-rise

hello, i need to test operations and listeners using vocabularies, they are present in my studio package but, from what i understand are not included when the package is deployed locally  upon testing

  • this error when running a test meant to use a local directory contribution
%ERROR  1,should_Pass(my.package.operations.SomeOperationTest)
%TRACES 
org.nuxeo.ecm.directory.DirectoryException: Failed to invoke operation SomeOperation, No directory registered with name: Some_Directory
  • below is the structure of my core project source folder
main
  |- java
  |   |- my.package.operations
  |   |   |- SomeOperation.java
test
  |- java
  |   |- my.package.operations
  |   |   |- SomeOperationTest.java
  |- resources
  |   |- directories
  |   |   |- Some_Directory.csv
  |   |- OSGI-INF
  |   |   |- test-directories-contrib.xml
  • here is my test class
@RunWith(FeaturesRunner.class)
@Features(AutomationFeature.class)
@RepositoryConfig(cleanup = Granularity.METHOD)
@Deploy({
    "studio.extensions.my-studio",
    "my-bundle-symbolic-name",
    "my-bundle-symbolic-name:OSGI-INF/test-directories-contrib.xml"})
public class SomeOperationTest {

  @Inject
  OperationContext context;

  @Inject
  AutomationService automation;
  
  public void should_Pass() throws OperationException {

    automation.run(context, "SomeOperation"); // raises exception

    // ... some assertion
  }
}
  • here is the operation failing
@Operation(
    id = "SomeOperation",
    category = "Some",
    label = "Operation",
    description = "Openning a directory")
public class SomeOperation {

  @OperationMethod()
  public void run() {

    Framework.getService(DirectoryService.class).open("Some_Directory"); // raises exception

    // ... some more code
  }
}
  • this is the contribution
<?xml version="1.0"?>
<component name="my.package.test.directories">
  <extension target="org.nuxeo.ecm.directory.GenericDirectory" point="directories">
    <directory name="Some_Directory" extends="template-directory">
      <schema>vocabulary</schema>
      <idField>id</idField>
      <autoincrementIdField>false</autoincrementIdField>
      <dataFile>directories/Some_Directory.csv</dataFile>
      <createTablePolicy>on_missing_columns</createTablePolicy>
    </directory>
  </extension>
</component>
  • this is the content of the csv file
id,label,obsolete
"some","entry","0"

what am i missing, i have been running in circle for quite some time now i can't seem to find a solution anywhere

5 REPLIES 5

Jordann_Rousse1
Employee
Employee

Can you try to add the DirectoryFeature in your test class?

Instead of:

@Features(AutomationFeature.class)

Try:

import org.nuxeo.directory.test.DirectoryFeature;
...
@Features({ AutomationFeature.class, DirectoryFeature.class })

And when running the tests, have a look in the console for the "Component loading" part, if for some reason something cannot be loaded, it will show up there (and tell you what dependencies is missing)

 

cheshire
Champ on-the-rise
Champ on-the-rise

i unfortunately get the same error.

Do you have any components unable to be loaded during the test? In the console, have a look for the "Component Loading Status" part, you should have something like below that could maybe explain why your vocabulary is not loaded:

======================================================================
= Component Loading Status: Pending: 0 / Missing: 3 / Unstarted: 1 / Total: 206
  * service:org.nuxeo.elasticsearch.managment.contrib references missing [target=org.nuxeo.ecm.core.management.CoreManagementComponent;point=probes, target=org.nuxeo.ecm.core.management.CoreManagementComponent;point=healthCheck]
  * service:org.nuxeo.ecm.core.automation.features.bindings references missing [target=org.nuxeo.ecm.automation.server.AutomationServer;point=bindings]
  * service:org.nuxeo.runtime.stream.service.managment.contrib references missing [target=org.nuxeo.ecm.core.management.CoreManagementComponent;point=probes, target=org.nuxeo.ecm.core.management.CoreManagementComponent;point=healthCheck]
  - service:org.nuxeo.ecm.platform.ec.notification.service.NotificationService
======================================================================

cheshire
Champ on-the-rise
Champ on-the-rise

i do

======================================================================
= Component Loading Status: Pending: 6 / Missing: 3 / Unstarted: 0 / Total: 197
  * service:org.nuxeo.core.elasticsearch.custom requires [service:org.nuxeo.elasticsearch.ElasticSearchComponent.contrib]
  * service:org.nuxeo.ecm.platform.suggestbox.core.defaultSuggesters.override requires [service:org.nuxeo.ecm.platform.suggestbox.core.defaultSuggesters]
  * service:my.package.services.AuthService requires [service:org.nuxeo.ecm.jwt.auth, service:org.nuxeo.ecm.restapi.server.auth.config]
  * service:org.nuxeo.ecm.platform.thumbnail.listener.disable requires [service:org.nuxeo.ecm.platform.thumbnail.listener]
  * service:my.package.core.marshaller requires [service:org.nuxeo.ecm.platform.types.marshallers]
  * service:org.nuxeo.ecm.document.pageproviders.override requires [service:org.nuxeo.ecm.document.pageproviders]
  * service:studio.extensions.autodistribution references missing [target=org.nuxeo.elasticsearch.ElasticSearchComponent;point=elasticSearchIndex, target=org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService;point=loginScreen, target=org.nuxeo.ecm.platform.WebResources;point=resources, target=org.nuxeo.ecm.platform.WebResources;point=bundles, target=org.nuxeo.ecm.platform.types.TypeService;point=types, target=org.nuxeo.ecm.platform.ec.notification.service.NotificationService;point=templates]
  * service:org.nuxeo.ecm.core.automation.features.bindings references missing [target=org.nuxeo.ecm.automation.server.AutomationServer;point=bindings]
  * service:org.nuxeo.runtime.stream.service.managment.contrib references missing [target=org.nuxeo.ecm.core.management.CoreManagementComponent;point=probes, target=org.nuxeo.ecm.core.management.CoreManagementComponent;point=healthCheck]
======================================================================

is there something i can do to load them, i tried @Deploy  but end up with deployment errors

As you can see, your studio contribution is not loaded due to missing references, which should explain why your vocabulary is not defined during the context of your unit test:

  * service:studio.extensions.autodistribution references missing [target=org.nuxeo.elasticsearch.ElasticSearchComponent;point=elasticSearchIndex, target=org.nuxeo.ecm.platform.ui.web.auth.service.PluggableAuthenticationService;point=loginScreen, target=org.nuxeo.ecm.platform.WebResources;point=resources, target=org.nuxeo.ecm.platform.WebResources;point=bundles, target=org.nuxeo.ecm.platform.types.TypeService;point=types, target=org.nuxeo.ecm.platform.ec.notification.service.NotificationService;point=templates]

For each missing reference, you need to find which bundle brings it, and you should deploy it within your unit test.
For example with point=elasticSearchIndex, we can see the extension point is defined there: https://github.com/nuxeo/nuxeo/blob/1b35dcdbce963594a6d891e7ccdf0c9279ad4fce/modules/platform/nuxeo-... 

Which is part of bundle "org.nuxeo.elasticsearch.core" (see here https://github.com/nuxeo/nuxeo/blob/1b35dcdbce963594a6d891e7ccdf0c9279ad4fce/modules/platform/nuxeo-...

So either you deploy "org.nuxeo.elasticsearch.core", or you can directly use feature "RepositoryElasticSearchFeature" already loading that bundle:  https://github.com/nuxeo/nuxeo/blob/1b35dcdbce963594a6d891e7ccdf0c9279ad4fce/modules/platform/nuxeo-... 

 

Repeat that logic for each missing references until your service:studio.extensions.autodistribution is loaded when you execute your test! 🙂 

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.