def add_comment_open_comment(): raise_if_login_failed(locust) r = locust.get(f'/secure/AddComment!default.jspa?id={issue_id}', catch_response=True) content = r.content.decode('utf-8') token = fetch_by_re(params.atl_token_pattern, content) form_token = fetch_by_re(params.form_token_pattern, content) if not (f'Add Comment: {issue_key}' in content): logger.error( f'Could not open comment in the {issue_key} issue: {content}') assert f'Add Comment: {issue_key}' in content, 'Could not open comment in the issue' locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("805"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("810"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("820"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/internal/2/user/mention/search?issueKey={issue_key}&projectKey={project_key}' f'&maxResults=10&_={timestamp_int()}', catch_response=True) locust.session_data_storage['token'] = token locust.session_data_storage['form_token'] = form_token
def edit_issue_open_editor(): raise_if_login_failed(locust) r = locust.get(f'/secure/EditIssue!default.jspa?id={issue_id}', catch_response=True) content = r.content.decode('utf-8') issue_type = fetch_by_re(params.issue_type_pattern, content) atl_token = fetch_by_re(params.atl_token_pattern, content) priority = fetch_by_re(params.issue_priority_pattern, content, group_no=2) assignee = fetch_by_re(params.issue_assigneee_reporter_pattern, content, group_no=2) reporter = fetch_by_re(params.issue_reporter_pattern, content) if not (f' Edit Issue: [{issue_key}]' in content): logger.error(f'{params.err_message_issue_not_found} - {issue_id}, {issue_key}: {content}') assert f' Edit Issue: [{issue_key}]' in content, \ params.err_message_issue_not_found logger.locust_info(f"{params.action_name}: Editing issue {issue_key}") locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("705"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("710"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("720"), headers=RESOURCE_HEADERS, catch_response=True) locust.get(f'/rest/internal/2/user/mention/search?issueKey={issue_key}' f'&projectKey={project_key}&maxResults=10&_={timestamp_int()}', catch_response=True) edit_body = f'id={issue_id}&summary={generate_random_string(15)}&issueType={issue_type}&priority={priority}' \ f'&dueDate=""&assignee={assignee}&reporter={reporter}&environment=""' \ f'&description={generate_random_string(500)}&timetracking_originalestimate=""' \ f'&timetracking_remainingestimate=""&isCreateIssue=""&hasWorkStarted=""&dnd-dropzone=""' \ f'&comment=""&commentLevel=""&atl_token={atl_token}&Update=Update' locust.session_data_storage['edit_issue_body'] = edit_body locust.session_data_storage['atl_token'] = atl_token
def view_issue(locust): raise_if_login_failed(locust) params = BrowseIssue() issue_key = random.choice(jira_dataset['issues'])[0] project_key = random.choice(jira_dataset['issues'])[2] r = locust.get(f'/browse/{issue_key}', catch_response=True) content = r.content.decode('utf-8') issue_id = fetch_by_re(params.issue_id_pattern, content) project_avatar_id = fetch_by_re(params.project_avatar_id_pattern, content) edit_allowed = fetch_by_re(params.edit_allow_pattern, content, group_no=0) locust.get(f'/secure/projectavatar?avatarId={project_avatar_id}', catch_response=True) # Assertions if not (f'<meta name="ajs-issue-key" content="{issue_key}">' in content): logger.error(f'Issue {issue_key} not found: {content}') assert f'<meta name="ajs-issue-key" content="{issue_key}">' in content, 'Issue not found' logger.locust_info( f"{params.action_name}: Issue {issue_key} is opened successfully") logger.locust_info( f'{params.action_name}: Issue key - {issue_key}, issue_id - {issue_id}' ) if edit_allowed: url = f'/secure/AjaxIssueEditAction!default.jspa?decorator=none&issueId={issue_id}&_={timestamp_int()}' locust.get(url, catch_response=True) locust.client.put(f'/rest/projects/1.0/project/{project_key}/lastVisited', params.browse_project_payload, catch_response=True)
def view_dashboard(locust): raise_if_login_failed(locust) params = ViewDashboard() r = locust.get('/index.action', catch_response=True) content = r.content.decode('utf-8') keyboard_hash = fetch_by_re(params.keyboard_hash_re, content) build_number = fetch_by_re(params.build_number_re, content) if 'quick-search' not in content or 'Log Out' not in content: logger.error(f'Could not view dashboard: {content}') assert 'quick-search' in content and 'Log Out' in content, 'Could not view dashboard.' locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("205"), headers=RESOURCE_HEADERS, catch_response=True) locust.get('/rest/mywork/latest/status/notification/count', catch_response=True) locust.get( f'/rest/shortcuts/latest/shortcuts/{build_number}/{keyboard_hash}', catch_response=True) locust.get( f'/rest/experimental/search?cql=type=space%20and%20space.type=favourite%20order%20by%20' f'favourite%20desc&expand=space.icon&limit=100&_={timestamp_int()}', catch_response=True) r = locust.get( '/rest/dashboardmacros/1.0/updates?maxResults=40&tab=all&showProfilePic=true&labels=' '&spaces=&users=&types=&category=&spaceKey=', catch_response=True) content = r.content.decode('utf-8') if 'changeSets' not in content: logger.error(f'Could not view dashboard macros: {content}') assert 'changeSets' in content, 'Could not view dashboard macros.'
def create_issue_open_quick_create(): raise_if_login_failed(locust) r = locust.post('/secure/QuickCreateIssue!default.jspa?decorator=none', ADMIN_HEADERS, catch_response=True) content = r.content.decode('utf-8') atl_token = fetch_by_re(params.atl_token_pattern, content) form_token = fetch_by_re(params.form_token_pattern, content) issue_type = fetch_by_re(params.issue_type_pattern, content) resolution_done = fetch_by_re(params.resolution_done_pattern, content) fields_to_retain = re.findall(params.fields_to_retain_pattern, content) custom_fields_to_retain = re.findall( params.custom_fields_to_retain_pattern, content) issue_body_params_dict = { 'atl_token': atl_token, 'form_token': form_token, 'issue_type': issue_type, 'project_id': project_id, 'resolution_done': resolution_done, 'fields_to_retain': fields_to_retain, 'custom_fields_to_retain': custom_fields_to_retain } if not ('"id":"project","label":"Project"' in content): logger.error(f'{params.err_message_create_issue}: {content}') assert '"id":"project","label":"Project"' in content, params.err_message_create_issue locust.post('/rest/quickedit/1.0/userpreferences/create', json=params.user_preferences_payload, headers=ADMIN_HEADERS, catch_response=True) locust.session_data_storage[ 'issue_body_params_dict'] = issue_body_params_dict
def create_page_editor(): r = locust.client.get( f'/pages/createpage.action?spaceKey={space_key}&fromPageId={page_id}&src=quick-create', catch_response=True) content = r.content.decode('utf-8') if 'Page Title' not in content: logger.error(f'Could not open page editor: {content}') assert 'Page Title' in content, 'Could not open page editor.' parsed_space_key = fetch_by_re(params.space_key_re, content) atl_token = fetch_by_re(params.atl_token_re, content) content_id = fetch_by_re(params.content_id_re, content) locust.storage['content_id'] = content_id locust.storage['atl_token'] = atl_token locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("705"), TEXT_HEADERS, catch_response=True) locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("710"), TEXT_HEADERS, catch_response=True) locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("715"), TEXT_HEADERS, catch_response=True) locust.client.get('/rest/create-dialog/1.0/storage/quick-create', catch_response=True) locust.client.get( f'/rest/mywork/latest/status/notification/count?pageid=0&_={timestamp_int()}', catch_response=True) locust.client.get( f'/rest/jiraanywhere/1.0/servers?_={timestamp_int()}', catch_response=True) locust.client.get( f'/rest/shortcuts/latest/shortcuts/{build_number}/{keyboard_hash}', catch_response=True) locust.client.get(f'/rest/emoticons/1.0/?_={timestamp_int()}', catch_response=True) locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("750"), TEXT_HEADERS, catch_response=True) heartbeat_activity_body = { "dataType": "json", "contentId": content_id, "draftType": "page", "spaceKey": parsed_space_key, "atl_token": atl_token } r = locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body, TEXT_HEADERS, catch_response=True) content = r.content.decode('utf-8') if atl_token not in content: logger.error(f'Token {atl_token} not found in content: {content}') assert atl_token in content, 'Token not found in content.'
def view_board(locust, board_id, view_backlog=False): params = ViewBoard() if view_backlog: url = f'/secure/RapidBoard.jspa?rapidView={board_id}&view=planning' else: url = f'/secure/RapidBoard.jspa?rapidView={board_id}' r = locust.get(url, catch_response=True) content = r.content.decode('utf-8') project_key = fetch_by_re(params.project_key_pattern, content) project_id = fetch_by_re(params.project_id_pattern, content) project_plan = fetch_by_re(params.project_plan_pattern, content, group_no=2) if project_plan: project_plan = project_plan.replace('\\', '') logger.locust_info(f"{params.action_name}: key = {project_key}, id = {project_id}, plan = {project_plan}") assert f'currentViewConfig\"{{\"id\":{board_id}', 'Could not open board' locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1000"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1005"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1010"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1015"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1020"), headers=RESOURCE_HEADERS, catch_response=True) if project_key: locust.get(f'/rest/api/2/project/{project_key}?_={timestamp_int()}', catch_response=True) locust.get(f'/rest/greenhopper/1.0/xboard/toolSections?mode=work&rapidViewId={board_id}' f'&selectedProjectKey={project_key}&_={timestamp_int()}', catch_response=True) locust.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId={board_id}' f'&selectedProjectKey={project_key}&_={timestamp_int()}', catch_response=True) if view_backlog: locust.get(f'/rest/inline-create/1.0/context/bootstrap?query=' f'project%20%3D%20%22{project_key}%22%20ORDER%20BY%20Rank%20ASC&&_={timestamp_int()}', catch_response=True) else: locust.get(f'/rest/greenhopper/1.0/xboard/toolSections?mode=work&rapidViewId={board_id}' f'&_={timestamp_int()}', catch_response=True) if view_backlog: locust.get(f'/rest/greenhopper/1.0/xboard/plan/backlog/data.json?rapidViewId={board_id}', catch_response=True) else: locust.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId={board_id}', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1025"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1030"), headers=RESOURCE_HEADERS, catch_response=True) if view_backlog: locust.get(f'/rest/greenhopper/1.0/rapidviewconfig/editmodel.json?rapidViewId={board_id}' f'&_={timestamp_int()}', catch_response=True) if project_key: locust.client.put(f'/rest/projects/1.0/project/{project_key}/lastVisited', {"id": f"com.pyxis.greenhopper.jira:project-sidebar-work-{project_plan}"}, catch_response=True)
def login_and_view_dashboard(locust): session_id = str(uuid.uuid4()) locust.cross_action_storage[session_id] = dict() locust.session_data_storage = locust.cross_action_storage[session_id] locust.session_data_storage['app'] = 'confluence' params = Login() user = random.choice(confluence_dataset["users"]) username = user[0] password = user[1] login_body = params.login_body login_body['os_username'] = username login_body['os_password'] = password locust.post('/dologin.action', login_body, TEXT_HEADERS, catch_response=True) r = locust.get(url='/', catch_response=True) content = r.content.decode('utf-8') if 'Log Out' not in content: logger.error(f'Login with {username}, {password} failed: {content}') assert 'Log Out' in content, 'User authentication failed.' logger.locust_info(f'User {username} is successfully logged in') keyboard_hash = fetch_by_re(params.keyboard_hash_re, content) build_number = fetch_by_re(params.build_number_re, content) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("010"), headers=RESOURCE_HEADERS, catch_response=True) locust.get('/rest/mywork/latest/status/notification/count', catch_response=True) locust.get( f'/rest/shortcuts/latest/shortcuts/{build_number}/{keyboard_hash}', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("025"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/experimental/search?cql=type=space%20and%20space.type=favourite%20order%20by%20favourite' f'%20desc&expand=space.icon&limit=100&_={timestamp_int()}', catch_response=True) locust.get( '/rest/dashboardmacros/1.0/updates?maxResults=40&tab=all&showProfilePic=true&labels=' '&spaces=&users=&types=&category=&spaceKey=', catch_response=True) locust.session_data_storage['build_number'] = build_number locust.session_data_storage['keyboard_hash'] = keyboard_hash locust.session_data_storage['username'] = user[0] locust.session_data_storage['password'] = user[1]
def search_jql(locust): raise_if_login_failed(locust) params = SearchJql() jql = random.choice(jira_dataset['jqls'])[0] r = locust.get(f'/issues/?jql={jql}', catch_response=True) content = r.content.decode('utf-8') if not (locust.session_data_storage["token"] in content): logger.error(f'Can not search by {jql}: {content}') assert locust.session_data_storage["token"] in content, 'Can not search by jql' locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("305"), headers=RESOURCE_HEADERS, catch_response=True) locust.get(f'/rest/api/2/filter/favourite?expand=subscriptions[-5:]&_={timestamp_int()}', catch_response=True) locust.post('/rest/issueNav/latest/preferredSearchLayout', params={'layoutKey': 'split-view'}, headers=NO_TOKEN_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("320"), headers=RESOURCE_HEADERS, catch_response=True) r = locust.post('/rest/issueNav/1/issueTable', data=params.issue_table_payload, headers=NO_TOKEN_HEADERS, catch_response=True) content = r.content.decode('utf-8') issue_ids = re.findall(params.ids_pattern, content) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("330"), headers=RESOURCE_HEADERS, catch_response=True) if issue_ids: body = params.prepare_jql_body(issue_ids) r = locust.post('/rest/issueNav/1/issueTable/stable', data=body, headers=NO_TOKEN_HEADERS, catch_response=True) content = r.content.decode('utf-8') issue_key = fetch_by_re(params.issue_key_pattern, content) issue_id = fetch_by_re(params.issue_id_pattern, content) locust.post('/secure/QueryComponent!Jql.jspa', params={'jql': 'order by created DESC', 'decorator': None}, headers=TEXT_HEADERS, catch_response=True) locust.post('/rest/orderbycomponent/latest/orderByOptions/primary', json={"jql": "order by created DESC"}, headers=RESOURCE_HEADERS, catch_response=True) if issue_ids: r = locust.post('/secure/AjaxIssueAction!default.jspa', params={"decorator": None, "issueKey": issue_key, "prefetch": False, "shouldUpdateCurrentProject": False, "loadFields": False, "_": timestamp_int()}, headers=TEXT_HEADERS, catch_response=True) if params.edit_allow_string in r.content.decode('utf-8'): locust.get(f'/secure/AjaxIssueEditAction!default.jspa?' f'decorator=none&issueId={issue_id}&_={timestamp_int()}', catch_response=True)
def login_and_view_dashboard(locust): params = Login() user = random.choice(jira_dataset["users"]) body = params.login_body body['os_username'] = user[0] body['os_password'] = user[1] locust.client.post('/login.jsp', body, TEXT_HEADERS, catch_response=True) r = locust.client.get('/', catch_response=True) if not r.content: raise Exception('Please check server hostname in jira.yml file') content = r.content.decode('utf-8') locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("110"), TEXT_HEADERS, catch_response=True) locust.client.post( "/plugins/servlet/gadgets/dashboard-diagnostics", {"uri": f"{locust.client.base_url.lower()}/secure/Dashboard.jspa"}, TEXT_HEADERS, catch_response=True) locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("120"), TEXT_HEADERS, catch_response=True) locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("125"), TEXT_HEADERS, catch_response=True) locust.client.post('/rest/webResources/1.0/resources', params.resources_body.get("130"), TEXT_HEADERS, catch_response=True) locust.client.get( f'/rest/activity-stream/1.0/preferences?_={timestamp_int()}', catch_response=True) locust.client.get( f'/rest/gadget/1.0/issueTable/jql?num=10&tableContext=jira.table.cols.dashboard' f'&addDefault=true&enableSorting=true&paging=true&showActions=true' f'&jql=assignee+%3D+currentUser()+AND' f'+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC' f'&sortBy=&startIndex=0&_={timestamp_int()}', catch_response=True) locust.client.get( f'/plugins/servlet/streams?maxResults=5&relativeLinks=true&_={timestamp_int()}', catch_response=True) # Assertions token = fetch_by_re(params.atl_token_pattern, content) if not (f'title="loggedInUser" value="{user[0]}">' in content): logger.error(f'User {user[0]} authentication failed: {content}') assert f'title="loggedInUser" value="{user[0]}">' in content, 'User authentication failed' locust.user = user[0] locust.atl_token = token locust.storage = dict( ) # Define locust storage dict for getting cross-functional variables access logger.locust_info( f"{params.action_name}: User {user[0]} logged in with atl_token: {token}" )
def like_page(locust): raise_if_login_failed(locust) params = LikePage() page = random.choice(confluence_dataset["pages"]) page_id = page[0] JSON_HEADERS['Origin'] = CONFLUENCE_SETTINGS.server_url r = locust.get(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True) content = r.content.decode('utf-8') like = fetch_by_re(params.like_re, content) if like is None: r = locust.post(f'/rest/likes/1.0/content/{page_id}/likes', headers=JSON_HEADERS, catch_response=True) else: r = locust.client.delete(f'/rest/likes/1.0/content/{page_id}/likes', catch_response=True) content = r.content.decode('utf-8') if 'likes' not in content: logger.error(f"Could not set like to the page {page_id}: {content}") assert 'likes' in r.content.decode( 'utf-8'), 'Could not set like to the page.'
def open_editor(): create_page_id = locust.storage['create_page_id'] r = locust.client.get( f'/pages/editpage.action?pageId={create_page_id}', catch_response=True) content = r.content.decode('utf-8') if '<title>Edit' not in content or 'Update</button>' not in content: logger.error( f'Could not open PAGE {create_page_id} to edit: {content}') assert '<title>Edit' in content and 'Update</button>' in content, \ 'Could not open PAGE to edit.' edit_page_version = fetch_by_re(params.editor_page_version_re, content) edit_atl_token = fetch_by_re(params.atl_token_re, content) edit_space_key = fetch_by_re(params.space_key_re, content) edit_content_id = fetch_by_re(params.content_id_re, content) edit_page_id = fetch_by_re(params.page_id_re, content) edit_parent_page_id = fetch_by_re(params.parent_page_id, content) locust.storage['edit_parent_page_id'] = edit_parent_page_id locust.storage['edit_page_version'] = edit_page_version locust.storage['edit_page_id'] = edit_page_id locust.storage['atl_token'] = edit_atl_token locust.storage['edit_content_id'] = edit_content_id locust.client.get( f'/rest/jiraanywhere/1.0/servers?_={timestamp_int()}', catch_response=True) heartbeat_activity_body = { "dataType": "json", "contentId": edit_content_id, "draftType": "page", "spaceKey": edit_space_key, "atl_token": edit_atl_token } locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body, TEXT_HEADERS, catch_response=True) expand = 'history.createdBy.status%2Chistory.contributors.publishers.users.status' \ '%2Cchildren.comment.version.by.status' locust.client.get( f'/rest/api/content/{edit_page_id}?expand={expand}&_={timestamp_int()}', catch_response=True) locust.client.get(f'/rest/emoticons/1.0/_={timestamp_int()}', catch_response=True) locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body, TEXT_HEADERS, catch_response=True) locust.client.get( f'/rest/ui/1.0/content/{edit_page_id}/labels?_={timestamp_int()}', catch_response=True) locust.client.get('/rest/mywork/latest/status/notification/count', catch_response=True) locust.client.post('/json/startheartbeatactivity.action', heartbeat_activity_body, TEXT_HEADERS, catch_response=True)
def create_issue_submit_form(): raise_if_login_failed(locust) issue_body = params.prepare_issue_body(locust.session_data_storage['issue_body_params_dict'], user=locust.session_data_storage["username"]) r = locust.post('/secure/QuickCreateIssue.jspa?decorator=none', params=issue_body, headers=ADMIN_HEADERS, catch_response=True) content = r.content.decode('utf-8') if '"id":"project","label":"Project"' not in content: logger.error(f'{params.err_message_create_issue}: {content}') assert '"id":"project","label":"Project"' in content, params.err_message_create_issue issue_key = fetch_by_re(params.create_issue_key_pattern, content) logger.locust_info(f"{params.action_name}: Issue {issue_key} was successfully created")
def upload_attachments(locust): raise_if_login_failed(locust) params = UploadAttachments() page = random.choice(confluence_dataset["pages"]) static_content = random.choice(confluence_dataset["static-content"]) file_path = static_content[0] file_name = static_content[2] file_extension = static_content[1] page_id = page[0] r = locust.get(f'/pages/viewpage.action?pageId={page_id}', catch_response=True) content = r.content.decode('utf-8') if not ('Created by' in content and 'Save for later' in content): logger.error(f'Failed to open page {page_id}: {content}') assert 'Created by' in content and 'Save for later' in content, 'Failed to open page to upload attachments.' atl_token_view_issue = fetch_by_re(params.atl_token_view_issue_re, content) multipart_form_data = { "file": (file_name, open(file_path, 'rb'), file_extension) } r = locust.post(f'/pages/doattachfile.action?pageId={page_id}', params={ "atl_token": atl_token_view_issue, "comment_0": "", "comment_1": "", "comment_2": "", "comment_3": "", "comment_4": "0", "confirm": "Attach" }, files=multipart_form_data, catch_response=True) content = r.content.decode('utf-8') if not ('Upload file' in content and 'Attach more files' in content): logger.error(f'Could not upload attachments: {content}') assert 'Upload file' in content and 'Attach more files' in content, 'Could not upload attachments.'
def agent_login_and_view_dashboard(locust, jsm_agent_dataset): session_id = str(uuid.uuid4()) locust.cross_action_storage[session_id] = dict() locust.session_data_storage = locust.cross_action_storage[session_id] locust.session_data_storage['app'] = 'jsm' params = Login() # Define dataset for further actions user = random.choice(jsm_agent_dataset["agents"]) small_project = random.choice(jsm_agent_dataset['s_project']) medium_project = None if jsm_agent_dataset['m_project']: medium_project = random.choice(jsm_agent_dataset['m_project']) request = random.choice(jsm_agent_dataset['requests']) locust.session_data_storage['request_id'] = request[0] locust.session_data_storage['request_key'] = request[1] locust.session_data_storage['request_service_desk_id'] = request[2] locust.session_data_storage['request_project_id'] = request[3] locust.session_data_storage['request_project_key'] = request[4] locust.session_data_storage['s_project_id'] = small_project[1] locust.session_data_storage['s_project_key'] = small_project[2] locust.session_data_storage['s_project_all_open_queue_id'] = small_project[ 4] locust.session_data_storage[ 's_created_vs_resolved_queue_id'] = small_project[5] locust.session_data_storage['s_time_to_resolution_id'] = small_project[6] # Medium project dataset definition if medium_project: locust.session_data_storage['m_project_id'] = medium_project[1] locust.session_data_storage['m_project_key'] = medium_project[2] locust.session_data_storage[ 'm_project_all_open_queue_id'] = medium_project[4] locust.session_data_storage[ 'm_created_vs_resolved_queue_id'] = medium_project[5] locust.session_data_storage[ 'm_time_to_resolution_id'] = medium_project[6] body = params.login_body body['os_username'] = user[0] body['os_password'] = user[1] locust.post('/login.jsp', body, TEXT_HEADERS, catch_response=True) r = locust.get('/', catch_response=True) if not r.content: raise Exception('Please check server hostname in jsm.yml file') content = r.content.decode('utf-8') locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("110"), headers=RESOURCE_HEADERS, catch_response=True) locust.post( "/plugins/servlet/gadgets/dashboard-diagnostics", {"uri": f"{locust.client.base_url.lower()}/secure/Dashboard.jspa"}, TEXT_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("120"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("125"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("130"), headers=RESOURCE_HEADERS, catch_response=True) locust.get(f'/rest/activity-stream/1.0/preferences?_={timestamp_int()}', catch_response=True) locust.get( f'/rest/gadget/1.0/issueTable/jql?num=10&tableContext=jira.table.cols.dashboard' f'&addDefault=true&enableSorting=true&paging=true&showActions=true' f'&jql=assignee+%3D+currentUser()+AND' f'+resolution+%3D+unresolved+ORDER+BY+priority+DESC%2C+created+ASC' f'&sortBy=&startIndex=0&_={timestamp_int()}', catch_response=True) locust.get( f'/plugins/servlet/streams?maxResults=5&relativeLinks=true&_={timestamp_int()}', catch_response=True) # Assertions token = fetch_by_re(params.atl_token_pattern, content) if not (f'title="loggedInUser" value="{user[0]}">' in content): logger.error(f'User {user[0]} authentication failed: {content}') assert f'title="loggedInUser" value="{user[0]}">' in content, 'User authentication failed' locust.session_data_storage['username'] = user[0] locust.session_data_storage['password'] = user[1] locust.session_data_storage["token"] = token logger.locust_info( f"{params.action_name}: User {user[0]} logged in with atl_token: {token}" )
def create_page(): raise_if_login_failed(locust) draft_name = f"{generate_random_string(10, only_letters=True)}" content_id = locust.session_data_storage['content_id'] atl_token = locust.session_data_storage['atl_token'] create_page_body = { "status": "current", "title": f"Test Performance JMeter {draft_name}", "space": { "key": f"{space_key}" }, "body": { "storage": { "value": f"Test Performance Create Page Content {draft_name}", "representation": "storage", "content": { "id": f"{content_id}" } } }, "id": f"{content_id}", "type": "page", "version": { "number": 1 }, "ancestors": [{ "id": f"{page_id}", "type": "page" }] } TEXT_HEADERS['Content-Type'] = 'application/json' TEXT_HEADERS['X-Requested-With'] = 'XMLHttpRequest' r = locust.client.put(f'/rest/api/content/{content_id}?status=draft', json=create_page_body, headers=TEXT_HEADERS, catch_response=True) content = r.content.decode('utf-8') if 'draftId' not in content: logger.error(f'Could not create PAGE draft: {content}') assert 'draftId' in content, 'Could not create PAGE draft.' page_title = fetch_by_re(params.page_title_re, content) r = locust.get(f'{page_title}', catch_response=True) content = r.content.decode('utf-8') if 'Created by' not in content: logger.error(f'Page {page_title} was not created: {content}') assert 'Created by' in content, 'Page was not created.' parent_page_id = fetch_by_re(params.parent_page_id, content) create_page_id = fetch_by_re(params.create_page_id, content) locust.session_data_storage['create_page_id'] = create_page_id locust.session_data_storage['parent_page_id'] = parent_page_id heartbeat_activity_body = { "dataType": "json", "contentId": content_id, "space_key": space_key, "draftType": "page", "atl_token": atl_token } locust.post('/json/stopheartbeatactivity.action', params=heartbeat_activity_body, headers=TEXT_HEADERS, catch_response=True) locust.get('/rest/helptips/1.0/tips', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("795"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/jira-metadata/1.0/metadata/aggregate?pageId={create_page_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/likes/1.0/content/{create_page_id}/likes?commentLikes=true&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/inlinecomments/1.0/comments?containerId={create_page_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/mywork/latest/status/notification/count?pageid={create_page_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/highlighting/1.0/panel-items?pageId={create_page_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/watch-button/1.0/watchState/{create_page_id}?_={timestamp_int()}', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("830"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("835"), headers=RESOURCE_HEADERS, catch_response=True) r = locust.get( f'/plugins/editor-loader/editor.action?parentPageId={parent_page_id}' f'&pageId={create_page_id}&spaceKey={space_key}' f'&atl_after_login_redirect={page_title}&timeout=12000&_={timestamp_int()}', catch_response=True) content = r.content.decode('utf-8') if page_title not in content: logger.error( f'Page editor load failed for page {page_title}: {content}') assert page_title in content, 'Page editor load failed for page.' locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("845"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("850"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("855"), headers=RESOURCE_HEADERS, catch_response=True)
def view_page(): r = locust.get(f'/pages/viewpage.action?pageId={page_id}', catch_response=True) content = r.content.decode('utf-8') if 'Created by' not in content or 'Save for later' not in content: logger.error(f'Fail to open page {page_id}: {content}') assert 'Created by' in content and 'Save for later' in content, 'Could not open page.' parent_page_id = fetch_by_re(params.parent_page_id_re, content) parsed_page_id = fetch_by_re(params.page_id_re, content) space_key = fetch_by_re(params.space_key_re, content) tree_request_id = fetch_by_re(params.tree_result_id_re, content) has_no_root = fetch_by_re(params.has_no_root_re, content) root_page_id = fetch_by_re(params.root_page_id_re, content) atl_token_view_issue = fetch_by_re(params.atl_token_view_issue_re, content) editable = fetch_by_re(params.editable_re, content) ancestor_ids = re.findall(params.ancestor_ids_re, content) ancestor_str = 'ancestors=' for ancestor in ancestor_ids: ancestor_str = ancestor_str + str(ancestor) + '&' locust.session_data_storage['page_id'] = parsed_page_id locust.session_data_storage['has_no_root'] = has_no_root locust.session_data_storage['tree_request_id'] = tree_request_id locust.session_data_storage['root_page_id'] = root_page_id locust.session_data_storage['ancestors'] = ancestor_str locust.session_data_storage['space_key'] = space_key locust.session_data_storage['editable'] = editable locust.session_data_storage[ 'atl_token_view_issue'] = atl_token_view_issue locust.get('/rest/helptips/1.0/tips', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("110"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/likes/1.0/content/{parsed_page_id}/likes?commentLikes=true&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/highlighting/1.0/panel-items?pageId={parsed_page_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/mywork/latest/status/notification/count?pageId={parsed_page_id}&_={timestamp_int()}', catch_response=True) r = locust.get( f'/rest/inlinecomments/1.0/comments?containerId={parsed_page_id}&_={timestamp_int()}', catch_response=True) content = r.content.decode('utf-8') if 'authorDisplayName' not in content and '[]' not in content: logger.error( f'Could not open comments for page {parsed_page_id}: {content}' ) assert 'authorDisplayName' in content or '[]' in content, 'Could not open comments for page.' locust.get( f'/plugins/editor-loader/editor.action?parentPageId={parent_page_id}&pageId={parsed_page_id}' f'&spaceKey={space_key}&atl_after_login_redirect=/pages/viewpage.action' f'&timeout=12000&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/watch-button/1.0/watchState/{parsed_page_id}?_={timestamp_int()}', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("145"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("150"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("155"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("160"), headers=RESOURCE_HEADERS, catch_response=True)
def create_blog_editor(): raise_if_login_failed(locust) r = locust.get( f'/pages/createblogpost.action?spaceKey={blog_space_key}', catch_response=True) content = r.content.decode('utf-8') if 'Blog post title' not in content: logger.error( f'Could not open editor for {blog_space_key}: {content}') assert 'Blog post title' in content, 'Could not open editor for blog.' atl_token = fetch_by_re(params.atl_token_re, content) content_id = fetch_by_re(params.content_id_re, content) parsed_space_key = fetch_by_re(params.space_key, content) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("910"), headers=RESOURCE_HEADERS, catch_response=True) locust.get('/rest/mywork/latest/status/notification/count?pageId=0', catch_response=True) locust.get('/plugins/servlet/notifications-miniview', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("925"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("930"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/shortcuts/latest/shortcuts/{build_number}/{keyboard_hash}?_={timestamp_int()}', catch_response=True) heartbeat_activity_body = { "dataType": "json", "contentId": content_id, "draftType": "blogpost", "spaceKey": parsed_space_key, "atl_token": atl_token } r = locust.post('/json/startheartbeatactivity.action', heartbeat_activity_body, TEXT_HEADERS, catch_response=True) content = r.content.decode('utf-8') if atl_token not in content: logger.error(f'Token {atl_token} not found in content: {content}') assert atl_token in content, 'Token not found in content.' contributor_hash = fetch_by_re(params.contribution_hash, content) locust.session_data_storage['contributor_hash'] = contributor_hash r = locust.get(f'/rest/ui/1.0/content/{content_id}/labels', catch_response=True) content = r.content.decode('utf-8') if '"success":true' not in content: logger.error( f'Could not get labels for content {content_id}: {content}') assert '"success":true' in content, 'Could not get labels for content in blog editor.' draft_name = f"Performance Blog - {generate_random_string(10, only_letters=True)}" locust.session_data_storage['draft_name'] = draft_name locust.session_data_storage['parsed_space_key'] = parsed_space_key locust.session_data_storage['content_id'] = content_id locust.session_data_storage['atl_token'] = atl_token draft_body = { "draftId": content_id, "pageId": "0", "type": "blogpost", "title": draft_name, "spaceKey": parsed_space_key, "content": "<p>test blog draft</p>", "syncRev": "0.mcPCPtDvwoayMR7zvuQSbf8.27" } TEXT_HEADERS['Content-Type'] = 'application/json' r = locust.post('/rest/tinymce/1/drafts', json=draft_body, headers=TEXT_HEADERS, catch_response=True) content = r.content.decode('utf-8') if 'draftId' not in content: logger.error( f'Could not create blog post draft in space {parsed_space_key}: {content}' ) assert 'draftId' in content, 'Could not create blog post draft.'
def create_blog(): raise_if_login_failed(locust) draft_name = locust.session_data_storage['draft_name'] parsed_space_key = locust.session_data_storage['parsed_space_key'] content_id = locust.session_data_storage['content_id'] atl_token = locust.session_data_storage['atl_token'] draft_body = { "status": "current", "title": draft_name, "space": { "key": f"{parsed_space_key}" }, "body": { "editor": { "value": f"Test Performance Blog Page Content {draft_name}", "representation": "editor", "content": { "id": f"{content_id}" } } }, "id": f"{content_id}", "type": "blogpost", "version": { "number": 1, "minorEdit": True, "syncRev": "0.mcPCPtDvwoayMR7zvuQSbf8.30" } } TEXT_HEADERS['Content-Type'] = 'application/json' r = locust.client.put(f'/rest/api/content/{content_id}?status=draft', json=draft_body, headers=TEXT_HEADERS, catch_response=True) content = r.content.decode('utf-8') if 'current' not in content or 'title' not in content: logger.error(f'Could not open draft {draft_name}: {content}') assert 'current' in content and 'title' in content, 'Could not open blog draft.' created_blog_title = fetch_by_re(params.created_blog_title_re, content) logger.locust_info(f'Blog {created_blog_title} created') r = locust.get(f'/{created_blog_title}', catch_response=True) content = r.content.decode('utf-8') if 'Created by' not in content: logger.error( f'Could not open created blog {created_blog_title}: {content}') assert 'Created by' in content, 'Could not open created blog.' locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("970"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("975"), headers=RESOURCE_HEADERS, catch_response=True) locust.get('/plugins/servlet/notifications-miniview', catch_response=True) locust.get( f'/rest/watch-button/1.0/watchState/{content_id}?_={timestamp_int()}', catch_response=True) locust.get( f'/rest/likes/1.0/content/{content_id}/likes?commentLikes=true&_={timestamp_int()}', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("995"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/highlighting/1.0/panel-items?pageId={content_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/inlinecomments/1.0/comments?containerId={content_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/s/en_GB/{build_number}/{keyboard_hash}/_/images/icons/profilepics/add_profile_pic.svg', catch_response=True) locust.get('/rest/helptips/1.0/tips', catch_response=True) locust.get( f'/rest/mywork/latest/status/notification/count?pageid={content_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/plugins/editor-loader/editor.action?parentPageId=&pageId={content_id}' f'&spaceKey={parsed_space_key}&atl_after_login_redirect={created_blog_title}' f'&timeout=12000&_={timestamp_int()}', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1030"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1035"), headers=RESOURCE_HEADERS, catch_response=True) heartbeat_activity_body = { "dataType": "json", "contentId": content_id, "draftType": "blogpost", "spaceKey": parsed_space_key, "atl_token": atl_token } r = locust.post('/json/startheartbeatactivity.action', heartbeat_activity_body, TEXT_HEADERS, catch_response=True) content = r.content.decode('utf-8') if atl_token not in content: logger.error(f'Token {atl_token} not found in content: {content}') assert atl_token in content, 'Token not found in content.'
def view_blog(locust): raise_if_login_failed(locust) params = ViewBlog() blog = random.choice(confluence_dataset["blogs"]) blog_id = blog[0] r = locust.get(f'/pages/viewpage.action?pageId={blog_id}', catch_response=True) content = r.content.decode('utf-8') if 'Created by' not in content or 'Save for later' not in content: logger.error(f'Fail to open blog {blog_id}: {content}') assert 'Created by' in content and 'Save for later' in content, 'Could not view blog.' parent_page_id = fetch_by_re(params.parent_page_id_re, content) parsed_blog_id = fetch_by_re(params.page_id_re, content) space_key = fetch_by_re(params.space_key_re, content) locust.get('/rest/helptips/1.0/tips', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("310"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/likes/1.0/content/{parsed_blog_id}/likes?commentLikes=true&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/highlighting/1.0/panel-items?pageId={parsed_blog_id}&_={timestamp_int()}', catch_response=True) locust.get( f'/rest/mywork/latest/status/notification/count?pageId={parsed_blog_id}&_={timestamp_int()}', catch_response=True) r = locust.get( f'/rest/inlinecomments/1.0/comments?containerId={parsed_blog_id}&_={timestamp_int()}', catch_response=True) content = r.content.decode('utf-8') if 'authorDisplayName' not in content and '[]' not in content: logger.error( f'Could not open comments for page {parsed_blog_id}: {content}') assert 'authorDisplayName' in content or '[]' in content, 'Could not open comments for page.' r = locust.get( f'/plugins/editor-loader/editor.action?parentPageId={parent_page_id}&pageId={parsed_blog_id}' f'&spaceKey={space_key}&atl_after_login_redirect=/pages/viewpage.action' f'&timeout=12000&_={timestamp_int()}', catch_response=True) content = r.content.decode('utf-8') if 'draftId' not in content: logger.error( f'Could not open editor for blog {parsed_blog_id}: {content}') assert 'draftId' in content, 'Could not open editor for blog.' locust.get( f'/rest/watch-button/1.0/watchState/{parsed_blog_id}?_={timestamp_int()}', catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("345"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("350"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("355"), headers=RESOURCE_HEADERS, catch_response=True) locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("360"), headers=RESOURCE_HEADERS, catch_response=True) locust.get( f'/rest/quickreload/latest/{parsed_blog_id}?since={timestamp_int()}&_={timestamp_int()}', catch_response=True)
def kanban_board(locust, board_id): params = ViewBoard(action_name='view_kanban_board') url = f'/secure/RapidBoard.jspa?rapidView={board_id}' # 1000 /secure/RapidBoard.jspa r = locust.get(url, catch_response=True) content = r.content.decode('utf-8') project_key = fetch_by_re(params.project_key_pattern, content) project_id = fetch_by_re(params.project_id_pattern, content) project_plan = fetch_by_re(params.project_plan_pattern, content, group_no=2) if project_plan: project_plan = project_plan.replace('\\', '') logger.locust_info(f"{params.action_name}: key = {project_key}, id = {project_id}, plan = {project_plan}") assert f'currentViewConfig\"{{\"id\":{board_id}', 'Could not open board' # 1005 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1005"), headers=RESOURCE_HEADERS, catch_response=True) # 1010 /rest/greenhopper/1.0/xboard/config.json locust.get(f'/rest/greenhopper/1.0/xboard/config.json?' f'returnDefaultBoard=true' f'&_={timestamp_int()}', catch_response=True) # 1015 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1015"), headers=RESOURCE_HEADERS, catch_response=True) # 1025 /rest/analytics/1.0/publish/bulk locust.post('/rest/analytics/1.0/publish/bulk', json=params.resources_body.get("1025"), headers=RESOURCE_HEADERS, catch_response=True) if project_key: # 1030 /rest/api/2/project/${x_project_key} locust.get(f'/rest/api/2/project/{project_key}?_={timestamp_int()}', catch_response=True) # 1035 /rest/projects/1.0/project/{project_key}/lastVisited locust.client.put(f'/rest/projects/1.0/project/{project_key}/lastVisited', {"id": f"com.pyxis.greenhopper.jira:project-sidebar-work-{project_plan}"}, catch_response=True) # 1040 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1040"), headers=RESOURCE_HEADERS, catch_response=True) else: # 1045 /rest/greenhopper/1.0/xboard/toolSections locust.get(f'/rest/greenhopper/1.0/xboard/toolSections?mode=work&rapidViewId={board_id}' f'&_={timestamp_int()}', catch_response=True) # 1050 /rest/greenhopper/1.0/xboard/work/allData.json locust.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?rapidViewId={board_id}', catch_response=True) if project_id: # 1055 /rest/greenhopper/1.0/xboard/work/transitions.json locust.get(f'/rest/greenhopper/1.0/xboard/work/transitions.json?' f'projectId={project_id}' f'&_={timestamp_int()}') # 1060 /rest/analytics/1.0/publish/bulk locust.post('/rest/analytics/1.0/publish/bulk', json=params.resources_body.get("1060"), headers=RESOURCE_HEADERS, catch_response=True) if project_key: # 1065 /rest/projects/1.0/project/{project_key}/lastVisited locust.client.put(f'/rest/projects/1.0/project/{project_key}/lastVisited', {"id": f"com.pyxis.greenhopper.jira:project-sidebar-work-{project_plan}"}, catch_response=True)
def scrum_board(locust, board_id): params = ViewBoard(action_name='view_scrum_board') # 1100 /secure/RapidBoard.jspa r = locust.get(f'/secure/RapidBoard.jspa?rapidView={board_id}', catch_response=True) content = r.content.decode('utf-8') project_key = fetch_by_re(params.project_key_pattern, content) project_id = fetch_by_re(params.project_id_pattern, content) project_plan = fetch_by_re(params.project_plan_pattern, content, group_no=2) if project_plan: project_plan = project_plan.replace('\\', '') logger.locust_info(f"{params.action_name}: key = {project_key}, id = {project_id}, plan = {project_plan}") assert f'currentViewConfig\"{{\"id\":{board_id}', 'Could not open board' # 1110 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1110"), headers=RESOURCE_HEADERS, catch_response=True) # 1115 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1115"), headers=RESOURCE_HEADERS, catch_response=True) if project_key: # 1105 /rest/greenhopper/1.0/xboard/work/allData.json locust.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?' f'rapidViewId={board_id}' f'&selectedProjectKey={project_key}', catch_response=True) # 1120 /rest/api/2/project/{x_project_key} locust.get(f'/rest/api/2/project/{project_key}?' f'_={timestamp_int()}', catch_response=True) # 1125 /rest/greenhopper/1.0/xboard/toolSections locust.get(f'/rest/greenhopper/1.0/xboard/toolSections?' f'mode=work' f'&rapidViewId={board_id}' f'&selectedProjectKey={project_key}' f'&_={timestamp_int()}', catch_response=True) # 1130 /rest/greenhopper/1.0/xboard/work/allData.json locust.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?' f'rapidViewId={board_id}' f'&selectedProjectKey={project_key}', catch_response=True) # 1060 /rest/projects/1.0/project/{project_key}/lastVisited locust.client.put(f'/rest/projects/1.0/project/{project_key}/lastVisited', {"id": f"com.pyxis.greenhopper.jira:project-sidebar-work-{project_plan}"}, catch_response=True) if not project_key: # 1140 /rest/greenhopper/1.0/xboard/toolSections locust.get(f'/rest/greenhopper/1.0/xboard/toolSections?' f'mode=work' f'&rapidViewId={board_id}' f'&_={timestamp_int()}', catch_response=True) # 1145 /rest/greenhopper/1.0/xboard/work/allData.json locust.get(f'/rest/greenhopper/1.0/xboard/work/allData.json?' f'rapidViewId={board_id}', catch_response=True) # 1150 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1150"), headers=RESOURCE_HEADERS, catch_response=True) # 1155 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1155"), headers=RESOURCE_HEADERS, catch_response=True) # 1165 /rest/analytics/1.0/publish/bulk locust.post('/rest/analytics/1.0/publish/bulk', json=params.resources_body.get("1165"), headers=RESOURCE_HEADERS, catch_response=True)
def view_issue(locust): raise_if_login_failed(locust) params = BrowseIssue() issue_key = random.choice(jira_dataset['issues'])[0] project_key = random.choice(jira_dataset['issues'])[2] # 400 /browse r = locust.get(f'/browse/{issue_key}', catch_response=True) content = r.content.decode('utf-8') issue_id = fetch_by_re(params.issue_id_pattern, content) project_avatar_id = fetch_by_re(params.project_avatar_id_pattern, content) edit_allowed = fetch_by_re(params.edit_allow_pattern, content, group_no=0) # 405 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("405"), headers=RESOURCE_HEADERS, catch_response=True) # 410 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("410"), headers=RESOURCE_HEADERS, catch_response=True) # 415 /rest/analytics/1.0/publish/bulk locust.post('/rest/analytics/1.0/publish/bulk', json=params.resources_body.get("415"), headers=RESOURCE_HEADERS, catch_response=True) # 420 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("420"), headers=RESOURCE_HEADERS, catch_response=True) # 425 /rest/analytics/1.0/publish/bulk locust.post('/rest/analytics/1.0/publish/bulk', json=params.resources_body.get("425"), headers=RESOURCE_HEADERS, catch_response=True) # 430 /secure/projectavatar locust.get(f'/secure/projectavatar?avatarId={project_avatar_id}', catch_response=True) # Assertions if not (f'<meta name="ajs-issue-key" content="{issue_key}">' in content): logger.error(f'Issue {issue_key} not found: {content}') assert f'<meta name="ajs-issue-key" content="{issue_key}">' in content, 'Issue not found' logger.locust_info(f"{params.action_name}: Issue {issue_key} is opened successfully") logger.locust_info(f'{params.action_name}: Issue key - {issue_key}, issue_id - {issue_id}') # 435 /secure/AjaxIssueEditAction!default.jspa if edit_allowed: url = f'/secure/AjaxIssueEditAction!default.jspa?decorator=none&issueId={issue_id}&_={timestamp_int()}' locust.get(url, catch_response=True) # 440 /rest/projects/1.0/project/<project_key>/lastVisited locust.client.put(f'/rest/projects/1.0/project/{project_key}/lastVisited', params.browse_project_payload, catch_response=True)
def backlog_board(locust, board_id): params = ViewBoard(action_name='view_backlog') # 1200 /secure/RapidBoard.jspa r = locust.get(f'/secure/RapidBoard.jspa?' f'rapidView={board_id}' f'&view=planning', catch_response=True) content = r.content.decode('utf-8') project_key = fetch_by_re(params.project_key_pattern, content) project_id = fetch_by_re(params.project_id_pattern, content) project_plan = fetch_by_re(params.project_plan_pattern, content, group_no=2) if project_plan: project_plan = project_plan.replace('\\', '') logger.locust_info(f"{params.action_name}: key = {project_key}, id = {project_id}, plan = {project_plan}") assert f'currentViewConfig\"{{\"id\":{board_id}', 'Could not open board' # 1210 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1210"), headers=RESOURCE_HEADERS, catch_response=True) # 1215 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1215"), headers=RESOURCE_HEADERS, catch_response=True) if project_key: # 1205 /rest/greenhopper/1.0/xboard/plan/backlog/data.json locust.get(f'/rest/greenhopper/1.0/xboard/plan/backlog/data.json?' f'rapidViewId={board_id}' f'&selectedProjectKey={project_key}', catch_response=True) # 1235 /rest/api/2/project/{project_key} locust.get(f'/rest/api/2/project/{project_key}?_={timestamp_int()}', catch_response=True) # 1240 /rest/greenhopper/1.0/xboard/toolSections locust.get(f'/rest/greenhopper/1.0/xboard/toolSections?' f'mode=plan' f'&rapidViewId={board_id}' f'&selectedProjectKey={project_key}' f'&_={timestamp_int()}', catch_response=True) # 1245 /rest/greenhopper/1.0/xboard/plan/backlog/data.json locust.get(f'/rest/greenhopper/1.0/xboard/plan/backlog/data.json?' f'&rapidViewId={board_id}' f'&selectedProjectKey={project_key}' f'&_={timestamp_int()}', catch_response=True) # 1250 /rest/inline-create/1.0/context/bootstrap locust.get(f'/rest/inline-create/1.0/context/bootstrap?' f'&query=project = {project_key} ORDER BY Rank ASC' f'&_={timestamp_int()}', catch_response=True) # 1255 /rest/webResources/1.0/resources locust.post('/rest/webResources/1.0/resources', json=params.resources_body.get("1255"), headers=RESOURCE_HEADERS, catch_response=True) # 1260 /rest/analytics/1.0/publish/bulk locust.post('/rest/analytics/1.0/publish/bulk', json=params.resources_body.get("1260"), headers=RESOURCE_HEADERS, catch_response=True) # 1265 /rest/analytics/1.0/publish/bulk locust.post('/rest/analytics/1.0/publish/bulk', json=params.resources_body.get("1265"), headers=RESOURCE_HEADERS, catch_response=True) # 1285 /rest/projects/1.0/project/{project_key}/lastVisited locust.client.put(f'/rest/projects/1.0/project/{project_key}/lastVisited', {"id": f"com.pyxis.greenhopper.jira:project-sidebar-work-{project_plan}"}, catch_response=True) if not project_key: # 1270 /rest/greenhopper/1.0/xboard/toolSections locust.get(f'/rest/greenhopper/1.0/xboard/toolSections?' f'mode=plan' f'&rapidViewId={board_id}' f'&_={timestamp_int()}', catch_response=True) # 1275 /rest/greenhopper/1.0/xboard/plan/backlog/data.json locust.get(f'/rest/greenhopper/1.0/xboard/plan/backlog/data.json?' f'rapidViewId={board_id}', catch_response=True) # 1280 /rest/greenhopper/1.0/rapidviewconfig/editmodel.json locust.get(f'/rest/greenhopper/1.0/rapidviewconfig/editmodel.json?' f'rapidViewId={board_id}' f'&_={timestamp_int()}', catch_response=True)