deploy_not_existing_img_test.js 6.2 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 33 34
// 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 LogsPageObject from '../logs/logs_po';
import ReplicationControllersPageObject from '../replicationcontrollerslist/replicationcontrollers_po';
import ReplicationControllerDetailPageObject from '../replicationcontrollerdetail/replicationcontrollerdetail_po';
import ZeroStatePageObject from '../zerostate/zerostate_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
 */
35 36
// TODO(#494): Reenable this test when fixed.
xdescribe('Deploy not existing image story', () => {
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
  /** @type {!ZeroStatePageObject} */
  let zeroStatePage;

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

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

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

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

  /** @type {!LogsPageObject} */
  let logsPage;

  let appName = 'test';
  let containerImage = 'test';

  beforeAll(() => {
    // For empty cluster this should actually redirect to zerostate page
    browser.get('#/replicationcontrollers');

    zeroStatePage = new ZeroStatePageObject();
    deployPage = new DeployPageObject();
    replicationControllersPage = new ReplicationControllersPageObject();
    deleteDialog = new DeleteReplicationControllerDialogObject();
    replicationControllerDetailPage = new ReplicationControllerDetailPageObject();
    logsPage = new LogsPageObject();
  });

  it('should go to deploy page', () => {
    // when
    zeroStatePage.deployButton.click();

    // then
    expect(browser.getCurrentUrl()).toContain('deploy');
  });

  it('should deploy app and go to replication controllers list page', () => {
    // given
    deployPage.appNameField.sendKeys(appName);
    deployPage.containerImageField.sendKeys(containerImage);

    // when
84 85 86 87
    deployPage.deployButton.click().then(() => {
      // then
      expect(browser.getCurrentUrl()).toContain('replicationcontrollers');
    });
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
  });

  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
    expect(browser.getCurrentUrl()).toContain(`replicationcontrollers/default/${appName}`);
  });

  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(() => {
          expect(browser.getCurrentUrl()).toContain(`logs/default/${appName}`);
        });
      });
    });
  });

  it('pod logs should show pending state', () => {
    logsPage.logEntries.then((logEntries) => {
      expect(logEntries.length).toBe(1);
      let logEntryText = logEntries[0].getText();
      expect(logEntryText).toContain('State: "Pending"');
    });
  });

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

    browser.get('#/replicationcontrollers');

    cardMenuButton.click();
    replicationControllersPage.deleteAppButton.click().then(
        () => { deleteDialog.deleteAppButton.click(); });
  });
});