Amending	
  and	
  Testing	
  OpenStack	
  Changes	
  
Lab	
  Guide	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
	
  
Cisco	
  Live!	
  2015	
  
	
  
	
  
Amending	
  Changes	
   ©	
  Cisco	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   2	
  
Overall	
  Objectives	
  
	
  
This	
  lab	
  will	
  guide	
  you	
  through	
  the	
  process	
  of	
  amending	
  OpenStack	
  potential	
  changes	
  
during	
  acceptance	
  review	
  by	
  the	
  community,	
  and	
  will	
  also	
  show	
  some	
  examples	
  of	
  local	
  
testing.	
  
	
  
1. Submit	
  a	
  change	
  for	
  review	
  
2. Review	
  the	
  change	
  with	
  a	
  -­‐1	
  
3. Amend	
  the	
  change	
  to	
  fix	
  the	
  problems	
  pointed	
  out	
  in	
  review	
  and	
  to	
  resolve	
  merge	
  
conflicts	
  
4. Merge	
  the	
  change	
  
5. Try	
  local	
  test	
  tooling	
  
	
   	
  
Amending	
  Changes	
   ©	
  Cisco	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   3	
  
Submit	
  a	
  change	
  for	
  review	
  
	
  
Log	
  into	
  your	
  Ubuntu	
  14.04	
  VM.	
  At	
  a	
  command	
  prompt,	
  make	
  a	
  new	
  directory	
  so	
  that	
  this	
  
lab	
  will	
  be	
  independent	
  of	
  whatever	
  changes	
  were	
  made	
  in	
  prior	
  labs	
  and	
  clone	
  the	
  
sandbox	
  code	
  into	
  it:	
  
	
  
mkdir	
  amend_lab	
  
cd	
  amend_lab	
  
git	
  clone	
  git://git.openstack.org/openstack-­‐dev/sandbox	
  
	
  
Then,	
  change	
  directories	
  to	
  the	
  sandbox	
  code	
  and	
  run	
  the	
  git	
  review	
  -­‐s	
  command	
  to	
  
configure	
  it	
  for	
  submission	
  to	
  gerrit	
  
	
  
cd	
  sandbox	
  
git	
  review	
  -­‐s	
  
	
  
Next,	
  make	
  a	
  new	
  branch,	
  and	
  make	
  changes	
  in	
  that	
  branch.	
  Be	
  sure	
  to	
  use	
  your	
  email	
  
address	
  in	
  the	
  below	
  commands:	
  
	
  
git	
  checkout	
  -­‐b	
  newbranch	
  origin/master	
  
echo	
  “your@email.address”	
  >>	
  Changelog	
  
git	
  add	
  Changelog	
  
git	
  commit	
  -­‐m	
  "Added	
  file"	
  
git	
  review	
  
	
  
This	
  will	
  submit	
  the	
  changed	
  code	
  to	
  gerrit	
  for	
  automated	
  and	
  human	
  review,	
  and	
  will	
  
return	
  a	
  URL	
  which	
  you	
  can	
  access	
  to	
  monitor	
  the	
  review	
  process.	
  A	
  successful	
  session	
  will	
  
look	
  like:	
  
	
  
$	
  git	
  review	
  
remote:	
  Resolving	
  deltas:	
  100%	
  (1/1)	
  
remote:	
  Processing	
  changes:	
  new:	
  1,	
  refs:	
  1,	
  done	
  
remote:	
  
remote:	
  New	
  Changes:	
  
remote:	
  	
  	
  https://review.openstack.org/188988	
  
remote:	
  
To	
  ssh://openstax-­‐haxor@review.openstack.org:29418/openstack-­‐
dev/sandbox.git	
  
	
  *	
  [new	
  branch]	
  	
  	
  	
  	
  	
  HEAD	
  -­‐>	
  refs/publish/master/newbranch	
  
$	
  
Review	
  submitted	
  changes	
  
	
  
	
  
Amending	
  Changes	
   ©	
  Cisco	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   4	
  
To	
  review	
  the	
  changes,	
  go	
  to	
  the	
  URL	
  returned	
  when	
  you	
  submitted	
  the	
  proposed	
  change	
  
via	
  git	
  review.	
  Review	
  the	
  change	
  and	
  give	
  it	
  a	
  -­‐1	
  due	
  to	
  incomplete	
  commit	
  messages.	
  
	
  
	
  
	
  
Amending	
  Changes	
   ©	
  Cisco	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   5	
  
	
  
	
  
	
  
	
  
Amend	
  the	
  change	
  to	
  resolve	
  
	
  
At	
  a	
  command	
  prompt	
  on	
  your	
  Ubuntu	
  14.04	
  VM,	
  run	
  the	
  command:	
  
	
  
git	
  config	
  -­‐-­‐amend	
  
	
  
This	
  will	
  pull	
  up	
  an	
  editor	
  in	
  which	
  you	
  can	
  put	
  a	
  new	
  commit	
  message.	
  Put	
  a	
  properly	
  
