datastax / cstar_perf

Apache Cassandra performance testing platform
Apache License 2.0
72 stars 34 forks source link

CSTAR-630: Support case where client and server users are not the same #238

Closed csplinter closed 8 years ago

csplinter commented 8 years ago

Sometimes the cstar_perf tool host is not using the same linux user as the server under test host. This causes the DSE bootstrap process to fail because it tries to create the cstar_perf tool host home on the server under test host.

[automaton@10.200.175.89] out: [10.200.241.2] run: rm -rf /home/automaton/fab/dse_builds/dse-5.0.0
[automaton@10.200.175.89] out: [10.200.241.2] run: mkdir -p /home/automaton/fab/dse_builds
[automaton@10.200.175.89] out: [10.200.241.2] out: mkdir: cannot create directory ‘/home/automaton’: Permission denied
[automaton@10.200.175.89] out: [10.200.241.2] out: 
[automaton@10.200.175.89] out: 
[automaton@10.200.175.89] out: 
[automaton@10.200.175.89] out: Fatal error: run() received nonzero return code 1 while executing!
[automaton@10.200.175.89] out: 
[automaton@10.200.175.89] out: Requested: mkdir -p /home/automaton/fab/dse_builds
[automaton@10.200.175.89] out: Executed: /bin/bash -l -c "mkdir -p /home/automaton/fab/dse_builds"

In order to solve this, we only use os.path.expanduser to get the dse_build_local location. This PR uses os.path.join('~','fab','dse') as the dse_build_remote location. This allows the path to properly expand when the given commands are run on the server under test host.

Tested:

nastra commented 8 years ago

There are certain cases where os.path.join('~','fab','dse') would't work. One case that I can think of is if such a path is passed to the JVM as a parameter. What if we instead use the $HOME variable?

csplinter commented 8 years ago

Using $HOME fails here

[testcluster-01] run: ln -sfn ~/fab/dse_builds/dse-5.0.0 $HOME/fab/dse
[testcluster-01] download: <file obj> <- /home/cstar/$HOME/fab/dse/resources/cassandra/conf/cassandra.yaml

Fatal error: get() encountered an exception while downloading '/home/cstar/$HOME/fab/dse/resources/cassandra/conf/cassandra.yaml'

Underlying exception:
    No such file

Aborting.

This issue with using environment variables in the path appears to be specific to using the fab.get and fab.put commands

csplinter commented 8 years ago

I chose to add a local option to our get_dse_path and get_cassandra_path

fab_cassandra.py

def get_cassandra_path(local=True):
    return os.path.expanduser('~/fab/cassandra') if local else os.path.join(fab.run('pwd'), 'fab', 'cassandra')

def get_bin_path(local=True):
    return os.path.join(get_cassandra_path(local=local), 'bin')

fab_dse.py

def get_dse_path(local=True):
    return os.path.expanduser("~/fab/dse") if local else os.path.join(fab.run('pwd'), 'fab', 'dse')

def get_dse_conf_path(local=True):
    return os.path.join(get_dse_path(local=local), 'resources', 'dse', 'conf')

def get_cassandra_path(local=True):
    return os.path.join(get_dse_path(local=local), 'resources', 'cassandra')
csplinter commented 8 years ago

The behavior here with the fabric.operations.get function

download: <file obj> <- /home/cstar/$HOME/fab/dse/resources/cassandra/conf/cassandra.yaml

Is caused by the fact that they are joining home = ftp.normalize('.') with the remote_path. In our case, the home is /home/cstar and the remote path is $HOME/fab/dse/resources/cassandra/conf/cassandra.yaml. See the fabric source, we hit that case because the fabric code is first checking for os.path.isabs(remote_path) and on Unix, that means it begins with a slash. I do not see a way to work around this using $HOME in get_dse_path without modifying this path in each call to fab.get or fab.put.

Regarding the first solution of using os.path.join('~','fab','dse') and the case of using such a path as a JVM parameter, could we do something similar to what we do here? At this point I am having trouble finding an easier solution

nastra commented 8 years ago

Regarding the first solution of using os.path.join('~','fab','dse') and the case of using such a path as a JVM parameter, could we do something similar to what we do here?

The approach from https://github.com/datastax/cstar_perf/blob/master/tool/cstar_perf/tool/fab_dse.py/#L190-L191 sounds like a reasonable workaround

csplinter commented 8 years ago

@nastra this is ready for another review

nastra commented 8 years ago

+1