You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Matteo Rulli <ma...@gmail.com> on 2017/04/20 10:09:00 UTC

Fileinstall, feature config and pax-exam

Hello,
We are running a couple of integration tests using pax-exam 4.10.0 and Karaf 4.0.8. In the test's @Configuration method we install a feature that contains both the bundle under test and the corresp. configuration files.

The tests work fine on most dev machines except one where the test fails. As far as I understood the test failure is triggered by fileinstall that restarts some bundles while the tests are running:

... test already started...

2017-04-20 09:30:48,638 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Updating configuration from org.apache.aries.transaction.cfg
2017-04-20 09:30:48,642 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Creating configuration from org.ops4j.datasource-dsone-postgres.cfg
2017-04-20 09:30:48,645 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Creating configuration from org.ops4j.datasource-dsone-postgres-plain.cfg
2

... test fails with:
<openjpa-2.4.1-r422266:1730418 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: This operation failed for some instances.  See the nested exceptions array for details.
Caused by: <openjpa-2.4.1-r422266:1730418 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: This operation cannot be performed while a Transaction is active.
FailedObject: org.apache.openjpa.persistence.EntityManagerImpl@28c1622b
	at org.apache.openjpa.kernel.AbstractBrokerFactory.assertNoActiveTransaction(AbstractBrokerFactory.java:708)[87:org.apache.openjpa:2.4.1]
	... 63 more

And if I query the ConfigAdmin, it reports the "duplicated" configuration entries for the DataSource:

    databaseName: dsone
    dataSourceName: xa-com.example.dsone.persistence
    org.apache.karaf.features.configKey: org.ops4j.datasource-dsone-postgres
    osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool-xa
    password: ******
    portNumber: 5432
    serverName: localhost
    service.factoryPid: org.ops4j.datasource
    service.pid: org.ops4j.datasource.211f5de1-8c00-4eaa-b501-b35ac6e9b6c4
    user: ******

    databaseName: dsone
    dataSourceName: com.example.dsone.persistence
    org.apache.karaf.features.configKey: org.ops4j.datasource-dsone-postgres-plain
    osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool
    password: ******
    portNumber: 5432
    serverName: localhost
    service.factoryPid: org.ops4j.datasource
    service.pid: org.ops4j.datasource.15452283-8188-4761-b134-f1d987eb3302
    user: ******

    databaseName: dsone
    dataSourceName: com.example.dsone.persistence
    felix.fileinstall.filenamefile:/Users/roberto/Documents/git/example/com.example.osgi.dsone/com.example.dsone.storage.provider/target/exam/b157e12e-78cc-4138-9be3-8841da76b972/etc/org.ops4j.datasource-dsone-postgres-plain.cfg
    osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool
    password: ******
    portNumber: 5432
    serverName: localhost
    service.factoryPid: org.ops4j.datasource
    service.pid: org.ops4j.datasource.78917eb8-051b-454d-905b-758b125ab631
    user: ******

    databaseName: dsone
    dataSourceName: xa-com.example.dsone.persistence
    felix.fileinstall.filenamefile:/Users/roberto/Documents/git/example/com.example.osgi.dsone/com.example.dsone.storage.provider/target/exam/b157e12e-78cc-4138-9be3-8841da76b972/etc/org.ops4j.datasource-dsone-postgres.cfg
    osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool-xa
    password: ******
    portNumber: 5432
    serverName: localhost
    service.factoryPid: org.ops4j.datasource
    service.pid: org.ops4j.datasource.0dfef597-9c1c-4cfc-864c-1a50c73b7350
    user: ******

So my question is:

1. Is this plausible? I mean: is it true that fileinstall could interpret config files that are installed by the feature service as new config files, triggering the problem above?
1. Is installing the config files along with the karaf feature the right way to go in this kind of scenarios?
2. What is the best way to solve this problem? I could wait in @Before method until I see all the config entries but this seems a little bit ugly to me...

Thank you,
matteo

Re: Fileinstall, feature config and pax-exam

Posted by Christian Schneider <ch...@die-schneider.net>.
Not sure if this is a good idea. This way the test is quite different 
from your real system.

Better use editConfigurationFilePut to create the data source config you 
need for the test.

Christian

On 20.04.2017 16:18, Matteo Rulli wrote:
> Thank you Christian. Yes you are right, we could simply avoid to embed 
> the config placeholders in the feature file.
>
> But there is also another way that just came to my mind:
>
> Option[] options = new Option[] {
> editConfigurationFilePut( "etc/config.properties", 
> "felix.fileinstall.poll", String.valueOf(Integer.MAX_VALUE)),
> features(biepiRepo,"my-feature-to-test")
> };
>
> as this prevents fileinstall to trigger bundle updates.
>
> Thanks,
> Matteo

-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com


Re: Fileinstall, feature config and pax-exam

Posted by Matteo Rulli <ma...@gmail.com>.
Thank you Christian. Yes you are right, we could simply avoid to embed the config placeholders in the feature file. 

But there is also another way that just came to my mind:

