Bug 1162263 - ambari_config.sh does not accept args in different order
Summary: ambari_config.sh does not accept args in different order
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Gluster Storage
Classification: Red Hat Storage
Component: rhs-hadoop-install
Version: rhgs-3.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Jeff Vance
QA Contact: BigData QE
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-11-10 16:55 UTC by Martin Kudlej
Modified: 2014-11-11 09:18 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-11-10 17:41:58 UTC
Embargoed:


Attachments (Terms of Use)

Description Martin Kudlej 2014-11-10 16:55:06 UTC
Description of problem:
I've read script help message:
configs.sh [-u userId] [-p password] [-port port] ...
and I see there just tiny bug where configs.sh should be changed to real name of script. I recommend to use $0 param.

And I've tried to do permutations of first 3 params because from that help message I expect that I can do that.
Just this permutation passed:
-u admin -p admin -port 8080
USERID=admin
PASSWORD=admin
PORT=:8080
########## Performing 'GET' on (Site:core-site, Tag:version1415365175001)

Others return help message:
-u admin -port 8080 -p admin
-p admin -u admin -port 8080
-p admin -port 8080 -u admin
-port 8080 -p admin -u admin
-port 8080 -u admin -p admin


I recommend to use getopt utility to parse arguments.


Version-Release number of selected component (if applicable):
rhs-hadoop-install-2_29-1

How reproducible:
100%

Actual results:
Script cannot handle permutations of arguments.

Expected results:
All supported scripts will handle permutations of args where it is possible according help message.

Additional info:
perm.sh:
#!/bin/bash

for i in `cat x.txt`; do
  par="";
  for c in `echo $i | sed -e 's/\(.\)/\1\n/g'`; do
    if [ $c == 'a' ]; then
      par="$par -u admin"
    fi
    if [ $c == 'b' ]; then
      par="$par -p admin"
    fi
    if [ $c == 'c' ]; then
      par="$par -port 8080"
    fi
  done;
  echo $par;
  ./ambari_config.sh $par get _hostname_ TestCluster core-site;
done

x.txt:
file with permutations

perm.awk for creating permutations:
function permute(s, st,     i, j, n, tmp) {
    n = split(s, item,//)
    if (st > n) {  print s; return }
    for (i=st; i<=n; i++) {
        if (i != st) {
         tmp = item[st]; item[st] = item[i]; item[i] = tmp
         nextstr = item[1]
         for (j=2; j<=n; j++) nextstr = nextstr delim item[j]
        }else {
          nextstr = s
        }
       permute(nextstr, st+1)
       n = split(s, item, //)
   }
}
{ permute($0,1) }

Comment 1 Martin Kudlej 2014-11-10 16:57:08 UTC
There is another subbug when user miss one argument:
"./ambari_config.sh -p admin -p 8080 get" ... (-u admin is missed)

Comment 4 Martin Kudlej 2014-11-11 09:18:51 UTC
I haven't known that this script is deprecated. I think in this case wontfix is OK and I've filed BZ for removing deprecated scripts from package. I think errata problems cannot be solved like this. Please see bug 1162527


Note You need to log in before you can comment on or make changes to this bug.