galasa-dev / projectmanagement

Project Management repo for Issues and ZenHub
7 stars 4 forks source link

DB2 Manager: bundle fails to install and activate #1850

Closed jadecarino closed 4 months ago

jadecarino commented 5 months ago

Describe the bug

When trying to run a test that requires the DB2 Manager, the bundle is failing to install and activate and the test class is unable to proceed. The cause of this is unclear but as the Db2ManagerIVT was not added into our regression suite and therefore hasn't been tested in ~2 years, it could be assumed that the DB2 Manager has regressed in some way.

We were made aware of this bug by a user attempting to use the DB2 Manager in a brand new Galasa test project. I recreated the error by following the same steps they did. Additionally, I could not run the Db2ManagerIVT.

Steps to reproduce

Using the DB2 Manager in a brand-new Galasa project

  1. galasactl local init
  2. galasactl project create --package dev.galasa.test --features test --force --obr --log - --maven
  3. cd dev.galasa.test
  4. mvn clean install
  5. galasactl runs submit local --log - --obr mvn:dev.galasa.test/dev.galasa.test.obr/0.0.1-SNAPSHOT/obr --class dev.galasa.test.test/dev.galasa.test.test.TestTest Up until this point it works fine.
  6. Add this dependency to the pom.xml for dev.galasa.test:
        <dependency>
            <groupId>dev.galasa</groupId>
            <artifactId>dev.galasa.db2.manager</artifactId>
            <scope>provided</scope>
        </dependency>
  7. Add this dependency to the pom.xml for dev.galasa.test.test:
        <dependency>
            <groupId>dev.galasa</groupId>
            <artifactId>dev.galasa.db2.manager</artifactId>
        </dependency>
  8. Add this to the TestTest.java file:
    @Db2Instance (tag = "PRIMARY")
    public IDb2Instance db2;
    @Db2Schema (tag = "PRIMARY", db2Tag = "PRIMARY", archive = true)
    public IDb2Schema schema;
  9. mvn clean install
  10. galasactl runs submit local --log - --obr mvn:dev.galasa.test/dev.galasa.test.obr/0.0.1-SNAPSHOT/obr --class dev.galasa.test.test/dev.galasa.test.test.TestTest --trace

See error:

