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

Update unit test dependencies #2068

Conversation

benjaminapetersen
Copy link
Contributor

@benjaminapetersen benjaminapetersen commented Sep 13, 2017

https://trello.com/c/w3vdwj85

Updates karma related dependencies for unit testing.

screen shot 2017-09-13 at 3 12 37 pm

Looking into why a few tests now fail, will update again shortly (did we always have this pretty coverage tool?)(is a lot of red reported by that pretty coverage tool 😄 ).

to fix:

  • one of the updates, probably jasmine, is more strictly comparing objects than previously, resulting in some tests failing.
  • the coverage table is being output twice since I'm running the tests in Firefox & Chrome concurrently by default. This is a little annoying.

@spadgett

@benjaminapetersen
Copy link
Contributor Author

I these tests are failing because they are a little sloppy, basically json1 === json2. There are new properties added to the objects. I'll try to make them specific & fix.

@spadgett
Copy link
Member

spadgett commented Sep 13, 2017

@benjaminapetersen Awesome.

The errors are because

{foo: undefined}

is not equal to

{}

We're explicitly setting some fields to undefined in the services.

@spadgett
Copy link
Member

@benjaminapetersen
Copy link
Contributor Author

@spadgett thanks! I didn't see your comment until my last push, but let me know your thoughts on this. I updated the tests (where they now fail) to break them down into very specific parts. If there is a failure, its focused on a single value or an object of much smaller complexity. Pros and cons:

  • much easier to diagnose a failure & make a change
  • harder to see what the overall structure is supposed to be

I think the pros outweigh the cons since I always end up running the functions and console.log(JSON.stringify(someMethod.getBigBlobOutput())) anyway.

Another potential con, I got around the sudden missing namespace property causing the failures by ignoring the property. This is potentially bad. Is this the only case where a new property might get added? Is it appropriate to rely on tests to catch that, or should we update the tests by adding another test for the property if the property is important.

Def open to your thoughts & further adjustments.
Protractor (e2e) updates coming in a separate PR.

@benjaminapetersen
Copy link
Contributor Author

[test]

@benjaminapetersen
Copy link
Contributor Author

Ooop, forgot to drop Chrome from the list.

[test]

@spadgett
Copy link
Member

@benjaminapetersen I agree it makes it easier to diagnose failures, but I worry the tests are now passing with "bad" data. namespace: undefined should not be there. If we don't check the complete objects, we'll let things we're not checking for through. Another common problem would be not stripping $$foo angular values from the objects before we send them to the API. If we don't test the full object, we'll miss stuff like that.

I'd rather fix the services not to set undefined values in the objects. That to me seems like the bug.

There are also things like

https://www.npmjs.com/package/karma-jasmine-diff-reporter

to better see what the diff is. That seems cleaner to me than rewriting our tests.

@benjaminapetersen
Copy link
Contributor Author

Agreed, I'll try that diff reporter & update this. Curious if there is a good argument for both, the more explict test next to the blob comparison.

@benjaminapetersen
Copy link
Contributor Author

Opened an issue with that reporter, the installation instructions are either incomplete or something is broken. reporter issue

@benjaminapetersen
Copy link
Contributor Author

Ok, since that diff reporter doesn't work, I kept both versions of the test. Hopefully will be short term, but I really dislike debugging these as blob vs blob. Will try to make progress on that issue as a follow-up.

Meanwhile, this will get unit test dependencies 100% current, would like to get back to protractor for e2e & get that working on Mac.

[test]

expect(resources.buildConfig).toEqual(
var generatedBuildConfig = resources.buildConfig;

// specific tests to ease pain in debugging
Copy link
Member

Choose a reason for hiding this comment

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

In the long run, these are going to make the tests harder to maintain. We've repeated everything twice, and it's a lot of work to write these. I'm not sure it's worth the tradeoff.

Copy link
Member

@spadgett spadgett Sep 15, 2017

Choose a reason for hiding this comment

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

@benjaminapetersen I'd rather not test the same things twice. Since we have the diff reporter, let's remove this.

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 diff reporter states this is legacy behavior. Boo. I'm working on getting more info from the developer. It may mean that he isn't supporting it anymore. Mind if I hold off on deleting the code till I have a good answer? I hate to update all our dependencies just to end up with a deprecated dependency that will fall over on us again. Hopefully will get an answer soon.

@benjaminapetersen
Copy link
Contributor Author

flake?

+ ssh -F ./.config/origin-ci-tool/inventory/.ssh_config -t openshiftdevel 'bash -l -c "timeout 300 /tmp/tmp.jjTPwTJqTB"'
+ cd /data/src/github.com/openshift/aos-cd-jobs
+ trap 'exit 0' EXIT
+ sjb/gcs/started.py
++ exit 0
++ export status=FAILURE
++ status=FAILURE
+ set +o xtrace
########## FINISHED STAGE: FAILURE: RECORD THE STARTING METADATA [00h 05m 00s] ##########
Build step 'Execute shell' marked build as failure
[PostBuildScript] - Execution post build scripts.
[workspace] $ /bin/bash /tmp/jenkins8090829258080536932.sh

[test]

@benjaminapetersen
Copy link
Contributor Author

Fail cuz Firefox:

Running "karma:unit" (karma) task
14 09 2017 21:54:48.085:ERROR [launcher]: Cannot start Firefox
	
14 09 2017 21:54:48.087:ERROR [launcher]: Firefox stdout: 
14 09 2017 21:54:48.087:ERROR [launcher]: Firefox stderr: 
14 09 2017 21:54:48.088:ERROR [launcher]: Firefox failed 2 times (cannot start). Giving up.
Warning: Task "karma:unit" failed.� Use --force to continue.

Aborted due to warnings.


Execution Time (2017-09-15 01:54:25 UTC)
loading tasks    364ms  ▇ 2%
concurrent:test   5.4s  ▇▇▇▇▇▇▇▇▇▇▇ 24%
postcss:dist     677ms  ▇▇ 3%
karma:unit       16.3s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 71%
Total 22.8s

make: *** [test] Error 3
++ export status=FAILURE
++ status=FAILURE
+ set +o xtrace
########## FINISHED STAGE: FAILURE: RUN WEB CONSOLE TESTS [00h 06m 46s] ##########

Good grief. Specified older FF in Travis similar to catalog 432.

[test], plz.

@benjaminapetersen
Copy link
Contributor Author

Travis does not appear to honor the browsers flag in our .travis.yml:

language: node_js
node_js:
  - "6"
before_script:
  - make build
script:
  - grunt test --browsers=PhantomJS # hmmm.
  - hack/verify-dist.sh
addons:
  firefox "49.0"

@benjaminapetersen
Copy link
Contributor Author

Trying Nightmare because Firefox is being that anyway...

[test]

@spadgett
Copy link
Member

Good grief. Specified older FF in Travis similar to catalog 432.

@benjaminapetersen I think you need a virtual screen. Let's try with current Firefox.

before_script:
  - export DISPLAY=:99.0
  - sh -e /etc/init.d/xvfb start

@benjaminapetersen
Copy link
Contributor Author

Figured out the config tweak to get the diff reporter to work:

screen shot 2017-09-15 at 10 16 22 am

Requires "legacy: true" flag because Jasmine has its own diff now, but the built-in diff I'm seeing is not awesome. Fishing around to see if we need to worry about legacy mode.

@benjaminapetersen
Copy link
Contributor Author

@spadgett I'll add that, though its odd that unit testing would require a window. Lets see.

@benjaminapetersen
Copy link
Contributor Author

@spadgett We had caching of node modules between updates didn't we? Seems like testing is taking longer again.

@spadgett
Copy link
Member

Running "karma:unit" (karma) task
15 09 2017 10:42:43.235:ERROR [launcher]: Cannot start Nightmare
	
15 09 2017 10:42:43.237:ERROR [launcher]: Nightmare stdout: 
15 09 2017 10:42:43.237:ERROR [launcher]: Nightmare stderr: 
15 09 2017 10:42:43.416:ERROR [launcher]: Cannot start Nightmare
	
15 09 2017 10:42:43.416:ERROR [launcher]: Nightmare stdout: 
15 09 2017 10:42:43.416:ERROR [launcher]: Nightmare stderr: 
15 09 2017 10:42:43.592:ERROR [launcher]: Cannot start Nightmare
	
15 09 2017 10:42:43.593:ERROR [launcher]: Nightmare stdout: 
15 09 2017 10:42:43.593:ERROR [launcher]: Nightmare stderr: 
15 09 2017 10:42:43.593:ERROR [launcher]: Nightmare failed 2 times (cannot start). Giving up.
Warning: Task "karma:unit" failed.� Use --force to continue.

@spadgett
Copy link
Member

spadgett commented Sep 15, 2017

@benjaminapetersen We don't cache dependencies anymore, but it doesn't make that big of a difference. Most of the time is spent elsewhere.

Test job usually takes about 20-30 minutes.

@benjaminapetersen
Copy link
Contributor Author

Swapping back Firefox for Nightmare. Works fine locally, should use FF for Travis.

@spadgett
Copy link
Member

Looks like Jenkins has the same Firefox error as Travis

@benjaminapetersen
Copy link
Contributor Author

Swapping to ['PhantomJS'] from ['Firefox'] temporarily just to see if we can get something to run.

@stevekuznetsov I may request some assistance from you diagnosing my Firefox dilemma if this doesn't work.

@benjaminapetersen
Copy link
Contributor Author

Adding a sleep 3 to .travis.yml to give xvfb time to start. maybe timing issue? Is what we did originally with key-value-editor to get it working.

@spadgett
Copy link
Member

Looks like unit tests ran in Jenkins, but later starting protractor we get this:

Error: No selenium server jar found at the specified location (/data/src/github.com/openshift/origin-web-console/node_modules/grunt-protractor-runner/node_modules/protractor/selenium/selenium-server-standalone-2.45.0.jar). Check that the version number is up to date.

package.json Outdated
"protractor": "1.7.0",
"protractor-screenshot-reporter": "0.0.5",

"protractor": "^5.1.2",
Copy link
Member

Choose a reason for hiding this comment

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

Did you mean to bump protractor in this pull? I thought other changes were needed for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, crap, my last swap between branches must have accidentally committed that, thanks. Will update and see where that gets us.

package.json Outdated
@@ -69,6 +84,7 @@
"serve": "grunt serve",
"start": "grunt serve",
"test-integration": "grunt test-integration",
"postinstall": "node test/upgrade-selenium.js && node_modules/protractor/bin/webdriver-manager update"
"__postinstall": "node test/upgrade-selenium.js && node_modules/protractor/bin/webdriver-manager update",
"_postinstall": "node_modules/protractor/bin/webdriver-manager update"
Copy link
Member

Choose a reason for hiding this comment

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

This might be causing the Jenkins failure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same as above, putting this back.

@benjaminapetersen
Copy link
Contributor Author

Ok put the protractor stuff back, lets see if this test runs.

@spadgett
Copy link
Member

FINISHED STAGE: FAILURE: PROVISION CLOUD RESOURCES [00h 10m 20s]

[test]

@benjaminapetersen
Copy link
Contributor Author

Yay Jenkins survived this time. Now for Travis...

@spadgett
Copy link
Member

Looks like the previous Travis run worked, but now it's stuck.

.travis.yml Outdated
# even our unit tests require a
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3 # give xvfb some time to start
Copy link
Member

Choose a reason for hiding this comment

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

We should be able to remove this if we're using PhantomJS (for now anyway)

Copy link
Contributor Author

@benjaminapetersen benjaminapetersen Sep 15, 2017

Choose a reason for hiding this comment

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

I will comment out all of this display stuff & leave another FIXME (& note it in the issue)

Copy link
Member

Choose a reason for hiding this comment

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

I will comment out all of this display stuff & leave another FIXME (& note it in the issue)

I'd rather just remove it to keep the code tidy :)

We could add this to the issue if necessary.

Gruntfile.js Outdated
// if running locally on mac, we can test both FF & Chrome,
// in Travis, just FF
// ['Nightmare'] is a good alt for a current headless
// TODO: fix this, PhantomJS is deprecated
Copy link
Member

Choose a reason for hiding this comment

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

Let's track as an issue instead of a TODO in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok ill update to FIXME & open an issue.

Copy link
Member

Choose a reason for hiding this comment

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

I'd remove the comment altogether and just use the issue. I'd prefer to track things once, and TODOs tend to get forgotten

],

// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,

colors: true,
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to try and add colors back?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup can do.


// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_DEBUG,
logLevel: config.LOG_ERROR,
Copy link
Member

Choose a reason for hiding this comment

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

Any specific reason to change this from debug?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was just noisy, was trying to cut down on stuff to swim through. Let me roll that back.

@benjaminapetersen
Copy link
Contributor Author

Ok, so we had one successful run? Pushing updates per the comments &...

[test]

again.

@benjaminapetersen
Copy link
Contributor Author

Travis hangs again. I sad. ☹️

kid-throws-fit

[test]

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

LGTM, but please squash. Thanks @benjaminapetersen, happy to see these updated

@benjaminapetersen
Copy link
Contributor Author

OOoooo it worked. neato. Will squash soon & be glad to be ready to roll with this.

@stevekuznetsov
Copy link
Contributor

Looks like it may have been in the Travis queue for a while there.

@benjaminapetersen benjaminapetersen force-pushed the bpetersen/unit-test-dependency-udpates branch from 3eb08a0 to 9d1c673 Compare September 16, 2017 01:19
@benjaminapetersen benjaminapetersen force-pushed the bpetersen/unit-test-dependency-udpates branch from 9d1c673 to 91fe691 Compare September 16, 2017 01:21
@benjaminapetersen
Copy link
Contributor Author

benjaminapetersen commented Sep 16, 2017

Squashed.

[test]

Btw, I had to swap back logLevel: config.LOG_ERROR, from LOG_DEBUG as there is so much noise from all the file loading that it causes the tests to flake at times (locally, and it overwhelms the meaningful test output).

@spadgett
Copy link
Member

Origin Web Console Test Results: FAILURE (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_web_console/214/) (Base Commit: 5bf079c) (PR Branch Commit: 91fe691)

flake #1685

[test]

@openshift-bot
Copy link

Evaluated for origin web console test up to 91fe691

@openshift-bot
Copy link

Origin Web Console Test Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_request_origin_web_console/216/) (Base Commit: 5bf079c) (PR Branch Commit: 91fe691)

@spadgett
Copy link
Member

[merge]

@openshift-bot
Copy link

Evaluated for origin web console merge up to 91fe691

@openshift-bot
Copy link

openshift-bot commented Sep 16, 2017

Origin Web Console Merge Results: SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_request_origin_web_console/205/) (Base Commit: 1466f66) (PR Branch Commit: 91fe691)

@openshift-bot openshift-bot merged commit 1b695d8 into openshift:master Sep 16, 2017
@benjaminapetersen benjaminapetersen deleted the bpetersen/unit-test-dependency-udpates branch September 16, 2017 20:32
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.

None yet

4 participants