structured	
  commit	
  message	
  this	
  time:	
  
	
  
	
  
Now	
  submit	
  the	
  updated	
  code	
  for	
  re-­‐review:	
  
	
  
git	
  review	
  
	
  
In	
  review.openstack.org	
  you	
  should	
  now	
  see	
  that	
  your	
  proposed	
  change	
  has	
  a	
  second	
  
revision	
  and	
  is	
  ready	
  to	
  be	
  re-­‐reviewed.	
  
Amending	
  Changes	
   ©	
  Cisco	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   6	
  
	
  
	
  
Review	
  the	
  change	
  again	
  and	
  if	
  no	
  other	
  problems	
  are	
  present,	
  vote	
  +2	
  and	
  merge	
  the	
  
change.	
  
Bonus:	
  Thinking	
  about	
  merge	
  conflicts	
  
	
  
Depending	
  on	
  timing	
  of	
  submissions,	
  some	
  of	
  you	
  may	
  encounter	
  merge	
  conflicts	
  when	
  you	
  
try	
  to	
  merge	
  your	
  Changelog	
  change.	
  Think	
  about	
  why	
  that	
  is?	
  Do	
  you	
  see	
  potential	
  for	
  that	
  
happening	
  outside	
  of	
  the	
  lab	
  as	
  well?	
  
	
  
One	
  of	
  the	
  following	
  approaches	
  may	
  help	
  you	
  overcome	
  this	
  obstacle.	
  
	
  
For	
  trivial	
  rebasing	
  conflicts,	
  the	
  Rebase	
  button	
  in	
  review.openstack.org	
  may	
  resolve	
  the	
  
merge	
  conflict.	
  
Amending	
  Changes	
   ©	
  Cisco	
  and/or	
  its	
  affiliates.	
  All	
  rights	
  reserved.	
   7	
  
	
  
For	
  more	
  complicated	
  conflicts	
  the	
  process	
  will	
  vary	
  but	
  will	
  likely	
  involve	
  git	
  rebase	
  on	
  
your	
  local	
  command	
  line.	
  http://jjasghar.github.io/blog/2014/10/13/git-­‐rebase-­‐and-­‐git-­‐
detached-­‐head-­‐cheat-­‐sheet/	
  is	
  one	
  good	
  reference	
  with	
  examples.	
  
	
  
Local	
  Testing	
  
	
  
Most	
  OpenStack	
  projects	
  have	
  local	
  tests	
  which	
  should	
  be	
  run	
  prior	
  to	
  submitting	
  code	
  for	
  
review.	
  
	
  
You	
  can	
  run	
  static	
  analysis	
  tests	
  like	
  style	
  compliance	
  in	
  the	
  sandbox.	
  To	
  try	
  flake8,	
  install	
  
and	
  run	
  it	
  
	
  
sudo	
  apt-­‐get	
  install	
  flake8	
  
flake8	
  test.py	
  
	
  
You	
  can	
  also	
  run	
  unit	
  and	
  integration	
  tests	
  though	
  those	
  aren’t	
  included	
  with	
  the	
  sandbox	
  
test	
  environment.	
  To	
  see	
  some	
  of	
  those	
  you	
  can	
  download	
  one	
  of	
  the	
  larger	
  projects	
  and	
  
start	
  to	
  look	
  at	
  the	
  testing	
  included	
  with	
  it:	
  
	
  
cd	
  
sudo	
  apt-­‐get	
  install	
  python-­‐pip	
  python-­‐dev	
  libffi-­‐dev	
  	
  
sudo	
  apt-­‐get	
  install	
  libssl-­‐dev	
  libldap2-­‐dev	
  libsasl2-­‐dev	
  
sudo	
  apt-­‐get	
  install	
  libxml2-­‐dev	
  libxslt-­‐dev	
  
sudo	
  pip	
  install	
  tox	
  
git	
  clone	
  git://git.openstack.org/openstack/keystone	
  
cd	
  keystone	
  
tox	
  –e	
  py27	
  
	
  
Note:	
  most	
  projects	
  use	
  tox	
  as	
  the	
  test	
  framework.	
  Specifics	
  will	
  vary	
  by	
  project	
  and	
  will	
  
likely	
  require	
  additional	
  dependencies	
  be	
  installed	
  beyond	
  those	
  listed.	
  
	
  

