<s> from ipaddr import IPAddress <EOL> from uuid import uuid4 <EOL> from jsonschema . exceptions import ValidationError <EOL> from twisted . internet . task import Clock <EOL> from flocker . apiclient import FakeFlockerClient , Node <EOL> from flocker . testtools import TestCase <EOL> from benchmark . cluster import BenchmarkCluster , validate_cluster_configuration <EOL> class ValidationTests ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> super ( TestCase , self ) . setUp ( ) <EOL> self . config = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } <EOL> ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ '<STR_LIT:user>' ] , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:version>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> } , <EOL> } <EOL> def test_valid ( self ) : <EOL> """<STR_LIT>""" <EOL> validate_cluster_configuration ( self . config ) <EOL> def test_config_extra_attribute ( self ) : <EOL> """<STR_LIT>""" <EOL> self . config [ '<STR_LIT>' ] = [ ] <EOL> validate_cluster_configuration ( self . config ) <EOL> def test_missing_control_node ( self ) : <EOL> """<STR_LIT>""" <EOL> del self . config [ '<STR_LIT>' ] <EOL> self . assertRaises ( <EOL> ValidationError , <EOL> validate_cluster_configuration , self . config , <EOL> ) <EOL> def test_missing_agent_nodes ( self ) : <EOL> """<STR_LIT>""" <EOL> del self . config [ '<STR_LIT>' ] <EOL> self . assertRaises ( <EOL> ValidationError , <EOL> validate_cluster_configuration , self . config , <EOL> ) <EOL> CONTROL_SERVICE_PUBLIC_IP = IPAddress ( '<STR_LIT>' ) <EOL> CONTROL_SERVICE_PRIVATE_IP = IPAddress ( '<STR_LIT>' ) <EOL> DEFAULT_VOLUME_SIZE = <NUM_LIT> <EOL> class BenchmarkClusterTests ( TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( BenchmarkClusterTests , self ) . setUp ( ) <EOL> node = Node ( <EOL> uuid = uuid4 ( ) , public_address = CONTROL_SERVICE_PRIVATE_IP <EOL> ) <EOL> self . control_service = FakeFlockerClient ( [ node ] ) <EOL> self . cluster = BenchmarkCluster ( <EOL> CONTROL_SERVICE_PUBLIC_IP , <EOL> lambda reactor : self . control_service , <EOL> { <EOL> CONTROL_SERVICE_PRIVATE_IP : CONTROL_SERVICE_PUBLIC_IP , <EOL> } , <EOL> DEFAULT_VOLUME_SIZE , <EOL> ) <EOL> def test_control_node_address ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . cluster . control_node_address ( ) , CONTROL_SERVICE_PUBLIC_IP ) <EOL> def test_control_service ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertIs ( <EOL> self . cluster . get_control_service ( Clock ( ) ) , self . control_service ) <EOL> def test_public_address ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . cluster . public_address ( CONTROL_SERVICE_PRIVATE_IP ) , <EOL> CONTROL_SERVICE_PUBLIC_IP <EOL> ) <EOL> def test_default_volume_size ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> self . cluster . default_volume_size ( ) , DEFAULT_VOLUME_SIZE ) </s>
