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

Push the smallfile test results into elasticsearch server. #1984

Merged
merged 19 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ocs_ci/ocs/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,34 @@ def time_taken_to_complete_rebalance(self, timeout=600):
time_taken = time.time() - start_time
return (time_taken / 60)

def get_clustername(self):
"""
Return the name (DNS short name) of the cluster

Args:
AviadP marked this conversation as resolved.
Show resolved Hide resolved
None

Returns:
str: the short DNS name of the cluster
"""
out = run_cmd('oc get route -n openshift-console -o yaml')
AviadP marked this conversation as resolved.
Show resolved Hide resolved
return yaml.full_load(out)['items'][0]['spec']['host'].split('.')[2]

def get_version(self):
"""
Return the OCS Version

Args:
None

Returns:
str: The version of the OCS
"""
ns = config.ENV_DATA['cluster_namespace']
out = run_cmd(f'oc get csv -n {ns} -o yaml')
AviadP marked this conversation as resolved.
Show resolved Hide resolved
ocs_version = yaml.full_load(out)
return ocs_version['items'][0]['spec']['version']


class CephHealthMonitor(threading.Thread):
"""
Expand Down
44 changes: 44 additions & 0 deletions ocs_ci/ocs/ocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,50 @@ def get_logs(
)
return output

def get_build(self):
"""
Return the OCP Build Version

Args:
None
vasukulkarni marked this conversation as resolved.
Show resolved Hide resolved

Returns:
str: The build version of the OCP
vasukulkarni marked this conversation as resolved.
Show resolved Hide resolved
"""
ns = config.ENV_DATA['cluster_namespace']
out = run_cmd(f'oc get clusterversion -n {ns} -o yaml')
vasukulkarni marked this conversation as resolved.
Show resolved Hide resolved
ocp_build = yaml.full_load(out)
return ocp_build['items'][0]['status']['desired']['version']

def get_channel(self):
"""
Return the OCP Channel

Args:
None

Returns:
str: The channel of the OCP
"""
ns = config.ENV_DATA['cluster_namespace']
out = run_cmd(f'oc get clusterversion -n {ns} -o yaml')
ocp_build = yaml.full_load(out)
return ocp_build['items'][0]['spec']['channel']

def get_provider(self):
"""
Return the OCP Provider (Platform)

Args:
None

Returns:
str: The Provider that the OCP is running on
"""
out = run_cmd('oc get nodes -o yaml')
provider = yaml.full_load(out)['items'][0]['spec']['providerID'].split(':')[0]
return provider


def switch_to_project(project_name):
"""
Expand Down
12 changes: 7 additions & 5 deletions ocs_ci/templates/workloads/smallfile/SmallFile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ metadata:
name: smallfile-benchmark
namespace: my-ripsaw
spec:
test_user: homer_simpson
clustername: aws-dec26-2019
test_user: avi-liani
vasukulkarni marked this conversation as resolved.
Show resolved Hide resolved
clustername: dc27-4.4-on-4.3
elasticsearch:
es: es_server
es_port: 9090
es_index: smallfile
server: 10.0.144.152
port: 9200
es_index: ripsaw_smallfile
metadata_collection: true
index_data: true
workload:
name: smallfile
args:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
-e .
elasticsearch
93 changes: 86 additions & 7 deletions tests/e2e/performance/test_small_file_workload.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
import pytest
import time

from ocs_ci.ocs.cluster import CephCluster
from ocs_ci.ocs.ocp import OCP
from ocs_ci.utility.utils import TimeoutSampler
from ocs_ci.utility.utils import TimeoutSampler, get_ocp_version, run_cmd
from ocs_ci.ocs.resources.ocs import OCS
from ocs_ci.utility import templating
from ocs_ci.ocs.utils import get_pod_name_by_pattern
from ocs_ci.ocs.ripsaw import RipSaw
from ocs_ci.ocs import constants
from ocs_ci.framework.testlib import E2ETest, performance
from tests.helpers import get_logs_with_errors
from elasticsearch import Elasticsearch

log = logging.getLogger(__name__)