dev.galasa.framework.spi.FrameworkException: Bundle failed to install and activate
    at dev.galasa.framework.BundleManagement.loadBundle(BundleManagement.java:57) ~[-1714452933856:?]
    at dev.galasa.framework.TestRunner.runTest(TestRunner.java:232) [-1714452933856:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at dev.galasa.boot.felix.FelixFramework.runTest(FelixFramework.java:233) [galasa-boot-0.31.0.jar:?]
    at dev.galasa.boot.Launcher.launch(Launcher.java:176) [galasa-boot-0.31.0.jar:?]
    at dev.galasa.boot.Launcher.main(Launcher.java:126) [galasa-boot-0.31.0.jar:?]
Caused by: dev.galasa.framework.spi.FrameworkException: Bundle failed to install and activate
    at dev.galasa.framework.BundleManagement.addResource(BundleManagement.java:168) ~[-1714452933856:?]
    at dev.galasa.framework.BundleManagement.loadBundle(BundleManagement.java:55) ~[-1714452933856:?]
    ... 8 more

Running the Db2ManagerIVT

  1. Build all Galasa repositories up to and including the OBR so your ~/.m2/repository/dev/galasa is populated
  2. Run the Db2ManagerIVT locally: galasactl runs submit local --log - --obr mvn:dev.galasa/dev.galasa.uber.obr/0.33.0/obr --class dev.galasa.db2.manager.ivt/dev.galasa.db2.manager.ivt.Db2ManagerIVT

See error in run log:

30/04/2024 14:42:10.358 DEBUG d.g.f.FrameworkInitialisation - bootstrap property framework.config.store used to determine CPS location.
30/04/2024 14:42:10.358 DEBUG d.g.f.FrameworkInitialisation - Configuration Property Store is file:///Users/jadecarino/.galasa/cps.properties
30/04/2024 14:42:10.364 DEBUG d.g.f.FrameworkInitialisation - Selected CPS Service is dev.galasa.framework.internal.cps.FpfConfigurationPropertyStore
30/04/2024 14:42:10.365 DEBUG d.g.f.FrameworkInitialisation - Dynamic Status Store is file:///Users/jadecarino/.galasa/dss.properties
30/04/2024 14:42:10.365 DEBUG d.g.f.FrameworkInitialisation - Obtained value of DSS from galasa home
30/04/2024 14:42:10.370 INFO  d.g.f.FrameworkInitialisation - Submitting test dev.galasa.db2.manager.ivt/dev.galasa.db2.manager.ivt.Db2ManagerIVT
30/04/2024 14:42:10.394 INFO  d.g.f.FrameworkInitialisation - Allocated Run Name L120 to this run
30/04/2024 14:42:10.394 INFO  d.g.f.FrameworkInitialisation - Run name is L120
30/04/2024 14:42:10.395 DEBUG d.g.f.FrameworkInitialisation - Adding Result Archive Store location file:////Users/jadecarino/.galasa/ras
30/04/2024 14:42:10.395 DEBUG d.g.f.FrameworkInitialisation - Result Archive Stores are [file:////Users/jadecarino/.galasa/ras]
30/04/2024 14:42:10.410 DEBUG d.g.f.FrameworkInitialisation - Credentials Store is file:///Users/jadecarino/.galasa/credentials.properties
30/04/2024 14:42:10.412 INFO  d.g.f.FrameworkInitialisation - Framework initialised
30/04/2024 14:42:10.413 DEBUG d.g.f.TestRunner - CPS property framework.produce.events was found and is set to: true
30/04/2024 14:42:10.478 ERROR d.g.f.TestRunner - Unable to load the test bundle dev.galasa.db2.manager.ivt
dev.galasa.framework.spi.FrameworkException: Bundle failed to install and activate
    at dev.galasa.framework.BundleManagement.loadBundle(BundleManagement.java:57) ~[-1714484530186:?]
    at dev.galasa.framework.TestRunner.runTest(TestRunner.java:232) [-1714484530186:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at dev.galasa.boot.felix.FelixFramework.runTest(FelixFramework.java:233) [galasa-boot-0.31.0.jar:?]
    at dev.galasa.boot.Launcher.launch(Launcher.java:176) [galasa-boot-0.31.0.jar:?]
    at dev.galasa.boot.Launcher.main(Launcher.java:126) [galasa-boot-0.31.0.jar:?]
Caused by: dev.galasa.framework.spi.FrameworkException: Bundle failed to install and activate
    at dev.galasa.framework.BundleManagement.addResource(BundleManagement.java:168) ~[-1714484530186:?]
    at dev.galasa.framework.BundleManagement.loadBundle(BundleManagement.java:55) ~[-1714484530186:?]
    ... 8 more
dev.galasa.framework.spi.FrameworkException: Bundle failed to install and activate
    at dev.galasa.framework.BundleManagement.loadBundle(BundleManagement.java:57) ~[-1714484530186:?]
    at dev.galasa.framework.TestRunner.runTest(TestRunner.java:232) [-1714484530186:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at dev.galasa.boot.felix.FelixFramework.runTest(FelixFramework.java:233) [galasa-boot-0.31.0.jar:?]
    at dev.galasa.boot.Launcher.launch(Launcher.java:176) [galasa-boot-0.31.0.jar:?]
    at dev.galasa.boot.Launcher.main(Launcher.java:126) [galasa-boot-0.31.0.jar:?]
Caused by: dev.galasa.framework.spi.FrameworkException: Bundle failed to install and activate
    at dev.galasa.framework.BundleManagement.addResource(BundleManagement.java:168) ~[-1714484530186:?]
    at dev.galasa.framework.BundleManagement.loadBundle(BundleManagement.java:55) ~[-1714484530186:?]
    ... 8 more
30/04/2024 14:42:10.482 DEBUG d.g.f.TestRunner - Producing a test lifecycle status change event.
30/04/2024 14:42:10.496 INFO  d.g.f.Framework - Shutting down the framework
30/04/2024 14:42:10.496 INFO  d.g.f.Framework - Framework shutdown

Expected behavior

The bundle should be able to install and activate, and the test that attempts to use the DB2 Manager should be able to proceed with running.

techcobweb commented 4 months ago

Current status:

@KirbyKatcher Can you please provide more detailed status on progress here ?

It's possible that your configuration is wrong, and there is a mismatch in terms of versions of things. eg: New source, plugging in and replacing old driver, but they have different versions of dependencies, so the wiring doesn't work between OSGi bundles ?

@jadecarino Are you please able to talk with @KirbyKatcher and see how come it didn't work for you, and yet it did work for him ?

techcobweb commented 4 months ago

The customer is using 0.32.0

Here is their pom.xml:

for galasa ctl we have a 0.32.0 zip that was provided to me by test architect of the team
<dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>dev.galasa</groupId>
                <artifactId>galasa-bom</artifactId>
                <version>0.32.0</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>dev.galasa</groupId>
            <artifactId>dev.galasa</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dev.galasa</groupId>
            <artifactId>dev.galasa.core.manager</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>dev.galasa</groupId>
            <artifactId>dev.galasa.artifact.manager</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
        </dependency>
KirbyKatcher commented 4 months ago

I can not see the issue whilst trying with the community edition of DB2 and the correct properties:

command

galasactl runs submit local --log - --obr mvn:dev.galasa/dev.galasa.uber.obr/0.34.0/obr --class dev.galasa.db2.manager.ivt/dev.galasa.db2.manager.ivt.Db2ManagerIVT

cps.properties

  db2.dse.instance.PRIMARY.name=DB2INST1
  db2.dse.schema.PRIMARY.name=testdb
  db2.instance.DB2INST1.url=jdbc:db2://<url>:<port>/TESTDB
  db2.instance.DB2INST1.credentials=TESTDB

credentials.properties

  secure.credentials.TESTDB.username=<username>
  secure.credentials.TESTDB.password=<password>

The manager has not had any changes since version 0.25.0, so the same should work on galasa v 0.32.0.

KirbyKatcher commented 4 months ago

Closing this issue as the customer has come back with the fact that they have resolved it when running a maven build. "I have to put the dependency at 2 places, 1 in root pom and another in test pom. As soon as I added it, it is now able to proceed"