forked from openstack/rally
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The scenario creates and deletes a Hadoop cluster. Change-Id: I1280f5f3f4cd7415788a3e474dd1852c68a3c35c
- Loading branch information
1 parent
24218d9
commit e2a3e1c
Showing
7 changed files
with
387 additions
and
8 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
doc/samples/tasks/scenarios/sahara/create_and_delete_cluster.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"SaharaClusters.create_and_delete_cluster": [ | ||
{ | ||
"args": { | ||
"flavor": { | ||
"name": "m1.small" | ||
}, | ||
"node_count": 2, | ||
"plugin_name": "vanilla", | ||
"hadoop_version": "2.3.0" | ||
}, | ||
"runner": { | ||
"type": "constant", | ||
"times": 4, | ||
"concurrency": 2 | ||
}, | ||
"context": { | ||
"users": { | ||
"tenants": 1, | ||
"users_per_tenant": 1 | ||
}, | ||
"sahara_image": { | ||
"image_url": "http://sahara-files.mirantis.com/sahara-icehouse-vanilla-2.3.0-ubuntu-13.10.qcow2", | ||
"username": "ubuntu", | ||
"plugin_name": "vanilla", | ||
"hadoop_version": "2.3.0" | ||
} | ||
} | ||
} | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
doc/samples/tasks/scenarios/sahara/create_and_delete_cluster.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
SaharaClusters.create_and_delete_cluster: | ||
- | ||
args: | ||
flavor: | ||
name: "m1.small" | ||
node_count: 2 | ||
plugin_name: "vanilla" | ||
hadoop_version: "2.3.0" | ||
runner: | ||
type: "constant" | ||
times: 4 | ||
concurrency: 2 | ||
context: | ||
users: | ||
tenants: 1 | ||
users_per_tenant: 1 | ||
sahara_image: | ||
image_url: "http://sahara-files.mirantis.com/sahara-icehouse-vanilla-2.3.0-ubuntu-13.10.qcow2" | ||
username: "ubuntu" | ||
plugin_name: "vanilla" | ||
hadoop_version: "2.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright 2014: Mirantis Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from rally.benchmark.scenarios import base | ||
from rally.benchmark.scenarios.sahara import utils | ||
from rally.benchmark import types | ||
from rally.benchmark import validation | ||
from rally import consts | ||
from rally.openstack.common import log as logging | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
class SaharaClusters(utils.SaharaScenario): | ||
|
||
@types.set(flavor=types.FlavorResourceType) | ||
@validation.add(validation.flavor_exists('flavor')) | ||
@validation.required_services(consts.Service.SAHARA) | ||
@validation.required_contexts("users", "sahara_image") | ||
@validation.add(validation.number("node_count", minval=2, | ||
integer_only=True)) | ||
@base.scenario(context={"cleanup": ["sahara"]}) | ||
def create_and_delete_cluster(self, flavor, node_count, | ||
plugin_name="vanilla", | ||
hadoop_version="2.3.0"): | ||
"""Test the Sahara Cluster launch and delete commands. | ||
This scenario launches a Hadoop cluster, waits until it becomes | ||
'Active' and deletes it. | ||
:param flavor: The Nova flavor that will be for nodes in the | ||
created node groups | ||
:param node_count: The total number of instances in a cluster (>= 2) | ||
:param plugin_name: The name of a provisioning plugin | ||
:param hadoop_version: The version of Hadoop distribution supported by | ||
the specified plugin. | ||
""" | ||
|
||
tenant_id = self.clients("keystone").tenant_id | ||
image_id = self.context()["sahara_images"][tenant_id] | ||
|
||
LOG.debug("Using Image: %s" % image_id) | ||
|
||
cluster = self._launch_cluster(flavor_id=flavor, | ||
image_id=image_id, | ||
node_count=node_count, | ||
plugin_name=plugin_name, | ||
hadoop_version=hadoop_version) | ||
|
||
self._delete_cluster(cluster) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright 2014: Mirantis Inc. | ||
# All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
import mock | ||
|
||
from rally.benchmark.scenarios.sahara import clusters | ||
from tests import test | ||
|
||
SAHARA_CLUSTERS = "rally.benchmark.scenarios.sahara.clusters.SaharaClusters" | ||
SAHARA_UTILS = 'rally.benchmark.scenarios.sahara.utils' | ||
|
||
|
||
class SaharaNodeGroupTemplatesTestCase(test.TestCase): | ||
|
||
@mock.patch(SAHARA_CLUSTERS + "._delete_cluster") | ||
@mock.patch(SAHARA_CLUSTERS + "._launch_cluster", | ||
return_value=mock.MagicMock(id=42)) | ||
@mock.patch(SAHARA_UTILS + '.SaharaScenario.clients') | ||
def test_create_and_delete_cluster(self, mock_clients, mock_launch_cluster, | ||
mock_delete_cluster): | ||
|
||
clusters_scenario = clusters.SaharaClusters() | ||
|
||
clusters_scenario.clients("keystone").tenant_id = "test_tenant" | ||
clusters_scenario.context = mock.MagicMock(return_value={ | ||
"sahara_images": {"test_tenant": "test_image"}} | ||
) | ||
clusters_scenario.create_and_delete_cluster("test_flavor", 5, | ||
"test_plugin", | ||
"test_version") | ||
|
||
mock_launch_cluster.assert_called_once_with( | ||
flavor_id="test_flavor", | ||
image_id="test_image", | ||
node_count=5, | ||
plugin_name="test_plugin", | ||
hadoop_version="test_version") | ||
|
||
mock_delete_cluster.assert_called_once_with( | ||
mock_launch_cluster.return_value) |
Oops, something went wrong.