galasa-dev / projectmanagement

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

Bug: Issues with loading of Galasa Managers fields #2025

Closed adamcoulthard closed 1 month ago

adamcoulthard commented 1 month ago

Describe the bug

I'm kind of hoping someone can put me out of my misery with the loading of managers because from my stepping through the code it feels like there is a fundamental issue with the way the galasa managers are loading. I hope I'm just being stupid and I'm missing something but I'm at a lose to explain what I'm seeing at the moment. In my testcase I've defined the following two ports:

    /** My Port*/
    @ZosIpPort(tag = "MYPORT")
    public int my port;

    /** Used by the WUI... */
    @ZosIpPort(tag = "MYPORT2")
    public int myport2;

Within my manager which is dependent on the z/OS manager I've done the following request:

Map<String, String> ports = this.zosManager.getTaggedPorts();

But ports is always returned as empty.... Now it gets interesting and whether I've understood the loading of managers logic correctly.

So I started to debug things because I couldn't understand why this was empty and attempted to understand how the z/OS Manager was working. Initially I put a break point into generateIpPort expecting this to get called but the break point is never hit. I started to look closer how these are all defined because I couldn't figure out how they were suppose to load up. All the "extra" annotations provided by the z/OS Manager are defined with the annotation themselves of @ZosManagerField.

When the manager is initialised it calls the function findAnnotatedFields and passes the ZosManagerField.class into this. But this always returns empty when I've debugged it and this then means the youAreRequired method isn't called because it assumes it's not required! Which means we don't say we are dependent on the IpNetworkManager.

Now going abit further on the zOSManager goes into provision generate and does some work and the last thing it calls is:

generateAnnotatedFields(ZosManagerField.class);

This calls the generateAnnotatedFields which again calls the findAnnotatedFields passing the ZosManagerField.class. So this returns empty again and we don't actually go on and generate anything.

It feels like these find / generate aren't working using these grouping annotations (@ZosManagerField) because they aren't going to find the grouped classes. Stepping through the generateAnnotatedFields I can see that the foundAnnotatedFields is empty and so we get out straight away and never generate anything.

Hopefully I'm missing something but I don't know what at the moment.

Steps to reproduce

  1. Add @ZosIpPort into your class
  2. Run the class and print the values out they will be empty when they should have been set.

Expected behavior

zOSManager fields should be initialised from the test class as expected.

adamcoulthard commented 1 month ago

I might have found what the problem is....

adamcoulthard commented 1 month ago

The problem seems to be that the ports are not defined correctly they should have been defined as IIpPort. It's a shame that there isn't some kind of checking to help with this error. But it's a mistake on my part. Have to admit I still don't really understand how the code works and picks up the correct fields but it does appear to be working.