1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 describe('Process tests', function() {
10 // Only set up common users once. These aren't set up as aliases because
11 // aliases are cleaned up after every test. Also it doesn't make sense
12 // to set the same users on beforeEach() over and over again, so we
13 // separate a little from Cypress' 'Best Practices' here.
14 cy.getUser('admin', 'Admin', 'User', true, true)
15 .as('adminUser').then(function() {
16 adminUser = this.adminUser;
19 cy.getUser('user', 'Active', 'User', false, true)
20 .as('activeUser').then(function() {
21 activeUser = this.activeUser;
26 beforeEach(function() {
28 cy.clearLocalStorage();
31 function setupDockerImage(image_name) {
32 // Create a collection that will be used as a docker image for the tests.
33 cy.createCollection(adminUser.token, {
35 manifest_text: ". d21353cfe035e3e384563ee55eadbb2f+67108864 5c77a43e329b9838cbec18ff42790e57+55605760 0:122714624:sha256:d8309758b8fe2c81034ffc8a10c36460b77db7bc5e7b448c4e5b684f9d95a678.tar\n"
36 }).as('dockerImage').then(function(dockerImage) {
37 // Give read permissions to the active user on the docker image.
38 cy.createLink(adminUser.token, {
39 link_class: 'permission',
41 tail_uuid: activeUser.user.uuid,
42 head_uuid: dockerImage.uuid
43 }).as('dockerImagePermission').then(function() {
44 // Set-up docker image collection tags
45 cy.createLink(activeUser.token, {
46 link_class: 'docker_image_repo+tag',
48 head_uuid: dockerImage.uuid,
49 }).as('dockerImageRepoTag');
50 cy.createLink(activeUser.token, {
51 link_class: 'docker_image_hash',
52 name: 'sha256:d8309758b8fe2c81034ffc8a10c36460b77db7bc5e7b448c4e5b684f9d95a678',
53 head_uuid: dockerImage.uuid,
54 }).as('dockerImageHash');
57 return cy.getAll('@dockerImage', '@dockerImageRepoTag', '@dockerImageHash',
58 '@dockerImagePermission').then(function([dockerImage]) {
63 function createContainerRequest(user, name, docker_image, command, reuse = false, state = 'Uncommitted') {
64 return setupDockerImage(docker_image).then(function(dockerImage) {
65 return cy.createContainerRequest(user.token, {
68 container_image: dockerImage.portable_data_hash, // for some reason, docker_image doesn't work here
69 output_path: 'stdout.txt',
71 runtime_constraints: {
87 it('shows process logs', function() {
88 const crName = 'test_container_request';
89 createContainerRequest(
93 ['echo', 'hello world'],
95 .then(function(containerRequest) {
96 cy.loginAs(activeUser);
97 cy.goToPath(`/processes/${containerRequest.uuid}`);
98 cy.get('[data-cy=process-details]').should('contain', crName);
99 cy.get('[data-cy=process-logs]')
100 .should('contain', 'No logs yet')
101 .and('not.contain', 'hello world');
102 cy.createLog(activeUser.token, {
103 object_uuid: containerRequest.container_uuid,
108 }).then(function(log) {
109 cy.get('[data-cy=process-logs]')
110 .should('not.contain', 'No logs yet')
111 .and('contain', 'hello world');
116 it('filters process logs by event type', function() {
117 const nodeInfoLogs = [
119 'Linux compute-99cb150b26149780de44b929577e1aed-19rgca8vobuvc4p 5.4.0-1059-azure #62~18.04.1-Ubuntu SMP Tue Sep 14 17:53:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux',
122 'vendor_id : GenuineIntel',
125 'model name : Intel(R) Xeon(R) CPU E5-2673 v4 @ 2.30GHz'
127 const crunchRunLogs = [
128 '2022-03-22T13:56:22.542417997Z using local keepstore process (pid 3733) at http://localhost:46837, writing logs to keepstore.txt in log collection',
129 '2022-03-22T13:56:26.237571754Z crunch-run 2.4.0~dev20220321141729 (go1.17.1) started',
130 '2022-03-22T13:56:26.244704134Z crunch-run process has uid=0(root) gid=0(root) groups=0(root)',
131 '2022-03-22T13:56:26.244862836Z Executing container \'zzzzz-dz642-1wokwvcct9s9du3\' using docker runtime',
132 '2022-03-22T13:56:26.245037738Z Executing on host \'compute-99cb150b26149780de44b929577e1aed-19rgca8vobuvc4p\'',
135 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dui nisi, hendrerit porta sapien a, pretium dignissim purus.',
136 'Integer viverra, mauris finibus aliquet ultricies, dui mauris cursus justo, ut venenatis nibh ex eget neque.',
137 'In hac habitasse platea dictumst.',
138 'Fusce fringilla turpis id accumsan faucibus. Donec congue congue ex non posuere. In semper mi quis tristique rhoncus.',
139 'Interdum et malesuada fames ac ante ipsum primis in faucibus.',
140 'Quisque fermentum tortor ex, ut suscipit velit feugiat faucibus.',
141 'Donec vitae porta risus, at luctus nulla. Mauris gravida iaculis ipsum, id sagittis tortor egestas ac.',
142 'Maecenas condimentum volutpat nulla. Integer lacinia maximus risus eu posuere.',
143 'Donec vitae leo id augue gravida bibendum.',
144 'Nam libero libero, pretium ac faucibus elementum, mattis nec ex.',
145 'Nullam id laoreet nibh. Vivamus tellus metus, pretium quis justo ut, bibendum varius metus. Pellentesque vitae accumsan lorem, quis tincidunt augue.',
146 'Aliquam viverra nisi nulla, et efficitur dolor mattis in.',
147 'Sed at enim sit amet nulla tincidunt mattis. Aenean eget aliquet ex, non ultrices ex. Nulla ex tortor, vestibulum aliquam tempor ac, aliquam vel est.',
148 'Fusce auctor faucibus libero id venenatis. Etiam sodales, odio eu cursus efficitur, quam sem blandit ex, quis porttitor enim dui quis lectus. In id tincidunt felis.',
149 'Phasellus non ex quis arcu tempus faucibus molestie in sapien.',
150 'Duis tristique semper dolor, vitae pulvinar risus.',
151 'Aliquam tortor elit, luctus nec tortor eget, porta tristique nulla.',
152 'Nulla eget mollis ipsum.',
155 createContainerRequest(
157 'test_container_request',
159 ['echo', 'hello world'],
161 .then(function(containerRequest) {
162 cy.logsForContainer(activeUser.token, containerRequest.container_uuid,
163 'node-info', nodeInfoLogs).as('nodeInfoLogs');
164 cy.logsForContainer(activeUser.token, containerRequest.container_uuid,
165 'crunch-run', crunchRunLogs).as('crunchRunLogs');
166 cy.logsForContainer(activeUser.token, containerRequest.container_uuid,
167 'stdout', stdoutLogs).as('stdoutLogs');
168 cy.getAll('@stdoutLogs', '@nodeInfoLogs', '@crunchRunLogs').then(function() {
169 cy.loginAs(activeUser);
170 cy.goToPath(`/processes/${containerRequest.uuid}`);
171 // Should should all logs
172 cy.get('[data-cy=process-logs-filter]').should('contain', 'All logs');
173 cy.get('[data-cy=process-logs]')
174 .should('contain', stdoutLogs[Math.floor(Math.random() * stdoutLogs.length)])
175 .and('contain', nodeInfoLogs[Math.floor(Math.random() * nodeInfoLogs.length)])
176 .and('contain', crunchRunLogs[Math.floor(Math.random() * crunchRunLogs.length)]);
177 // Select 'node-info' logs
178 cy.get('[data-cy=process-logs-filter]').click();
179 cy.get('body').contains('li', 'node-info').click();
180 cy.get('[data-cy=process-logs]')
181 .should('not.contain', stdoutLogs[Math.floor(Math.random() * stdoutLogs.length)])
182 .and('contain', nodeInfoLogs[Math.floor(Math.random() * nodeInfoLogs.length)])
183 .and('not.contain', crunchRunLogs[Math.floor(Math.random() * crunchRunLogs.length)]);
184 // Select 'stdout' logs
185 cy.get('[data-cy=process-logs-filter]').click();
186 cy.get('body').contains('li', 'stdout').click();
187 cy.get('[data-cy=process-logs]')
188 .should('contain', stdoutLogs[Math.floor(Math.random() * stdoutLogs.length)])
189 .and('not.contain', nodeInfoLogs[Math.floor(Math.random() * nodeInfoLogs.length)])
190 .and('not.contain', crunchRunLogs[Math.floor(Math.random() * crunchRunLogs.length)]);
195 it('should show runtime status indicators', function() {
196 // Setup running container with runtime_status error & warning messages
197 createContainerRequest(
199 'test_container_request',
201 ['echo', 'hello world'],
203 .as('containerRequest')
204 .then(function(containerRequest) {
205 expect(containerRequest.state).to.equal('Committed');
206 expect(containerRequest.container_uuid).not.to.be.equal('');
208 cy.getContainer(activeUser.token, containerRequest.container_uuid)
209 .then(function(queuedContainer) {
210 expect(queuedContainer.state).to.be.equal('Queued');
212 cy.updateContainer(adminUser.token, containerRequest.container_uuid, {
214 }).then(function(lockedContainer) {
215 expect(lockedContainer.state).to.be.equal('Locked');
217 cy.updateContainer(adminUser.token, lockedContainer.uuid, {
220 error: 'Something went wrong',
221 errorDetail: 'Process exited with status 1',
222 warning: 'Free disk space is low',
225 .as('runningContainer')
226 .then(function(runningContainer) {
227 expect(runningContainer.state).to.be.equal('Running');
228 expect(runningContainer.runtime_status).to.be.deep.equal({
229 'error': 'Something went wrong',
230 'errorDetail': 'Process exited with status 1',
231 'warning': 'Free disk space is low',
236 // Test that the UI shows the error and warning messages
237 cy.getAll('@containerRequest', '@runningContainer').then(function([containerRequest]) {
238 cy.loginAs(activeUser);
239 cy.goToPath(`/processes/${containerRequest.uuid}`);
240 cy.get('[data-cy=process-runtime-status-error]')
241 .should('contain', 'Something went wrong')
242 .and('contain', 'Process exited with status 1');
243 cy.get('[data-cy=process-runtime-status-warning]')
244 .should('contain', 'Free disk space is low')
245 .and('contain', 'No additional warning details available');