deploy_not_existing_img_test.js 5.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
// Copyright 2015 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import DeployPageObject from '../deploy/deploy_po';
import DeleteReplicationControllerDialogObject from '../replicationcontrollerdetail/deletereplicationcontroller_po';
import ReplicationControllersPageObject from '../replicationcontrollerslist/replicationcontrollers_po';
import ReplicationControllerDetailPageObject from '../replicationcontrollerdetail/replicationcontrollerdetail_po';

/**
 * This integration test will check complete user story in given order:
 *  - [Zerostate Page] - go to deploy page
 *  - [Deploy Page] - provide data for not existing image and click deploy
 *  - [Replication Controller List Page] - wait for card status error to appear and go to
 *                                         details page
 *  - [Replication Controller Details Page] - Go to events tab, filter by warnings and check
 *                                            results
 *  - [Replication Controller Details Page] - Go to Pods tab and click on Logs link near the
 *                                            existing pod
 *  - [Logs Page] - Check if pod logs show that pod is in pending state.
 *  - Clean up and delete created resources
 */
33
describe('Deploy not existing image story', () => {
34 35 36 37 38 39 40 41 42 43 44 45 46

  /** @type {!DeployPageObject} */
  let deployPage;

  /** @type {!ReplicationControllersPageObject} */
  let replicationControllersPage;

  /** @type {!DeleteReplicationControllerDialogObject} */
  let deleteDialog;

  /** @type {!ReplicationControllerDetailPageObject} */
  let replicationControllerDetailPage;

47
  let appName = `test-${Date.now()}`;
48 49 50 51 52 53 54 55 56
  let containerImage = 'test';

  beforeAll(() => {
    deployPage = new DeployPageObject();
    replicationControllersPage = new ReplicationControllersPageObject();
    deleteDialog = new DeleteReplicationControllerDialogObject();
    replicationControllerDetailPage = new ReplicationControllerDetailPageObject();
  });

57 58 59
  it('should deploy app and go to replication controllers list page', (doneFn) => {
    // For empty cluster this should actually redirect to zerostate page
    browser.get('#/deploy');
60 61 62 63 64
    // given
    deployPage.appNameField.sendKeys(appName);
    deployPage.containerImageField.sendKeys(containerImage);

    // when
65 66
    deployPage.deployButton.click().then(() => {
      // then
67
      expect(browser.getCurrentUrl()).toContain('replicationcontroller');
68
      doneFn();
69
    });
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
  });

  it('should wait for card to be in error state', () => {
    // given
    let cardErrors = replicationControllersPage.getElementByAppName(
        replicationControllersPage.cardErrorsQuery, appName, true);
    let cardErrorIcon = replicationControllersPage.getElementByAppName(
        replicationControllersPage.cardErrorIconQuery, appName);

    // when
    browser.driver.wait(() => {
      return cardErrorIcon.isPresent().then((result) => {
        if (result) {
          return true;
        }

        browser.driver.navigate().refresh();
        return false;
      });
    });

    // then
    expect(cardErrorIcon.isDisplayed()).toBeTruthy();
    cardErrors.then((errors) => { expect(errors.length).not.toBe(0); });
  });

  it('should go to details page', () => {
    // given
    let cardDetailsPageLink = replicationControllersPage.getElementByAppName(
        replicationControllersPage.cardDetailsPageLinkQuery, appName);

    // when
    cardDetailsPageLink.click();

    // then
105
    expect(browser.getCurrentUrl()).toContain(`replicationcontroller/default/${appName}`);
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
  });

  it('should switch to events tab and check for errors', () => {
    // when
    // Switch to events tab
    replicationControllerDetailPage.eventsTab.click();

    // Filter events by warnings
    replicationControllerDetailPage.eventsTypeFilter.click().then(
        () => { replicationControllerDetailPage.eventsTypeWarning.click(); });

    // then
    expect(replicationControllerDetailPage.eventsTable.isDisplayed()).toBeTruthy();
  });

  it('should switch to pods tab and go to pod logs page', () => {
    // when
    // Switch to pods tab
    replicationControllerDetailPage.podsTab.click();

    // Click pod log link
    replicationControllerDetailPage.podLogsLink.click().then(() => {
      // then
      // Logs page is opened in new window so we have to switch browser focus to that window.
      browser.getAllWindowHandles().then((handles) => {
        let logsWindowHandle = handles[1];
        browser.switchTo().window(logsWindowHandle).then(() => {
133
          expect(browser.getCurrentUrl()).toContain(`log/default/${appName}`);
134 135 136 137 138 139
        });
      });
    });
  });

  // Clean up and delete created resources
140
  afterAll((doneFn) => {
141 142 143
    let cardMenuButton = replicationControllersPage.getElementByAppName(
        replicationControllersPage.cardMenuButtonQuery, appName);

144
    browser.get('#/replicationcontroller');
145 146

    cardMenuButton.click();
147 148 149 150
    replicationControllersPage.deleteAppButton.click().then(() => {
      deleteDialog.deleteAppButton.click();
      doneFn();
    });
151 152
  });
});