예제 #1
0
 def check_from_dict(self):
     empty = ClusterSpec.empty()
     assert "[]" == str(empty)
     node_specs_dict = {
         'cpu': 2,
         'mem': '2GB',
         'disk': '30GB',
         'num_nodes': 2
     }
     custom_linux_1 = ClusterSpec.from_dict(node_specs_dict)
     assert '[{"additional_disks(GB)": {}, "cpu": 2, "disk(GB)": 30.0, "mem(GB)": 2.0, "num_nodes": 2, "os": "linux"}]' \
            == str(custom_linux_1)
예제 #2
0
    def expected_cluster_spec(self):
        """
        The cluster spec we expect this test to consume when run.

        :return:            A ClusterSpec object.
        """
        cluster_size = self.cluster_use_metadata.get(CLUSTER_SIZE_KEYWORD)
        if cluster_size is not None:
            return ClusterSpec.simple_linux(cluster_size)
        elif self.cluster is None:
            return ClusterSpec.empty()
        else:
            return self.cluster.all()
예제 #3
0
    def expected_cluster_spec(self):
        """
        The cluster spec we expect this test to consume when run.

        :return:            A ClusterSpec object.
        """
        cluster_spec = self.cluster_use_metadata.get(CLUSTER_SPEC_KEYWORD)
        cluster_size = self.cluster_use_metadata.get(CLUSTER_SIZE_KEYWORD)
        if cluster_spec is not None:
            return cluster_spec
        elif cluster_size is not None:
            return ClusterSpec.simple_linux(cluster_size)
        elif self.cluster is None:
            return ClusterSpec.empty()
        else:
            return self.cluster.all()
예제 #4
0
 def check_from_list(self):
     empty = ClusterSpec.empty()
     assert "[]" == str(empty)
     node_specs_dict_list = [{
         'cpu': 2,
         'mem': '2GB',
         'disk': '20GB',
         'num_nodes': 2
     }, {
         'cpu': 4,
         'mem': '4GB',
         'disk': '40GB',
         'num_nodes': 4
     }]
     custom_linux_2 = ClusterSpec.from_list(node_specs_dict_list)
     assert '[{"additional_disks(GB)": {}, "cpu": 2, "disk(GB)": 20.0, "mem(GB)": 2.0, "num_nodes": 2, "os": "linux"},' \
            ' {"additional_disks(GB)": {}, "cpu": 4, "disk(GB)": 40.0, "mem(GB)": 4.0, "num_nodes": 4, "os": "linux"}]' \
            == str(custom_linux_2)
예제 #5
0
 def check_to_string(self):
     empty = ClusterSpec.empty()
     assert "[]" == str(empty)
     simple_linux_5 = ClusterSpec.simple_linux(5)
     assert '[{"num_nodes": 5, "os": "linux"}]' == str(simple_linux_5)
예제 #6
0
 def check_cluster_spec_sizes(self):
     simple_linux_2 = ClusterSpec.simple_linux(2)
     assert 2 == len(simple_linux_2)
     assert 0 == len(ClusterSpec.empty())
예제 #7
0
 def check_to_string(self):
     empty = ClusterSpec.empty()
     assert "[]" == str(empty)
     simple_linux_5 = ClusterSpec.simple_linux(5)
     assert '[{"additional_disks(GB)": {}, "cpu": 0, "disk(GB)": 0, "mem(GB)": 0, "num_nodes": 5, "os": "linux"}]' \
            == str(simple_linux_5)