Option[] options = new Option[] {
	editConfigurationFilePut( "etc/config.properties", "felix.fileinstall.poll", String.valueOf(Integer.MAX_VALUE)),
	features(biepiRepo,"my-feature-to-test")
};

as this prevents fileinstall to trigger bundle updates. 

Thanks,
Matteo

> On 20 Apr 2017, at 15:41, Christian Schneider <ch...@die-schneider.net> wrote:
> 
> I think there is or was an issue with loading factory configs as defaults in a feature.
> 
> As your database config normally contains secret information I propose to not install it in the feature. Instead you can deploy the config as part of your pax exam setup.
> 
> Christian
> 
> On 20.04.2017 12:09, Matteo Rulli wrote:
>> Hello,
>> We are running a couple of integration tests using pax-exam 4.10.0 and Karaf 4.0.8. In the test's @Configuration method we install a feature that contains both the bundle under test and the corresp. configuration files.
>> 
>> The tests work fine on most dev machines except one where the test fails. As far as I understood the test failure is triggered by fileinstall that restarts some bundles while the tests are running:
>> 
>> ... test already started...
>> 
>> 2017-04-20 09:30:48,638 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Updating configuration from org.apache.aries.transaction.cfg
>> 2017-04-20 09:30:48,642 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Creating configuration from org.ops4j.datasource-dsone-postgres.cfg
>> 2017-04-20 09:30:48,645 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - org.apache.felix.fileinstall - 3.5.6 | Creating configuration from org.ops4j.datasource-dsone-postgres-plain.cfg
>> 2
>> 
>> ... test fails with:
>> <openjpa-2.4.1-r422266:1730418 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: This operation failed for some instances.  See the nested exceptions array for details.
>> Caused by: <openjpa-2.4.1-r422266:1730418 nonfatal user error> org.apache.openjpa.persistence.InvalidStateException: This operation cannot be performed while a Transaction is active.
>> FailedObject: org.apache.openjpa.persistence.EntityManagerImpl@28c1622b
>> 	at org.apache.openjpa.kernel.AbstractBrokerFactory.assertNoActiveTransaction(AbstractBrokerFactory.java:708)[87:org.apache.openjpa:2.4.1]
>> 	... 63 more
>> 
>> And if I query the ConfigAdmin, it reports the "duplicated" configuration entries for the DataSource:
>> 
>>     databaseName: dsone
>>     dataSourceName: xa-com.example.dsone.persistence
>>     org.apache.karaf.features.configKey: org.ops4j.datasource-dsone-postgres
>>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool-xa
>>     password: ******
>>     portNumber: 5432
>>     serverName: localhost
>>     service.factoryPid: org.ops4j.datasource
>>     service.pid: org.ops4j.datasource.211f5de1-8c00-4eaa-b501-b35ac6e9b6c4
>>     user: ******
>> 
>>     databaseName: dsone
>>     dataSourceName: com.example.dsone.persistence
>>     org.apache.karaf.features.configKey: org.ops4j.datasource-dsone-postgres-plain
>>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool
>>     password: ******
>>     portNumber: 5432
>>     serverName: localhost
>>     service.factoryPid: org.ops4j.datasource
>>     service.pid: org.ops4j.datasource.15452283-8188-4761-b134-f1d987eb3302
>>     user: ******
>> 
>>     databaseName: dsone
>>     dataSourceName: com.example.dsone.persistence
>>     felix.fileinstall.filenamefile:/Users/roberto/Documents/git/example/com.example.osgi.dsone/com.example.dsone.storage.provider/target/exam/b157e12e-78cc-4138-9be3-8841da76b972/etc/org.ops4j.datasource-dsone-postgres-plain.cfg
>>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool
>>     password: ******
>>     portNumber: 5432
>>     serverName: localhost
>>     service.factoryPid: org.ops4j.datasource
>>     service.pid: org.ops4j.datasource.78917eb8-051b-454d-905b-758b125ab631
>>     user: ******
>> 
>>     databaseName: dsone
>>     dataSourceName: xa-com.example.dsone.persistence
>>     felix.fileinstall.filenamefile:/Users/roberto/Documents/git/example/com.example.osgi.dsone/com.example.dsone.storage.provider/target/exam/b157e12e-78cc-4138-9be3-8841da76b972/etc/org.ops4j.datasource-dsone-postgres.cfg
>>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool-xa
>>     password: ******
>>     portNumber: 5432
>>     serverName: localhost
>>     service.factoryPid: org.ops4j.datasource
>>     service.pid: org.ops4j.datasource.0dfef597-9c1c-4cfc-864c-1a50c73b7350
>>     user: ******
>> 
>> So my question is:
>> 
>> 1. Is this plausible? I mean: is it true that fileinstall could interpret config files that are installed by the feature service as new config files, triggering the problem above?
>> 1. Is installing the config files along with the karaf feature the right way to go in this kind of scenarios?
>> 2. What is the best way to solve this problem? I could wait in @Before method until I see all the config entries but this seems a little bit ugly to me...
>> 
>> Thank you,
>> matteo
> 
> 
> -- 
> Christian Schneider
> http://www.liquid-reality.de <http://www.liquid-reality.de/>
> 
> Open Source Architect
> http://www.talend.com <http://www.talend.com/>


