Skip to content

Creating selenium framework tests (abstraction for rh-che)#10191

Merged
dmytro-ndp merged 7 commits intoeclipse-che:masterfrom
ScrewTSW:226-feature-rh-che-upstream-selenium-tests-compatibility
Jul 4, 2018
Merged

Creating selenium framework tests (abstraction for rh-che)#10191
dmytro-ndp merged 7 commits intoeclipse-che:masterfrom
ScrewTSW:226-feature-rh-che-upstream-selenium-tests-compatibility

Conversation

@ScrewTSW
Copy link
Copy Markdown
Member

@ScrewTSW ScrewTSW commented Jun 26, 2018

What does this PR do?

This PR modifies some required classes and generalizes them for use outside of eclipse/che repo.
rh-che related PR : redhat-developer/rh-che/pull/721

What issues does this PR fix or reference?

redhat-developer/che-functional-tests/issues/266

@ScrewTSW ScrewTSW requested a review from vparfonov as a code owner June 26, 2018 07:48
@codenvy-ci
Copy link
Copy Markdown

Can one of the admins verify this patch?

1 similar comment
@codenvy-ci
Copy link
Copy Markdown

Can one of the admins verify this patch?

@benoitf benoitf added the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Jun 26, 2018
@codenvy-ci
Copy link
Copy Markdown

Can one of the admins verify this patch?

@ScrewTSW ScrewTSW changed the title WIP: Creating selenium framework tests (abstraction for rh-che) Creating selenium framework tests (abstraction for rh-che) Jun 26, 2018
@ScrewTSW ScrewTSW force-pushed the 226-feature-rh-che-upstream-selenium-tests-compatibility branch 2 times, most recently from 8d7e5c1 to ab33b6e Compare June 26, 2018 08:01
@ScrewTSW ScrewTSW force-pushed the 226-feature-rh-che-upstream-selenium-tests-compatibility branch from ab33b6e to 9c8de39 Compare June 26, 2018 08:56
@garagatyi
Copy link
Copy Markdown

@garagatyi
Copy link
Copy Markdown

ci-build

@codenvy-ci
Copy link
Copy Markdown

Build # 4561 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/4561/ to view the results.


bind(AbstractTestWorkspaceServiceClient.class).to(CheTestWorkspaceServiceClient.class);
//
// bind(TestWorkspaceServiceClientFactory.class).to(CheTestWorkspaceServiceClientFactory.class);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment looks redundant here.

import org.eclipse.che.selenium.core.client.TestMachineServiceClient;
import org.eclipse.che.selenium.core.client.TestOrganizationServiceClient;
import org.eclipse.che.selenium.core.client.TestOrganizationServiceClientFactory;
import org.eclipse.che.selenium.core.client.*;
Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 26, 2018

Choose a reason for hiding this comment

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

it's better to define dependencies explicitly

import org.eclipse.che.selenium.core.user.TestUser;
import org.eclipse.che.selenium.core.user.TestUserFactory;
import org.eclipse.che.selenium.core.user.TestUserImpl;
import org.eclipse.che.selenium.core.user.*;
Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 26, 2018

Choose a reason for hiding this comment

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

it's better to define dependencies explicitly

import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.ToastLoader;
import org.eclipse.che.selenium.pageobject.*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's better to define dependencies explicitly

import static org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack.BLANK;
import static org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack.DOT_NET;
import static org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack.JAVA;
import static org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace.Stack.*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's better to define dependencies explicitly

Copy link
Copy Markdown
Member Author

@ScrewTSW ScrewTSW Jun 27, 2018

Choose a reason for hiding this comment

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

You shouldn't use static imports. instead referencing the values like Stack.JAVA.
There are of course some exceptions too, though.

import org.eclipse.che.selenium.pageobject.dashboard.DocumentationPage;
import org.eclipse.che.selenium.pageobject.dashboard.NewWorkspace;
import org.eclipse.che.selenium.pageobject.dashboard.ProjectOptions;
import org.eclipse.che.selenium.pageobject.dashboard.*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's better to define dependencies explicitly

import static org.openqa.selenium.Keys.ARROW_DOWN;
import static org.openqa.selenium.Keys.ARROW_UP;
import static org.openqa.selenium.Keys.ESCAPE;
import static org.openqa.selenium.Keys.*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's better to define dependencies explicitly

import org.eclipse.che.selenium.pageobject.NotificationsPopupPanel;
import org.eclipse.che.selenium.pageobject.ProjectExplorer;
import org.eclipse.che.selenium.pageobject.ToastLoader;
import org.eclipse.che.selenium.pageobject.*;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

it's better to define dependencies explicitly

