Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce FrameworkType and set Run name of Resource Management #180

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adamcoulthard
Copy link
Contributor

@adamcoulthard adamcoulthard commented Feb 3, 2025

fixes galasa-dev/projectmanagement#2124

This is the first part of the Resource Management changes. To allow RAS directory pieces to start to work correctly this introduces the new internal FrameworkType enum at the moment that are the following enums:

  • test
  • resourceManagement
  • ecosystem
  • launcher
  • controller
  • server

Some of these could be expanded but at the moment the only two that actually mean anything are test and resourceManager. When the framework is initialised it uses these to decide what to do with the testRunName which is either set to the next run number if a test or "resourceManagement" if its the resourceManagement, otherwise no RunName is set.

@techcobweb
Copy link
Contributor

techcobweb commented Feb 5, 2025

So far in Galasa development we've been really trying hard to not make the framework know how it's being used.
Not looked at the code yet, but this is something we've been actively trying to avoid.
Any variance we've added a plug-point, and the different configurations inject a different implementation.
eg: Ras using etcd or Ras using a file.
Will look at the code and get back to you...

...some time passes...

OK. Looked at the code. It's clear we didn't follow our own advice on that one (soo inconsistent), so what you are doing isn't a huge stretch beyond what's already there.

And this PR isn't disruptive I believe.

} break;

case resourceManagement: {
this.framework.setTestRunName("resourceManagement");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This "resourceManagement" should be a symbolic literal from somewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any ideas where might be best to place this? Is there a standard location for these things? For the time being I could just add it to the FrameworkInitialisation.java.

// *** Need the DSS for this as the latest run number number is stored in there
String runName = locateRunName(this.cpsFramework);
this.framework.setTestRunName(runName);
switch(type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be worth putting this into a separate method so the overall method doesn't get any bigger.

package dev.galasa.framework;

public enum FrameworkType {
test, resourceManagement, ecosystem, launcher, controller, server
Copy link
Contributor

@techcobweb techcobweb Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TEST, RESOURCE_MANAGEMENT, ECOSYSTEM, LAUNCHER, CONTROLLER, SERVER - I always thought enums should be upper-case names. I see there are differing opinions online about this, but generally in Java I think all constants are upper-case, and enum values are constants.

What do each mean ? eg: What is an ECOSYSTEM type of framework ? Not sure that means anything to me.

Also, trying to move away from the word "ecosystem" in general anyway

What's the difference between a LAUNCHER and SERVER ?...etc.

As you don't have a need for some of these types, maybe have TEST, RESOURCE_MANAGEMENT, OTHER ? until we do need the distinctions ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did wonder about not doing them all, happy to change to these.

Copy link
Contributor

@techcobweb techcobweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you're doing. The changes don't look disruptive. Some minor points raised in the comments.

@techcobweb
Copy link
Contributor

techcobweb commented Feb 5, 2025

In some ways I wonder whether we should just pass in a TestNameAllocator(), and OverridePropertiesLoader() interface/class rather than do this, to drive the differences in behaviour. That would make for fewer branches in the code, and fewer unit tests to write generally.

Or (better still) have a FrameworkTypeStrategy interface, which gets passed in, which hides the differences between the different 'modes' of running.
eg:

public interface FrameworkInitialisationStrategy {

  /** @returns null if no testcase name needs to be set
  String getTestcaseName(cps);

  void startLoggingCapture(framework);

  Properties loadOverridePropertiesFromDss(dss);
 
  ...etc.
}

We could just have a Test implementation, and a ResourceManager implementation, and a default implementation.

We could also extract some code out of the initialiser class which is specific to Test initialisation, or resource manager initialisation..etc. eg: locateRunName()

Is it important for your future plans that the type lives beyond the initialisation of the framework, to provide different behaviour? Like what ?...

@techcobweb
Copy link
Contributor

techcobweb commented Feb 5, 2025

Also, unit testing... any scope for some unit tests at all here ?

If unit testing can be done without relying on any framework, just straight Java old-school way, then we lessen our dependencies also.

The unit testing gets easier if we inject a strategy, and unit test that each implementation of the strategy does what it's supposed to independently of the base framework code.

@techcobweb
Copy link
Contributor

@adamcoulthard Thanks for the PR to look at. Comments above. Happy to talk about anything I've written there.

@adamcoulthard
Copy link
Contributor Author

@techcobweb there is no reason for anything to live on. The only reason really for this change is to allow me to set the testName for the resourceManager and prior to these changes I couldn't do it. This allows the managers to be able to initialise their Ras Providers correctly.

I think longer term we probably want to look at the managers and how the RAS stuff works so that we can make a null RAS provider that just "swallows" everything. But I've not really understood full how all the RAS stuff hangs together and was a lot more nervous about making changes in that area than this simple fix now. With potential enhancing in the future.

I would probably agree that doing something slight different to all this would make sense but I was worried about over complicating the startup. Its already difficult to weave though and I thought more indirection would make things worse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to access managers during Resource Management
2 participants