Amending and Testing changes lab guide

  • 1.
    Amending  and  Testing  OpenStack  Changes   Lab  Guide                                                                         Cisco  Live!  2015      
  • 2.
    Amending  Changes  ©  Cisco  and/or  its  affiliates.  All  rights  reserved.   2   Overall  Objectives     This  lab  will  guide  you  through  the  process  of  amending  OpenStack  potential  changes   during  acceptance  review  by  the  community,  and  will  also  show  some  examples  of  local   testing.     1. Submit  a  change  for  review   2. Review  the  change  with  a  -­‐1   3. Amend  the  change  to  fix  the  problems  pointed  out  in  review  and  to  resolve  merge   conflicts   4. Merge  the  change   5. Try  local  test  tooling      
  • 3.
    Amending  Changes  ©  Cisco  and/or  its  affiliates.  All  rights  reserved.   3   Submit  a  change  for  review     Log  into  your  Ubuntu  14.04  VM.  At  a  command  prompt,  make  a  new  directory  so  that  this   lab  will  be  independent  of  whatever  changes  were  made  in  prior  labs  and  clone  the   sandbox  code  into  it:     mkdir  amend_lab   cd  amend_lab   git  clone  git://git.openstack.org/openstack-­‐dev/sandbox     Then,  change  directories  to  the  sandbox  code  and  run  the  git  review  -­‐s  command  to   configure  it  for  submission  to  gerrit     cd  sandbox   git  review  -­‐s     Next,  make  a  new  branch,  and  make  changes  in  that  branch.  Be  sure  to  use  your  email   address  in  the  below  commands:     git  checkout  -­‐b  newbranch  origin/master   echo  “your@email.address”  >>  Changelog   git  add  Changelog   git  commit  -­‐m  "Added  file"   git  review     This  will  submit  the  changed  code  to  gerrit  for  automated  and  human  review,  and  will   return  a  URL  which  you  can  access  to  monitor  the  review  process.  A  successful  session  will   look  like:     $  git  review   remote:  Resolving  deltas:  100%  (1/1)   remote:  Processing  changes:  new:  1,  refs:  1,  done   remote:   remote:  New  Changes:   remote:      https://review.openstack.org/188988   remote:   To  ssh://openstax-­‐haxor@review.openstack.org:29418/openstack-­‐ dev/sandbox.git    *  [new  branch]            HEAD  -­‐>  refs/publish/master/newbranch   $   Review  submitted  changes      
  • 4.
    Amending  Changes  ©  Cisco  and/or  its  affiliates.  All  rights  reserved.   4   To  review  the  changes,  go  to  the  URL  returned  when  you  submitted  the  proposed  change   via  git  review.  Review  the  change  and  give  it  a  -­‐1  due  to  incomplete  commit  messages.        
  • 5.
    Amending  Changes  ©  Cisco  and/or  its  affiliates.  All  rights  reserved.   5           Amend  the  change  to  resolve     At  a  command  prompt  on  your  Ubuntu  14.04  VM,  run  the  command:     git  config  -­‐-­‐amend     This  will  pull  up  an  editor  in  which  you  can  put  a  new  commit  message.  Put  a  properly   structured  commit  message  this  time:       Now  submit  the  updated  code  for  re-­‐review:     git  review     In  review.openstack.org  you  should  now  see  that  your  proposed  change  has  a  second   revision  and  is  ready  to  be  re-­‐reviewed.  
  • 6.
    Amending  Changes  ©  Cisco  and/or  its  affiliates.  All  rights  reserved.   6       Review  the  change  again  and  if  no  other  problems  are  present,  vote  +2  and  merge  the   change.   Bonus:  Thinking  about  merge  conflicts     Depending  on  timing  of  submissions,  some  of  you  may  encounter  merge  conflicts  when  you   try  to  merge  your  Changelog  change.  Think  about  why  that  is?  Do  you  see  potential  for  that   happening  outside  of  the  lab  as  well?     One  of  the  following  approaches  may  help  you  overcome  this  obstacle.     For  trivial  rebasing  conflicts,  the  Rebase  button  in  review.openstack.org  may  resolve  the   merge  conflict.  
  • 7.
    Amending  Changes  ©  Cisco  and/or  its  affiliates.  All  rights  reserved.   7     For  more  complicated  conflicts  the  process  will  vary  but  will  likely  involve  git  rebase  on   your  local  command  line.  http://jjasghar.github.io/blog/2014/10/13/git-­‐rebase-­‐and-­‐git-­‐ detached-­‐head-­‐cheat-­‐sheet/  is  one  good  reference  with  examples.     Local  Testing     Most  OpenStack  projects  have  local  tests  which  should  be  run  prior  to  submitting  code  for   review.     You  can  run  static  analysis  tests  like  style  compliance  in  the  sandbox.  To  try  flake8,  install   and  run  it     sudo  apt-­‐get  install  flake8   flake8  test.py     You  can  also  run  unit  and  integration  tests  though  those  aren’t  included  with  the  sandbox   test  environment.  To  see  some  of  those  you  can  download  one  of  the  larger  projects  and   start  to  look  at  the  testing  included  with  it:     cd   sudo  apt-­‐get  install  python-­‐pip  python-­‐dev  libffi-­‐dev     sudo  apt-­‐get  install  libssl-­‐dev  libldap2-­‐dev  libsasl2-­‐dev   sudo  apt-­‐get  install  libxml2-­‐dev  libxslt-­‐dev   sudo  pip  install  tox   git  clone  git://git.openstack.org/openstack/keystone   cd  keystone   tox  –e  py27     Note:  most  projects  use  tox  as  the  test  framework.  Specifics  will  vary  by  project  and  will   likely  require  additional  dependencies  be  installed  beyond  those  listed.