import com.google.inject.assistedinject.Assisted;
import org.eclipse.che.selenium.core.user.TestUser;

public interface CheTestWorkspaceServiceClientFactory extends TestWorkspaceServiceClientFactory {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It ought to be TestWorkspaceServiceClientFactory which produces TestWorkspaceServiceClient instance.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see but how should we then differentiate to include RhCheTestWorkspaceServiceClient or CheTestWorkspaceServiceClient ?

Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 27, 2018

Choose a reason for hiding this comment

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

Guice will substitute proper concrete class automatically depending on what is bound in the module class to the TestWorkspaceServiceClient class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So, we doesn't need this class CheTestWorkspaceServiceClientFactory if we have already had TestWorkspaceServiceClientFactory.

Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp left a comment

Choose a reason for hiding this comment

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

@ScrewTSW: I reviewed the code again and realized that there is lack of interface class TestWorkspaceClientService similar to TestUserServiceClient. In that case class hierarchy will looks like the follow:
TestWorkspaceClientService -> AbstractTestWorkspaceClientService -> CheTestWorkspaceClientService.

In that case:

  • we doesn't need to change a lot of files replacing TestWorkspaceClientService on AbstractTestWorkspaceClientService;
  • we shouldn't use CheTestWorkspaceServiceClient in the test classes explicitly so as we are binding it in the module class;
  • we should bind interface TestWorkspaceServiceClient to concrete class CheTestWorkspaceServiceClient in CheSeleniumSuiteModule.

@ScrewTSW ScrewTSW force-pushed the 226-feature-rh-che-upstream-selenium-tests-compatibility branch 3 times, most recently from d485018 to 00976a3 Compare June 27, 2018 08:00
@ScrewTSW
Copy link
Copy Markdown
Member Author

Hello @dmytro-ndp @Katka92.
I have added new interface for TestWorkspaceServiceClient and refactored the code.
Please review.

// check that name field saves it state after choosing another stack
newWorkspace.waitPageLoad();
newWorkspace.waitStackSelected(BLANK);
newWorkspace.waitStackSelected(Stack.BLANK);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please, restore static imports in this class.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

is there some specific reason the static imports are used? using static imports should be avoided.

Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jul 2, 2018

Choose a reason for hiding this comment

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

Why it should be avoided? In this case it makes the code clearer because Stack. prefix doesn't add significant info to the code.

How about restoring initial content of file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

https://carlosbecker.com/posts/avoid-static-imports/
Here's a nice article explaining the issues that may arise, when developers that have never seen the code try to contribute.
Still it's just my opinion. I can restore the class.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I agree that static imports can arise the problems, and they are actually not recommended to use in production. But here we have tests, and also there are situations when static imports make code much more readable, for example, in lambdas.
Anyway, these changes don't block merging into master, IMHO.

@@ -37,25 +33,25 @@
* @author Anatolii Bazko
*/
@Singleton
Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 27, 2018

Choose a reason for hiding this comment

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

You shouldn't apply @Singleton annotation to abstract types. It doesn't make sense.
Use it in the extending class CheTestWorkspaceProvider so that it will work.

import com.google.inject.assistedinject.Assisted;
import org.eclipse.che.selenium.core.user.TestUser;

public interface CheTestWorkspaceServiceClientFactory extends TestWorkspaceServiceClientFactory {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So, we doesn't need this class CheTestWorkspaceServiceClientFactory if we have already had TestWorkspaceServiceClientFactory.

@Named("workspace.default_memory_gb") int defaultMemoryGb,
DefaultTestUser defaultUser,
WorkspaceDtoDeserializer workspaceDtoDeserializer,
CheTestWorkspaceServiceClient testWorkspaceServiceClient,
Copy link
Copy Markdown
Contributor

@dmytro-ndp dmytro-ndp Jun 27, 2018

Choose a reason for hiding this comment

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

We can declare TestWorkspaceServiceClient and TestWorkspaceServiceClientFactory here in constructor.


install(new FactoryModuleBuilder().build(TestUserHttpJsonRequestFactoryCreator.class));
install(new FactoryModuleBuilder().build(TestWorkspaceServiceClientFactory.class));
install(new FactoryModuleBuilder().build(CheTestWorkspaceServiceClientFactory.class));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We shouldn't use CheTestWorkspaceServiceClientFactory here.

Copy link
Copy Markdown
Contributor

@Katka92 Katka92 Jun 27, 2018

Choose a reason for hiding this comment

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

Could you please shortly elaborate why? Where should we then specify to use CheTestWorkspaceServiceClientFactory?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Because TestWorkspaceServiceClientFactory should work perfectly well with CheWorkspaceServiceClient itself.

@dmytro-ndp
Copy link
Copy Markdown
Contributor

Please restore TestWorkspaceServiceClient in classes where it were replaced on CheTestWorkspaceServiceClient accidentally.

@ScrewTSW ScrewTSW force-pushed the 226-feature-rh-che-upstream-selenium-tests-compatibility branch 5 times, most recently from 8ba2ed8 to eac13d5 Compare July 2, 2018 10:11
vzhukovs and others added 2 commits July 3, 2018 10:38
Signed-off-by: Tibor Dancs <tdancs@redhat.com>

Modified TestWorkspaceProvider -> Abstraction, so that rh-che can override needed methods.

Modified TestWorkspaceServiceClient for rh-che tests extension

Abstracted TestWorkspaceServiceClient for RhChe implementation

Fixed inject issues

Signed-off-by: Tibor Dancs <tdancs@redhat.com>

Modified required abstractions, using interfaces instead of implementations of the interface (e.g. DefaultTestUser)

Modified TestWorkspaceProvider -> Abstraction, so that rh-che can override needed methods.

Fixed inject issues

Signed-off-by: Tibor Dancs <tdancs@redhat.com>
@ScrewTSW ScrewTSW force-pushed the 226-feature-rh-che-upstream-selenium-tests-compatibility branch from eac13d5 to b1a72f9 Compare July 3, 2018 08:39
@ScrewTSW
Copy link
Copy Markdown
Member Author

ScrewTSW commented Jul 3, 2018

@dmytro-ndp Becasue of the added interface, the Guice now panics, complaining that the factory needs a concrete class implementation for install(new FactoryBuilder().build(<insert factory interface class here>))

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
@dmytro-ndp
Copy link
Copy Markdown
Contributor

dmytro-ndp commented Jul 3, 2018

@ScrewTSW: please, look at my fresh fixup - it provides implementation of TestWorkspaceServiceClient inside the TestWorkspaceServiceClientFactory explicitely.

@dmytro-ndp
Copy link
Copy Markdown
Contributor

ci-test

protected void configure() {
bind(TestAuthServiceClient.class).to(KeycloakTestAuthServiceClient.class);
bind(TestMachineServiceClient.class).to(CheTestMachineServiceClient.class);
bind(TestWorkspaceServiceClient.class).to(CheTestWorkspaceServiceClient.class);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can omit binding TestWorkspaceServiceClient here so as we have already done it in CheSeleniumSuiteModule.java.

@codenvy-ci
Copy link
Copy Markdown

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:10191
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

@dmytro-ndp
Copy link
Copy Markdown
Contributor

ci-build

@dmytro-ndp
Copy link
Copy Markdown
Contributor

ci-test-docker-single

@codenvy-ci
Copy link
Copy Markdown

ci-test build report:
Build details
Test report
selenium tests report data
docker image: eclipseche/che-server:10191
https://github.com/orgs/eclipse/teams/eclipse-che-qa please check this report.

Dmytro Nochevnov added 2 commits July 4, 2018 10:54
…kTest

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
@dmytro-ndp dmytro-ndp merged commit 09671a1 into eclipse-che:master Jul 4, 2018
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Jul 4, 2018
@benoitf benoitf added this to the 6.8.0 milestone Jul 4, 2018
@codenvy-ci
Copy link
Copy Markdown

Build # 4567 - FAILED

Please check console output at https://ci.codenvycorp.com/job/che-pullrequests-build/4567/ to view the results.

hbhargav pushed a commit to hbhargav/che that referenced this pull request Dec 5, 2018
…he#10191)

* Prepairing upstream che for abstraction (rh-che tests)

Signed-off-by: Tibor Dancs <tdancs@redhat.com>

Modified TestWorkspaceProvider -> Abstraction, so that rh-che can override needed methods.

Modified TestWorkspaceServiceClient for rh-che tests extension

Abstracted TestWorkspaceServiceClient for RhChe implementation

Fixed inject issues

Signed-off-by: Tibor Dancs <tdancs@redhat.com>

Modified required abstractions, using interfaces instead of implementations of the interface (e.g. DefaultTestUser)

Modified TestWorkspaceProvider -> Abstraction, so that rh-che can override needed methods.

Fixed inject issues

Signed-off-by: Tibor Dancs <tdancs@redhat.com>

* Fixing abstraction, added interface for TestWorkspaceServiceClient

* Reverting test class imports to interfaces

* Fix installing of TestWorkspaceServiceClientFactory

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>

* removed redundant bind

* Get rid of grouping of static imports in CreateWorkspaceFromBlankStackTest

Signed-off-by: Dmytro Nochevnov <dnochevnov@codenvy.com>
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.

7 participants