Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task/WP-288: Implement Queue Filter #883

Merged
merged 8 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions client/src/components/Applications/AppForm/AppForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const appShape = PropTypes.shape({
coresPerNode: PropTypes.number,
maxMinutes: PropTypes.number,
tags: PropTypes.arrayOf(PropTypes.string),
queueFilter: PropTypes.arrayOf(PropTypes.string),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can drop these changes on lines 47 and 272, as these don't correspond to default fields on the form

Copy link
Collaborator Author

@tjgrafft tjgrafft Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep this change addresses Chandra's comment, in regard to getting rid of 47 and 272 gets rid of queueFilter showing up in the job submission payload.

}),
systemNeedsKeys: PropTypes.bool,
pushKeysSystem: PropTypes.shape({}),
Expand Down Expand Up @@ -268,6 +269,7 @@ export const AppSchemaForm = ({ app }) => {
appId: app.definition.id,
appVersion: app.definition.version,
execSystemId: app.definition.jobAttributes.execSystemId,
queueFilter: app.definition.notes.queueFilter,
};

let missingAllocation = false;
Expand Down Expand Up @@ -692,11 +694,21 @@ export const AppSchemaForm = ({ app }) => {
)
.map((q) => q.name)
.sort()
.map((queueName) => (
<option key={queueName} value={queueName}>
{queueName}
</option>
))
.map((queueName) =>
app.definition.notes.queueFilter ? (
app.definition.notes.queueFilter.includes(
queueName
) && (
<option key={queueName} value={queueName}>
{queueName}
</option>
)
) : (
<option key={queueName} value={queueName}>
{queueName}
</option>
)
)
.sort()}
</FormField>
)}
Expand Down
55 changes: 55 additions & 0 deletions client/src/components/Applications/AppForm/AppForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,3 +442,58 @@ describe('AppDetail', () => {
).toBeDefined();
});
});

const mockAppWithQueueFilter = {
...helloWorldAppFixture,
definition: {
...helloWorldAppFixture.definition,
notes: {
...helloWorldAppFixture.definition.notes,
queueFilter: ['rtx', 'small'],
},
},
};

const mockAppWithoutQueueFilter = {
...helloWorldAppFixture,
definition: {
...helloWorldAppFixture.definition,
notes: {
...helloWorldAppFixture.definition.notes,
queueFilter: null,
},
},
};

describe('AppSchemaForm queueFilter tests', () => {
it('renders only the queues specified in the queueFilter', () => {
const { container } = renderAppSchemaFormComponent(
mockStore(initialMockState),
mockAppWithQueueFilter
);

const targetDropdown = container.querySelector(
'select[name="execSystemLogicalQueue"]'
);
const options = Array.from(targetDropdown.querySelectorAll('option'));
expect(options).toHaveLength(2);
expect(options[0].textContent).toBe('rtx');
expect(options[1].textContent).toBe('small');
});

it('renders all queues when no queueFilter is present', () => {
const { container } = renderAppSchemaFormComponent(
mockStore(initialMockState),
mockAppWithoutQueueFilter
);

const targetDropdown = container.querySelector(
'select[name="execSystemLogicalQueue"]'
);
const options = Array.from(targetDropdown.querySelectorAll('option'));
expect(options).toHaveLength(3);
expect(options[0].textContent).toBe('development');
expect(options[1].textContent).toBe('rtx');
expect(options[2].textContent).toBe('small');
});
});