Re: Fileinstall, feature config and pax-exam

Posted by Christian Schneider <ch...@die-schneider.net>.
I think there is or was an issue with loading factory configs as 
defaults in a feature.

As your database config normally contains secret information I propose 
to not install it in the feature. Instead you can deploy the config as 
part of your pax exam setup.

Christian

On 20.04.2017 12:09, Matteo Rulli wrote:
> Hello,
> We are running a couple of integration tests using pax-exam 4.10.0 and 
> Karaf 4.0.8. In the test's @Configuration method we install a feature 
> that contains both the bundle under test and the corresp. 
> configuration files.
>
> The tests work fine on most dev machines except one where the test 
> fails. As far as I understood the test failure is triggered by 
> fileinstall that restarts some bundles while the tests are running:
>
> ... test already started...
>
> 2017-04-20 09:30:48,638 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - 
> org.apache.felix.fileinstall - 3.5.6 | Updating configuration from 
> org.apache.aries.transaction.cfg
> 2017-04-20 09:30:48,642 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - 
> org.apache.felix.fileinstall - 3.5.6 | Creating configuration from 
> org.ops4j.datasource-dsone-postgres.cfg
> 2017-04-20 09:30:48,645 | INFO  | 3952a6dd0975/etc | fileinstall | 4 - 
> org.apache.felix.fileinstall - 3.5.6 | Creating configuration from 
> org.ops4j.datasource-dsone-postgres-plain.cfg
> 2
>
> ... test fails with:
> <openjpa-2.4.1-r422266:1730418 nonfatal user error> 
> org.apache.openjpa.persistence.InvalidStateException: This operation 
> failed for some instances.  See the nested exceptions array for details.
> Caused by: <openjpa-2.4.1-r422266:1730418 nonfatal user error> 
> org.apache.openjpa.persistence.InvalidStateException: This operation 
> cannot be performed while a Transaction is active.
> FailedObject: org.apache.openjpa.persistence.EntityManagerImpl@28c1622b
> at 
> org.apache.openjpa.kernel.AbstractBrokerFactory.assertNoActiveTransaction(AbstractBrokerFactory.java:708)[87:org.apache.openjpa:2.4.1]
> ... 63 more
>
> And if I query the ConfigAdmin, it reports the "duplicated" 
> configuration entries for the DataSource:
>
>     databaseName: dsone
>     dataSourceName: xa-com.example.dsone.persistence
> org.apache.karaf.features.configKey: org.ops4j.datasource-dsone-postgres
>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool-xa
>     password: ******
>     portNumber: 5432
>     serverName: localhost
>     service.factoryPid: org.ops4j.datasource
>     service.pid: org.ops4j.datasource.211f5de1-8c00-4eaa-b501-b35ac6e9b6c4
>     user: ******
>
>     databaseName: dsone
>     dataSourceName: com.example.dsone.persistence
> org.apache.karaf.features.configKey: 
> org.ops4j.datasource-dsone-postgres-plain
>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool
>     password: ******
>     portNumber: 5432
>     serverName: localhost
>     service.factoryPid: org.ops4j.datasource
>     service.pid: org.ops4j.datasource.15452283-8188-4761-b134-f1d987eb3302
>     user: ******
>
>     databaseName: dsone
>     dataSourceName: com.example.dsone.persistence
> felix.fileinstall.filenamefile:/Users/roberto/Documents/git/example/com.example.osgi.dsone/com.example.dsone.storage.provider/target/exam/b157e12e-78cc-4138-9be3-8841da76b972/etc/org.ops4j.datasource-dsone-postgres-plain.cfg
>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool
>     password: ******
>     portNumber: 5432
>     serverName: localhost
>     service.factoryPid: org.ops4j.datasource
>     service.pid: org.ops4j.datasource.78917eb8-051b-454d-905b-758b125ab631
>     user: ******
>
>     databaseName: dsone
>     dataSourceName: xa-com.example.dsone.persistence
> felix.fileinstall.filenamefile:/Users/roberto/Documents/git/example/com.example.osgi.dsone/com.example.dsone.storage.provider/target/exam/b157e12e-78cc-4138-9be3-8841da76b972/etc/org.ops4j.datasource-dsone-postgres.cfg
>     osgi.jdbc.driver.name: PostgreSQL JDBC Driver-pool-xa
>     password: ******
>     portNumber: 5432
>     serverName: localhost
>     service.factoryPid: org.ops4j.datasource
>     service.pid: org.ops4j.datasource.0dfef597-9c1c-4cfc-864c-1a50c73b7350
>     user: ******
>
> So my question is:
>
> 1. Is this plausible? I mean: is it true that fileinstall could 
> interpret config files that are installed by the feature service as 
> new config files, triggering the problem above?
> 1. Is installing the config files along with the karaf feature the 
> right way to go in this kind of scenarios?
> 2. What is the best way to solve this problem? I could wait in @Before 
> method until I see all the config entries but this seems a little bit 
> ugly to me...
>
> Thank you,
> matteo


-- 
Christian Schneider
http://www.liquid-reality.de

Open Source Architect
http://www.talend.com