Expand All @@ -40,31 +42,66 @@ class TestSmallFileWorkload(E2ETest):
workloads
"""

def analize_results(self, results, logs):
keesturam marked this conversation as resolved.
Show resolved Hide resolved

def add_value(res, key, value):
if key not in res.keys():
res[key] = [value]
else:
res[key].append(value)
return res
op = ''
for line in logs.split('\n'):
log.debug(line)
if "operation :" in line:
vasukulkarni marked this conversation as resolved.
Show resolved Hide resolved
op = line.split()[-1].strip()
if "total threads" in line:
results['smallfile-res'][op] = add_value(
results['smallfile-res'][op],
'total_threads', line.split()[-1].strip())
if "total files" in line:
results['smallfile-res'][op] = add_value(
results['smallfile-res'][op],
'total_files', line.split()[-1].strip())
if "elapsed time" in line:
results['smallfile-res'][op] = add_value(
results['smallfile-res'][op],
'elapsed_time', line.split()[-1].strip())
if "files/sec" in line:
results['smallfile-res'][op] = add_value(
results['smallfile-res'][op],
'filesPsec', line.split()[-1].strip())
if "requested files" in line:
results['smallfile-res'][op] = add_value(
results['smallfile-res'][op],
'percenrage', line.split()[0].strip())
vasukulkarni marked this conversation as resolved.
Show resolved Hide resolved
return results

@pytest.mark.parametrize(
argnames=["file_size", "files", "threads", "samples", "interface"],
argvalues=[
pytest.param(
*[4, 50000, 4, 1, constants.CEPHBLOCKPOOL],
*[4, 50000, 4, 3, constants.CEPHBLOCKPOOL],
marks=pytest.mark.polarion_id("OCS-1295"),
),
pytest.param(
*[16, 50000, 4, 1, constants.CEPHBLOCKPOOL],
*[16, 50000, 4, 3, constants.CEPHBLOCKPOOL],
marks=pytest.mark.polarion_id("OCS-2020"),
),
pytest.param(
*[16, 200000, 4, 1, constants.CEPHBLOCKPOOL],
*[16, 200000, 4, 3, constants.CEPHBLOCKPOOL],
marks=pytest.mark.polarion_id("OCS-2021"),
),
pytest.param(
*[4, 50000, 4, 1, constants.CEPHFILESYSTEM],
*[4, 50000, 4, 3, constants.CEPHFILESYSTEM],
marks=pytest.mark.polarion_id("OCS-2022"),
),
pytest.param(
*[16, 50000, 4, 1, constants.CEPHFILESYSTEM],
*[16, 50000, 4, 3, constants.CEPHFILESYSTEM],
marks=pytest.mark.polarion_id("OCS-2023"),
),
pytest.param(
*[16, 200000, 4, 1, constants.CEPHFILESYSTEM],
*[16, 200000, 4, 3, constants.CEPHFILESYSTEM],
vasukulkarni marked this conversation as resolved.
Show resolved Hide resolved
marks=pytest.mark.polarion_id("OCS-2024"),
),
]
Expand All @@ -74,6 +111,12 @@ def test_smallfile_workload(self, ripsaw, file_size, files, threads, samples, in
"""
Run SmallFile Workload
"""
ceph_cluster = CephCluster()
ocp_cluster = OCP()
# getting the name and email of the user that running the test.
user = run_cmd('git config --get user.name').strip()
email = run_cmd('git config --get user.email').strip()

log.info("Apply Operator CRD")
ripsaw.apply_crd('resources/crds/ripsaw_v1alpha1_ripsaw_crd.yaml')
sf_data = templating.load_yaml(constants.SMALLFILE_BENCHMARK_YAML)
Expand All @@ -92,6 +135,8 @@ def test_smallfile_workload(self, ripsaw, file_size, files, threads, samples, in
sf_data['spec']['workload']['args']['files'] = files
sf_data['spec']['workload']['args']['threads'] = threads
sf_data['spec']['workload']['args']['samples'] = samples
sf_data['spec']['clustername'] = ceph_cluster.get_clustername()
sf_data['spec']['test_user'] = f'{user}<{email}>'
""" Calculating the size of the volume that need to be test, it should be at least twice in the size then the
size of the files, and at least 100Gi.
since the file_size is in Kb and the vol_size need to be in Gb, more calculation is needed.
Expand All @@ -104,6 +149,31 @@ def test_smallfile_workload(self, ripsaw, file_size, files, threads, samples, in

sf_obj = OCS(**sf_data)
sf_obj.create()
log.info(f'The smallfile yaml file is {sf_data}')

# Initialaize the results doc file.
results = {
'user': sf_data['spec']['test_user'],
'ocp_version': get_ocp_version(),
'ocp_build': ocp_cluster.get_build(),
'ocp_channel': ocp_cluster.get_channel(),
'ocs_version': ceph_cluster.get_version(),
'vendor': ocp_cluster.get_provider(),
'cluster_name': sf_data['spec']['clustername'],
'smallfile-res': {},
'sample': samples,
'global_options': {
'files': files,
'file_size': file_size,
'threads': threads,
'storageclass': sf_data['spec']['workload']['args']['storageclass'],
'vol_size': sf_data['spec']['workload']['args']['storagesize']
}
}
# Getting all test operations
for op in sf_data['spec']['workload']['args']['operation']:
results['smallfile-res'][op] = {}

# wait for benchmark pods to get created - takes a while
for bench_pod in TimeoutSampler(
120, 3, get_pod_name_by_pattern, 'smallfile-client', 'my-ripsaw'
Expand All @@ -125,16 +195,25 @@ def test_smallfile_workload(self, ripsaw, file_size, files, threads, samples, in
)
start_time = time.time()
timeout = 1800
results['start_time'] = time.strftime('%Y-%m-%dT%H:%M:%SGMT', time.gmtime())
while True:
logs = bench_pod.exec_oc_cmd(
f'logs {small_file_client_pod}',
out_yaml_format=False
)
if "RUN STATUS DONE" in logs:
results = self.analize_results(results, logs)
results['end_time'] = time.strftime('%Y-%m-%dT%H:%M:%SGMT', time.gmtime())
log.debug(f'The test results are : {results}')
log.info("SmallFile Benchmark Completed Successfully")
break

if timeout < (time.time() - start_time):
raise TimeoutError(f"Timed out waiting for benchmark to complete")
time.sleep(30)
assert not get_logs_with_errors()

# push the results to our elasticsearch server
es = Elasticsearch([{'host': sf_data['spec']['elasticsearch']['server'],
'port': sf_data['spec']['elasticsearch']['port']}])
es.index(index='ripsaw-smallfile-results', doc_type='_doc', body=results)