def test_hcf_delete_nonexist_space(self): # Delete non-existing space non_existing_space = "no_space_name" + str(random.randint(1024, 4096)) hcf_auth.target(optional_args={'-o': self.setup_org}) out, err = hcf_space.delete_space(non_existing_space, input_data=b'yes\n') self.verify("FAILED", out)
def test_hcf_delete_nonexist_domain(self): # Delete non-existing domain hcf_auth.target(optional_args={'-o': self.setup_org}) non_existing_domain = "no_domain" + str(random.randint(1024, 4096)) out, err = hcf_domain.delete_domain(non_existing_domain, input_data=b'yes\n') self.verify("OK", out) self.verify("not found", out)
def test_hcf_apps(self): # Target space out, err = hcf_auth.target(optional_args={'-s': self.space_name}) out, err = hcf_apps.downloadApplication(self.app_url, self.app_dir) # Push application out, err = hcf_apps.push_app(self.app_dir, self.app_dir) # verify if application deployed successfully time.sleep(60) self.verify("App started", out) # List application out, err = hcf_apps.list_apps() self.verify(self.app_dir, out) # Scale application mem_limit = "1G" disk_limit = "1G" no_of_instances = "2" out, err = hcf_apps.scale_app(self.app_dir, optional_args={ '-i': no_of_instances, '-k': disk_limit, '-m': mem_limit, '-f': ' ' }) self.verify("OK", out) # Delete application out, err = hcf_apps.delete_app(self.app_dir, input_data=b'yes\n') self.verify("OK", out)
def test_hcf_docker_apps(self): # Target space out, err = hcf_auth.target(optional_args={'-s': self.space_name}) # Enable diego_docker feature flag feature_name = "diego_docker" out, err = hcf_apps.feature_flag(feature_name) while True: if "enabled" in out: break else: out, err = hcf_apps.enable_feature_flag(feature_name) self.verify("Feature " + feature_name + " Enabled", out) break # Push Docker application docker_app_name = 'docker_test_app' + str(random.randint(1024, 4096)) docker_app_out, err = hcf_apps.push_docker_app( docker_app_name, optional_args={'-o': self.docker_image}) time.sleep(60) self.verify("App started", docker_app_out) # Show docker application out, err = hcf_apps.show_app(docker_app_name) self.verify(docker_app_name, out) # List application out, err = hcf_apps.list_apps() self.verify(docker_app_name, out) # Delete docker application out, err = hcf_apps.delete_app(docker_app_name, input_data=b'yes\n') self.verify("OK", out)
def test_hcf_routes_(self): # Target space out, err = hcf_auth.target(optional_args={'-s': self.space_name}) # Create Domain domain_name = 'domain' + str(random.randint(1024, 4096)) + '.com' out, err = hcf_domain.create_domain(self.org_name, domain_name) self.verify(domain_name, out) self.verify("OK", out) # Create Route out, err = hcf_routes.create_route(self.space_name, domain_name) self.verify("Creating route", out) self.verify("OK", out) # Target space out, err = hcf_auth.target(optional_args={'-s': self.space_name}) # List Routes out, err = hcf_routes.list_routes() self.verify("Getting routes", out) # download app out, err = hcf_apps.downloadApplication(self.app_url, self.app_dir) # Push application out, err = hcf_apps.push_app(self.app_dir, self.app_dir) # verify if application deployed successfully time.sleep(60) self.verify("App started", out) # map route to app out, err = hcf_routes.map_route(self.app_dir, domain_name) self.verify("Adding route " + domain_name + " to app", out) self.verify("OK", out) # unmap route from app out, err = hcf_routes.unmap_route(self.app_dir, domain_name) self.verify("Removing route " + domain_name + " from app", out) self.verify("OK", out) # Delete routes out, err = hcf_routes.delete_orphaned_routes(input_data=b'yes\n') self.verify("Deleting route", out) self.verify("OK", out)
def setUpClass(cls): super(TestHcfMarketplace, cls).setUpClass() # Connect to the cluster URI target hcf_auth.connect_target(cls.cluster_url, optional_args={'--skip-ssl-validation': ' '}) # Log into Cluster using creds hcf_auth.login(optional_args={'-u': cls.username, '-p': cls.password}) # Create organisation cls.setup_org = 'og_test_org' + str(random.randint(1024, 4096)) out, err = hcf_organisations.create_org(cls.setup_org) out, err = hcf_auth.target(optional_args={'-o': cls.setup_org}) # Create Space cls.setup_space = 'sp_test_space' + str(random.randint(1024, 4096)) out, err = hcf_space.create_space(cls.setup_space) out, err = hcf_auth.target(optional_args={'-o': cls.setup_org, '-s': cls.setup_space})
def setUpClass(cls): super(TestHcfSecurityGroups, cls).setUpClass() # Connect to the cluster URI target hcf_auth.connect_target(cls.cluster_url, optional_args={'--skip-ssl-validation': ' '}) # Loginto Cluster using creds hcf_auth.login(optional_args={'-u': cls.username, '-p': cls.password}) # Create Organisation cls.org_name = 'org_test' + str(random.randint(1024, 4096)) out, err = hcf_organisations.create_org(cls.org_name) # Create Space out, err = hcf_auth.target(optional_args={'-o': cls.org_name}) cls.space_name = 'space_test' + str(random.randint(1024, 4096)) out, err = hcf_space.create_space(cls.space_name)
def setUpClass(cls): super(TestHcfApps, cls).setUpClass() # Connect to the cluster URI target hcf_auth.connect_target(cls.cluster_url, optional_args={'--skip-ssl-validation': ' '}) # Loginto Cluster using creds hcf_auth.login(optional_args={'-u': cls.username, '-p': cls.password}) # Create Organisation cls.org_name = 'og_test_org' + str(random.randint(1024, 4096)) out, err = hcf_organisations.create_org(cls.org_name) # Create Space out, err = hcf_auth.target(optional_args={'-o': cls.org_name}) cls.space_name = 'sp_test_space' + str(random.randint(1024, 4096)) out, err = hcf_space.create_space(cls.space_name) parsed = urlparse(cls.app_url) link = parsed.path.split('/') cls.app_dir = link[len(link) - 1]
def test_hcf_create_delete_security_group(self): # Create Security Group Rules File jsonFileName = hcf_security_groups.create_secgroup_rule_json() # Create Security Group secgroup_name = 'sg_test' + str(random.randint(1024, 4096)) out, err = hcf_security_groups.create_security_group( secgroup_name, jsonFileName) self.verify(secgroup_name, out) self.verify("OK", out) # List Security Groups out, err = hcf_security_groups.list_security_groups() self.verify(secgroup_name, out) self.verify("OK", out) # Target space out, err = hcf_auth.target(optional_args={ '-o': self.org_name, '-s': self.space_name }) # Bind Security Group out, err = hcf_security_groups.bind_security_group( secgroup_name, self.org_name, self.space_name) self.verify("Assigning security group ", out) self.verify("OK", out) # Unbind Security Group out, err = hcf_security_groups.unbind_security_group( secgroup_name, self.org_name, self.space_name) self.verify("Unbinding security group ", out) self.verify("OK", out) # Bind Staging Security Group out, err = hcf_security_groups.bind_staging_security_group( secgroup_name) self.verify("Binding security group " + secgroup_name + " to staging", out) self.verify("OK", out) # List Staging Security Groups out, err = hcf_security_groups.list_staging_security_groups() self.verify(secgroup_name, out) # Unbind Staging Security Group out, err = hcf_security_groups.unbind_staging_security_group( secgroup_name) self.verify( "Unbinding security group " + secgroup_name + " from defaults for staging", out) self.verify("OK", out) # Bind Running Security Group out, err = hcf_security_groups.bind_running_security_group( secgroup_name) self.verify( "Binding security group " + secgroup_name + " to defaults for running", out) self.verify("OK", out) # List Running Security Groups out, err = hcf_security_groups.list_running_security_groups() self.verify(secgroup_name, out) # Unbind Running Security Group out, err = hcf_security_groups.unbind_running_security_group( secgroup_name) self.verify( "Unbinding security group " + secgroup_name + " from defaults for running", out) self.verify("OK", out) # Update Security Group Rule jsonFileName = hcf_security_groups.updated_secgroup_rule_json() # Update Security Group out, err = hcf_security_groups.update_security_group( secgroup_name, jsonFileName) self.verify("Updating security group", out) self.verify("OK", out) # View Security Group Info out, err = hcf_security_groups.view_security_group(secgroup_name) # Delete Security Group and Rules file out, err = hcf_security_groups.delete_security_group( secgroup_name, input_data=b'yes\n') self.verify("Deleting security group", out) self.verify("OK", out) os.remove(jsonFileName)
def test_hcf_user_operations(self): # Login with admin to create user hcf_auth.login(optional_args={'-u': self.username, '-p': self.password}) # Create an organisation to bind with user org_name = 'og_test_org' + str(random.randint(1024, 4096)) hcf_organisations.create_org(org_name) # Create a space to bind with user out, err = hcf_auth.target(optional_args={'-o': org_name}) space_name = 'sp_test_space' + str(random.randint(1024, 4096)) out, err = hcf_space.create_space(space_name) out, err = hcf_auth.target(optional_args={'-s': space_name}) # Create user user_name = 'hcf_test_user' + str(random.randint(1024, 4096)) password = '******' + str(random.randint(1024, 4096)) out, err = hcf_users.create_user(user_name, password) self.verify(user_name, out) self.verify("OK", out) # Set role for user in an organisation org_role = "OrgManager" out, err = hcf_users.set_org_role(user_name, org_name, org_role) self.verify("OK", out) self.verify(org_name, out) self.verify(org_role, out) # Unset role for user in an organisation out, err = hcf_users.unset_org_role(user_name, org_name, org_role) self.verify("OK", out) self.verify(org_name, out) # Set role for user in a space space_role = "SpaceDeveloper" out, err = hcf_users.set_space_role( user_name, org_name, space_name, space_role) self.verify("OK", out) self.verify(space_name, out) self.verify(space_role, out) # Unset role for user in a space out, err = hcf_users.unset_space_role( user_name, org_name, space_name, space_role) self.verify("OK", out) self.verify(space_name, out) hcf_auth.logout(self.cluster_url) # Login with the created user out, err = hcf_auth.login(optional_args={'-u': user_name, '-p': password}) self.verify("Authenticating", out) self.verify("OK", out) hcf_auth.logout(self.cluster_url) # Login with admin to delete user hcf_auth.login(optional_args={'-u': self.username, '-p': self.password}) # Delete User out, err = hcf_users.delete_user( user_name, input_data=b'yes\n') self.verify("OK", out) # Delete org hcf_organisations.delete_org(org_name, input_data=b'yes\n') hcf_auth.logout(self.cluster_url)
def test_hcf_org_space_domain(self): # Create Organisation org_name = 'og_test_org' + str(random.randint(1024, 4096)) out, err = hcf_organisations.create_org(org_name) self.verify(org_name, out) self.verify("OK", out) # Get org info out, err = hcf_organisations.org_info(org_name) self.verify(org_name, out) # List Organisations out, err = hcf_organisations.list_orgs() self.verify(org_name, out) # Create Space out, err = hcf_auth.target(optional_args={'-o': org_name}) space_name = 'sp_test_space' + str(random.randint(1024, 4096)) out, err = hcf_space.create_space(space_name) self.verify(space_name, out) self.verify("OK", out) # List Spaces out, err = hcf_space.list_space() self.verify(space_name, out) # Get Space Info out, err = hcf_space.space(space_name) self.verify("Getting info for space", out) self.verify("OK", out) # Create Domain domain_name = 'testdomain' + str(random.randint(1024, 4096)) + '.com' hcf_domain.create_domain(org_name, domain_name) self.verify("OK", out) # List Domains out, err = hcf_domain.list_domain() self.verify("Getting domains in org", out) # List Router Groups out, err = hcf_domain.list_router_groups() self.verify("Getting router groups", out) # Delete domain hcf_auth.target(optional_args={'-o': org_name}) out, err = hcf_domain.delete_domain(domain_name, input_data=b'yes\n') self.verify("OK", out) # Rename org new_org_name = 'new_og_test_org' + str(random.randint(1024, 4096)) out, err = hcf_organisations.rename_org(org_name, new_org_name) self.verify(new_org_name, out) self.verify("OK", out) # Rename space new_space_name = 'new_sp_test_space' + str(random.randint(1024, 4096)) out, err = hcf_space.rename_space(space_name, new_space_name) self.verify(new_space_name, out) self.verify("OK", out) # Delete space and org out, err = hcf_space.delete_space(new_space_name, input_data=b'yes\n') self.verify("OK", out) out, err = hcf_organisations.delete_org(new_org_name, input_data=b'yes\n') self.verify("OK", out)
def test_hcf_get_nonexist_space(self): # Get space info for non-existing space hcf_auth.target(optional_args={'-o': self.setup_org}) space_name = 'nospace' + str(random.randint(1024, 4096)) out, err = hcf_space.space(space_name) self.verify("FAILED", out)