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

WS master should send plugin IDs instead of plugins metas to unified broker #12998

Merged
merged 1 commit into from
Apr 16, 2019

Conversation

amisevsk
Copy link
Contributor

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

@amisevsk amisevsk requested a review from garagatyi March 28, 2019 06:05
Copy link

@garagatyi garagatyi left a 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 {

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)

@garagatyi
Copy link

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

@amisevsk
Copy link
Contributor Author

amisevsk commented Apr 5, 2019

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.

@amisevsk
Copy link
Contributor Author

amisevsk commented Apr 5, 2019

For testing, images amisevsk/che-unified-plugin-broker:v0.15.2 and amisevsk/che-init-plugin-broker:v0.15.2 can be used.

Copy link
Member

@sleshchenko sleshchenko left a 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";
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Member

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.

Copy link
Contributor Author

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,
Copy link
Member

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.

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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")
Copy link
Member

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.

Copy link
Contributor Author

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(" *, *");
Copy link
Member

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);
  }

Copy link
Contributor Author

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) {
Copy link
Member

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

Copy link
Contributor Author

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() {
Copy link
Member

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.

Copy link
Contributor Author

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.

@amisevsk
Copy link
Contributor Author

amisevsk commented Apr 5, 2019

ci-test

@che-bot
Copy link
Contributor

che-bot commented Apr 5, 2019

Results of automated E2E tests of Eclipse Che Multiuser on OCP:
Build details
Test report
docker image: eclipseche/che-server:12998
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@amisevsk
Copy link
Contributor Author

Waiting on a release of Che plugin broker to mirror the necessary changes.

Do not merge

@sleshchenko sleshchenko changed the title WS master should send plugin IDs instead of plugins metas to unified broker WIP WS master should send plugin IDs instead of plugins metas to unified broker Apr 11, 2019
@sleshchenko sleshchenko changed the title WIP WS master should send plugin IDs instead of plugins metas to unified broker WS master should send plugin IDs instead of plugins metas to unified broker Apr 11, 2019
@garagatyi
Copy link

@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>
@amisevsk
Copy link
Contributor Author

@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.

@amisevsk amisevsk merged commit 0adb360 into eclipse-che:master Apr 16, 2019
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.

4 participants