-
Notifications
You must be signed in to change notification settings - Fork 622
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
Add plugin integration tests to protractor #2051
Add plugin integration tests to protractor #2051
Conversation
@rhrazdil @mareklibra @vojtechszocs @suomiy @rawagner this is a poc for adding integration tests in the plugin namespace, please review. @rhrazdil @vojtechszocs does that make sense ? |
@yaacov I like this idea. |
@spadgett PTAL, This PR moves plugin integration tests into the plugin directory, and automating the tests registration. |
@yaacov It is common that plugin-specific tests depend on views defined in the core integration_tests directory. I suppose it will be still possible to import stuff from the common integration-tests directory, am I right? |
@rhrazdil I did not try all the use cases, I was able to import types, const and views from the core tests ... and it worked for my tests. |
@spadgett hi, removed the POC , because we (@rhrazdil and me ) like the idea of having plugin tests in plugin package. @vojtechszocs @spadgett please review, does that makes sense to you ? do you see a use case where this approach if problematic, and need some changes ? |
@@ -20,6 +21,8 @@ const browserLogs: logging.Entry[] = []; | |||
|
|||
const suite = (tests: string[]) => (!_.isNil(process.env.BRIDGE_KUBEADMIN_PASSWORD) ? ['tests/login.scenario.ts'] : []).concat(['tests/base.scenario.ts', ...tests]); | |||
|
|||
const pluginSuites = _.mapValues(pluginsIntegrationTests(), (tests:string[]) => suite(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.
@yaacov I just realized, what if a test suite of some plugin needs to have a test spec that has to run before base.scenario.ts
? In kubevirt case, it is the kubevirt.login.scenario.ts
that logs in and is a prerequisite for the base.scenario.ts
to create a test namespace. So login needs to happen before the base.scenario.ts
.
For that reason I think we cannot the suite()
wrapper and plugin specific suite will need to specify the path to this file in their suite.
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.
👍 Thanks !
Removed the automatic suite()
and added an option to call explicitly call @console/integration-tests/
Overall, I think this is a great idea 👍 it's also in-line with our plan to move all frontend code (including unit & integration tests) into the monorepo structure. To reference code in root Each Console plugin could add one or more test suites, so it'd be nice to give them names: "consolePlugin": {
"entry": "src/plugin.tsx",
"integrationTests": {
// Q: do we also need the ability to reference base scenarios in integration-tests/tests?
"kubevirt": ["integration-tests/kubevirt.login.scenario.ts", "integration-tests/kubevirt.scenario.ts"]
}
} In terms of Console plugins used, integration tests should use the same active plugin resolution as unit tests ( # kubevirt-plugin is active by default, so this should work:
yarn run test-suite --suite kubevirt
# this should work as well, active_plugins = [app, kubevirt-plugin]
CONSOLE_PLUGINS=kubevirt-plugin yarn run test-suite --suite kubevirt
# this should fail, active_plugins = [app, dev-console]
CONSOLE_PLUGINS=dev-console yarn run test-suite --suite kubevirt I'll get back to this after the 🌴 holiday. |
2844aa3
to
b11586d
Compare
b11586d
to
affe646
Compare
@vojtechszocs thanks for the thorough review ❤️ a - added a @rhrazdil @mareklibra @vojtechszocs @suomiy @rawagner please review. |
/retest |
88f9a30
to
162c392
Compare
/test e2e-aws |
7589861
to
fd12552
Compare
/test e2e-aws |
@yaacov Indeed, we will want to reference |
/test e2e-gcp-console |
@rhrazdil hi, After offline discussion with @vojtechszocs we will remove the Reasons: b - It will resolve confusion about what |
3645977
to
b969eea
Compare
Once this PR gets merged, we can move remaining files in
To keep things simple, each suite array value should be treated as a path relative to In fact, I'd suggest that every Console plugin follows the standard convention for integration tests, reflected through the glob pattern: "consolePlugin": {
"entry": "src/plugin.tsx",
"integrationTestSuites": {
"foo": ["integration-tests/**/*.scenario.ts"]
}
} Console monorepo is a flat structure - to reference files outside the current plugin, we can do: "foo": [
"../console-app/integration-tests/tests/**/*.some.scenario.ts",
"integration-tests/**/*.scenario.ts"
] However, adding consistent (glob-aware) support for module paths, e.g.
would complicate the implementation. Again, I would try to keep things simple.
Please note that this PR applies the That said, it's perfectly OK to use relative paths like:
|
/test e2e-aws-console-olm |
/test e2e-gcp |
@yaacov Can you please rebase? 😇 |
b969eea
to
5e807cf
Compare
@vojtechszocs rebased :-) |
Thank you! @spadgett @christianvogt Is it OK to proceed with this PR? |
/test e2e-gcp-console |
@spadgett @christianvogt Please let us know if the PR looks good to you. |
name, | ||
version, | ||
readme: '', | ||
_id: `${name}@${version}`, |
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 cannot find where _id
is being used.
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.
@christianvogt , hi, thank you for the review, I think it comes from https://github.com/npm/normalize-package-data.
# ./build.sh
...
ERROR in /home/yzamir/go/src/github.com/openshift/console/frontend/packages/console-plugin-sdk/src/codegen/__tests__/plugin-resolver.spec.ts
(10,14): Type 'Readonly<{ name: string; version: string; readme: string; }>' is not assignable to type 'NormalizedPackageJson'.
Property '_id' is missing in type 'Readonly<{ name: string; version: string; readme: string; }>' but required in type 'Package'.
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.
Got it. Thanks!
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.
@christianvogt Just a note, the leading _
in the newly added _path
property is a convention to indicate that this property is computed, similar to the _id
.
@@ -88,11 +105,14 @@ export const resolvePluginPackages = ( | |||
return pluginFilter(appPackage, pluginPackages); | |||
}; | |||
|
|||
export type Package = readPkg.NormalizedPackageJson; | |||
export type Package = readPkg.NormalizedPackageJson & { | |||
_path: string; |
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.
underscore dangle :(
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.
@christianvogt , hi,
we discussed this in #2051 (comment) :-)
will be happy to revert @vojtechszocs ?
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.
No need to revert. I'm good with this.
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.
underscore dangle :(
This one is intentional, please see #2051 (comment)
I think this looks good. |
@vojtechszocs hi, do we need to ping someone ? |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt, yaacov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
Currently plugins need to manually add integration tests to
protractor.conf.ts
file.This PR add the infrastructure to add integration tests by using the plugin's
package.json
file.package.json
- "consolePlugin" field.@console/internal-integration-tests
tests.Usage:
package.json
Running the command:
If plugin is active, this test will run
tests/base.scenario.ts
from@common/internal-integration-tests
package and then.../kubevirt-plugin/integration-tests/index.scenario.ts
integration test.Example
Run the bridge without authentication:
Enable the demo plugin and run the demo plugin integration test:
Screencast:
