Project

Profile

Help

Task #7106

Refactor def self.show(name)

Added by Mark Zaslavskiy about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
High
Category:
mdbci features
Sprint/Milestone:
Start date:
23.06.2016
Due date:
% Done:

100%

Estimated time:
3:00 h
Spent time:
Target branch:
Test scenario:

# 1. Create configuration. Should create dir with config.
./mdbci --template confs/docker_lite.json generate SOME_DIR
./mdbci --template confs/libvirt_lite.json generate SOME_DIR2

# 2. Up node\nodes. Result: in SOME_DIR "vagrant status" should write running machines.
./mdbci up SOME_DIR2

# 3. Print node\nodes IP. NOTE: if some node stopped, function will raise error.
./mdbci show network SOME_DIR
./mdbci show network SOME_DIR2

# 4. Run tests for function. All tests must passed, and echo $?=>0.
pathToStoppedConfigToNode=SOME_DIR pathToConfigToNode=SOME_DIR2 rspec spec/unit/7106_refactor_def_self.show_spec.rb


Description

https://github.com/OSLL/mdbci/blob/4a68ae9f1f9c8bf3f45cb622607e751a2466e1b8/core/network.rb#L112

Function:
- should not contain code duplications
- should work with arguments in transparently way (for exmaple - all args[i] should be replaced for human readable and understandable name)
- exit code magic should be converted to raise
- split for two functions:
-- the first which returns its result as string in return
-- the second just wraps first and print it to $out.out
- add integration test for the whole command "show network"

Please use name getNetwork for refactored function!


Related issues

Related to [mdbci] Maria DB Continuous integration tool - Task #7102: Collect info from set_environment during mdbci up and put it to text file in case of successful upClosed22.06.2016

<a title="Actions" class="icon-only icon-actions js-contextmenu" href="#">Actions</a>

History

#1 Updated by Mark Zaslavskiy about 4 years ago

  • Related to Task #7102: Collect info from set_environment during mdbci up and put it to text file in case of successful up added

#2 Updated by Mark Zaslavskiy about 4 years ago

  • Assignee set to Tatyana Berlenko

#3 Updated by Mark Zaslavskiy about 4 years ago

  • Sprint/Milestone changed from 0.83 to 0.9

#4 Updated by Mark Zaslavskiy about 4 years ago

  • Assignee changed from Tatyana Berlenko to Ilfat Kinyaev

#5 Updated by Ilfat Kinyaev about 4 years ago

  • Estimated time set to 3:00 h

#6 Updated by Mark Zaslavskiy about 4 years ago

  • Description updated (diff)

#7 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from New to Active / In progress

#9 Updated by Ilfat Kinyaev about 4 years ago

  • Test scenario updated (diff)

#10 Updated by Ilfat Kinyaev about 4 years ago

  • % Done changed from 30 to 70
  • Test scenario updated (diff)

#11 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from Active / In progress to Review
  • Assignee changed from Ilfat Kinyaev to Mark Zaslavskiy
  • % Done changed from 70 to 100
  • Test scenario updated (diff)

#13 Updated by Mark Zaslavskiy about 4 years ago

Unittest failed

vagranttest@maxscale-jenkins:~/mdbci_zaslavskiy$ pathToStoppedConfigToNode=SOME_DIR pathToConfigToNode=SOME_DIR2 rspec spec/unit/7106_refactor_def_self.show_spec.rb
FF...

Failures:

1) Session #network should return IP for nodes
Failure/Error: expect { Network.show(ENV['pathToConfigToNode']) }.to output(/.+\..+\..+\..+/).to_stdout
RuntimeError:
Incorrect node # ./core/network.rb:188:in `rescue in getIpWrapper' # ./core/network.rb:185:in `getIpWrapper' # ./core/network.rb:172:in `block in getNetwork' # ./core/network.rb:171:in `each' # ./core/network.rb:171:in `getNetwork' # ./core/network.rb:128:in `show' # ./spec/unit/7106_refactor_def_self.show_spec.rb:30:in `block (3 levels) in &lt;top (required)&gt;' # ./spec/unit/7106_refactor_def_self.show_spec.rb:30:in `block (2 levels) in &lt;top (required)&gt;'
2) Session #network should raise not running nodes
Failure/Error: lambda{Network.show(ENV['pathToStoppedConfigToNode'].to_s)}.should(raise_error('Incorrect node'))
expected Exception with "Incorrect node", got #&lt;RuntimeError: Configuration not found: SOME_DIR&gt; with backtrace:
         # ./core/network.rb:165:in `getNetwork'
         # ./core/network.rb:128:in `show'
         # ./spec/unit/7106_refactor_def_self.show_spec.rb:34:in `block (3 levels) in &lt;top (required)&gt;'
         # ./spec/unit/7106_refactor_def_self.show_spec.rb:34:in `block (2 levels) in &lt;top (required)&gt;'
     # ./spec/unit/7106_refactor_def_self.show_spec.rb:34:in `block (2 levels) in &lt;top (required)&gt;'

Finished in 4.2 seconds (files took 0.16664 seconds to load)
5 examples, 2 failures

Failed examples:

rspec ./spec/unit/7106_refactor_def_self.show_spec.rb:29 # Session #network should return IP for nodes
rspec ./spec/unit/7106_refactor_def_self.show_spec.rb:33 # Session #network should raise not running nodes

#14 Updated by Mark Zaslavskiy about 4 years ago

  • Status changed from Review to New
  • Assignee changed from Mark Zaslavskiy to Ilfat Kinyaev

#15 Updated by Ilfat Kinyaev about 4 years ago

Same problem when generated templates is not success up.
NOTE: docker not up's.

#17 Updated by Ilfat Kinyaev about 4 years ago

  • % Done changed from 100 to 70

#18 Updated by Ilfat Kinyaev about 4 years ago

Up configs with integration branch and check with tests or def getNetwork.

#19 Updated by Ilfat Kinyaev about 4 years ago

Error manifested with aws_lite config.

#20 Updated by Ilfat Kinyaev about 4 years ago

NOTE: If succesiful waiting test for show IPs will at first position, next test, where looks stopped node, will error.
For cure it, success test must be last test, or need swap its.

#21 Updated by Mark Zaslavskiy about 4 years ago

  • Priority changed from Normal to High

#22 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from New to Active / In progress

#23 Updated by Ilfat Kinyaev about 4 years ago

Problem fixed: in test was not initialized awsConfig. Old comment about swapping was incorrect: loadNodes don't change directory if raised error.

http://maxscale-jenkins.mariadb.com:8090/job/mdbci_integration_test/379/
https://github.com/OSLL/mdbci/pull/238
https://github.com/OSLL/mdbci/tree/7106_refactor_def_self.show

#24 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from Active / In progress to New
  • % Done changed from 70 to 100

waiting test result

#26 Updated by Ilfat Kinyaev about 4 years ago

  • Status changed from New to Review
  • Assignee changed from Ilfat Kinyaev to Mark Zaslavskiy

#28 Updated by Mark Zaslavskiy about 4 years ago

  • Status changed from Review to Closed

Also available in: Atom PDF