-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
WS master should send plugin IDs instead of plugins metas to unified broker #12998
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
} | ||
|
||
@Test | ||
public void shouldParseAllPluginsAndEditor() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that you took these cases from another test class. But could you rework this test to test with data provider? It would looks way simpler and could include all the non exception cases like what you have in shouldReturnEmptyListWhenNoPluginsOrEditors
.
Apart from making code more concise and simplify its support you could split cases where different bugs would not fail the same test case as it is now with this test.
E.g.
- case with registry
- case with registry that has path /plugins
- case with registry that has path not equal /plugins
- case with registry that has multi-level path
- case without registry
- case with null editor
- case with null plugins
- case with multiple plugins
- etc
To simplify matching of results you can use assertEqualsnoOrder(actual.toArray(), expected.toArray())
(please excuse not precise names of methods if any)
Please take into account that after merging this PR we will need to adapt RhChe https://github.com/redhat-developer/rh-che/pull/1192/files#diff-d1c7cee2e326bd168cb76031bef4ef0cR197 |
Marked as ready for review since it works with locally built plugin-broker, but should not be released until eclipse-che/che-plugin-broker#46 is merged and a new image is available. |
For testing, images |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me.
Please take a look my inline comments
@@ -65,10 +67,10 @@ | |||
@Beta | |||
public abstract class BrokerEnvironmentFactory<E extends KubernetesEnvironment> { | |||
|
|||
private static final String CONFIG_MAP_NAME_SUFFIX = "broker-config-map"; | |||
@VisibleForTesting protected static final String CONFIG_MAP_NAME_SUFFIX = "broker-config-map"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be protected for testing? Maybe package private will be enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, moved to package private.
@@ -106,7 +111,7 @@ public BrokerEnvironmentFactory( | |||
* @return kubernetes environment (or its extension) with the Plugin broker objects | |||
*/ | |||
public E create( | |||
Collection<PluginMeta> pluginsMeta, RuntimeIdentity runtimeID, BrokersResult brokersResult) | |||
Collection<PluginFQN> pluginFQNs, RuntimeIdentity runtimeID, BrokersResult brokersResult) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update java doc according to your changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I see it is not related to this PR, but it would be cool if you fix it: brokersResult is unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated java doc and removed brokersResult -- good catch that must be leftover from the merging of brokers.
@@ -87,13 +90,15 @@ public BrokerEnvironmentFactory( | |||
AgentAuthEnableEnvVarProvider authEnableEnvVarProvider, | |||
MachineTokenEnvVarProvider machineTokenEnvVarProvider, | |||
@Named("che.workspace.plugin_broker.unified.image") String unifiedBrokerImage, | |||
@Named("che.workspace.plugin_broker.init.image") String initBrokerImage) { | |||
@Named("che.workspace.plugin_broker.init.image") String initBrokerImage, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just want to mention that this class is abstract and using @Inject
and @Named
do nothing.
I'm OK with leaving it since it may be used as a recommendation for implementations. But on another hand, it's one more place where these values for @Named
are copied/pasted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tha's what I get for writing code to fit what's already there :)
Removed annotations.
@Beta | ||
public class PluginFQNParser { | ||
|
||
public Collection<PluginFQN> parsePlugins(Map<String, String> attributes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's a public method it would be good to have few lines as java doc here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added docs
|
||
@Test( | ||
expectedExceptions = InfrastructureException.class, | ||
expectedExceptionsMessageRegExp = "Invalid.*duplicated") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The full expected message is String.format("Invalid Che tooling plugins configuration: plugin %s:%s is duplicated", ...)
and I think it makes sense to check full message to make sure that message is formatted correctly (message contains ID:VERSION
but not other values). I started to ask it after I saw that Che Server respond with errors where messages are wrong formatted, and it's pretty easy to make mistake here especially during refactoring.
WDYT?
It makes less sense to check the full message that is not formatted but still makes sense. It's like double fields for putting a password (password, confirm password). Also, if the message becomes formatted - then the author should change tests accordingly, otherwise it would be changed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it makes sense, I usually default to keeping the match as general as possible (only to ensure exception is being thrown for the right reason) but validating that plugin id and version are included makes a lot of sense.
|
||
List<PluginFQN> metaFQNs = new ArrayList<>(); | ||
if (!isNullOrEmpty(pluginsAttribute)) { | ||
String[] plugins = pluginsAttribute.split(" *, *"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*, *
makes sure that empty spaces will be removed between plugins but it does not remove empty spaces before the first plugin and after the last plugin. Maybe it would be safer to split by ,
and then trim split values.
@Test(
expectedExceptions = InfrastructureException.class,
expectedExceptionsMessageRegExp = "Invalid.*duplicated")
public void shouldDetectDuplicatedPluginsIfTheyArePrefixedSuffixedWithEmptySpaces() throws Exception {
Map<String, String> attributes =
createAttributes(
"",
" " + formatPlugin("http://testregistry1:8080", "testplugin", "1.0"),
formatPlugin("http://testregistry2:8080", "testplugin", "1.0") + " ");
parser.parsePlugins(attributes);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch -- done. And thanks for the test case, I've added it to the suite.
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add toString
as well. It may be useful in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -53,4 +57,28 @@ public String getVersion() { | |||
public void setVersion(String version) { | |||
this.version = version; | |||
} | |||
|
|||
@Override | |||
public int hashCode() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hashCode
might look simpler like
@Override
public int hashCode() {
return Objects.hash(getRegistry(), getId(), getVersion());
}
But I'm OK with current way as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pitfalls of auto-generated code. Fixed.
bbe85d2
to
53a9065
Compare
ci-test |
Results of automated E2E tests of Eclipse Che Multiuser on OCP: |
Waiting on a release of Che plugin broker to mirror the necessary changes. Do not merge |
@amisevsk I see that there is a release with necessary changes but it is done manually instead of by CI and container image is not pushed to Docker hub. Do you plan to push them? Do you need help with that? |
…tas. Instead of downloading metas from plugin registry and passing them to plugin broker, provide plugin broker with serialized plugin fully qualified names and allow broker to download necessary metas. Signed-off-by: Angel Misevski <amisevsk@redhat.com>
53a9065
to
0516bd2
Compare
@garagatyi Thanks for the help, I couldn't figure out the CI backing plugin-broker releases. Bumped broker version in che.properties, squashed all commits, and rebased on current master. Tested locally and everything works with FQN changes. |
What does this PR do?
Makes ws master send plugin FQNs to broker instead of downloaded meta.yamls.
Draft PR until eclipse-che/che-plugin-broker#40 is merged.
What issues does this PR fix or reference?
redhat-developer/rh-che#1307; related to #12908