Commit 2d6646a4 authored by adoneria's avatar adoneria Committed by Commit Bot

[updater] add structure for updater install test for windows.

This is the prelim CL to the implementation of updater install test
to create a basic folder structure and import constants from C++
integration tests.

Bug: 1130847
Change-Id: I0d414517f749d76f54e66643a0d64b4e43df6c6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2422092
Commit-Queue: Anjali Doneria <adoneria@google.com>
Reviewed-by: default avatarJoshua Pawlicki <waffles@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815266}
parent 22da3d35
......@@ -349,5 +349,12 @@ if (is_win || is_mac) {
"//testing/xvfb.py",
"//third_party/catapult/third_party/typ/",
]
if (is_win) {
data_deps = [
"//chrome/updater/win:updater",
"//chrome/updater/win/installer",
]
}
}
}
......@@ -11,11 +11,20 @@ To write a new integration test, extend it from `unittest.TestCase` class and
declare test function as `test_xyz()` so that typ can easily discover the tests
and run them.
Currently the folder contains a sample test written to test end-to-end
Currently the folder contains [a sample test](hello_test.py) written to test end-to-end
integration of the python test framework with chromium test infrastructure. This
is a work in progress and more code as per cross-platform updater test framework
design doc will be added here.
# Platforms Supported
* win: win7, win10
* mac: macOS 10.10-10.15
* mac: macOS 10.10-11.0 (11.0 arm64 support to be added soon)
# Directory Structure
* common/ contains all utility functions shared across the codebase.
* mock_server/ contains code to configure local HTTP/HTTPS server that mocks
behavior of real omaha server. The client sends request to this mock server
and receives response based on pre-configured rules and predicates.
* updater/ contains modules to support updater testing.
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Logger utility functions."""
import logging
import os
from test.integration_tests.common import path_finder
_DEFAULT_LOG_FORMAT = ('[%(levelname)-5s %(asctime)s.%(msecs)d '
'%(process)d:%(thread)d '
'%(filename)s:%(lineno)d]%(message)s')
_DATE_FORMAT = '%Y-%m-%d %H:%M:%S'
def GetLogLocation():
log_dir = os.getenv('${ISOLATED_OUTDIR}')
if log_dir is None:
log_dir = os.path.join(path_finder.get_integration_tests_dir(),
'test_output')
if not os.path.exists(log_dir):
os.makedirs(log_dir)
return log_dir
def LoggingToFile(log_file, log_level=logging.NOTSET):
"""Add a file log handler to the root log.
Args:
log_file: The log file path.
log_level: Log level of the file handler.
"""
# Always create a log file first for permission settings.
open(log_file, 'a').close()
logger = logging.getLogger()
# Don't filter logs out at the logger level, let handler do the filter.
logger.setLevel(logging.NOTSET)
handler = logging.FileHandler(log_file)
formatter = logging.Formatter(_DEFAULT_LOG_FORMAT, _DATE_FORMAT)
handler.setFormatter(formatter)
handler.setLevel(log_level)
logger.addHandler(handler)
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Tests updater installation."""
import logging
from test.integration_tests.updater import test_base
from test.integration_tests.updater.lib import updater_util
class InstallTest(test_base.UpdaterTestBase):
"""Tests for updater install."""
def setUp(self):
super(InstallTest, self).setUp()
def SetUpMockServer(self):
pass
def tearDown(self):
super(InstallTest, self).tearDown()
def test_install(self):
updater_util.Install()
if __name__ == '__main__':
unittest.main()
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Updater utility functions for mac platform."""
import logging
def Clean():
pass
def ExpectClean():
pass
def GetExecutablePath():
pass
def GetInstallerPath():
pass
def Install():
pass
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import sys
if sys.platform == 'darwin':
from test.integration_tests.updater.lib.mac.updater_util import *
elif 'win' in sys.platform:
from test.integration_tests.updater.lib.win.updater_util import *
else:
pass
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Updater utility functions for windows platform."""
import logging
def Clean():
pass
def ExpectClean():
pass
def GetExecutablePath():
pass
def GetInstallerPath():
pass
def Install():
pass
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Base test class for updater testing.
This is the base class that all tests derive from. It extends unittest.TestCase
class to create the unittest-driven framework. It provides test fixtures through
setUp() and teardown() which can be overridden by test cases to perform their
intended action before test run and after test run respectively.
"""
import logging
import os
import unittest
from test.integration_tests.common import logger_util
from test.integration_tests.updater.lib import updater_util
class UpdaterTestBase(unittest.TestCase):
"""Base test class for updater testing on new infra."""
@classmethod
def setUpClass(cls):
super(UpdaterTestBase, cls).setUpClass()
# Sets up logging with the given level.
log_file_path = os.path.join(logger_util.GetLogLocation(),
'TestCase.log')
log_level = logging.NOTSET
logger_util.LoggingToFile(log_file_path, log_level)
@classmethod
def tearDownClass(cls):
super(UpdaterTestBase, cls).tearDownClass()
def setUp(self):
super(UpdaterTestBase, self).setUp()
logging.info('Running test: %s', self.id())
logging.info('In test case setUp.')
# cleanup the system before running test
self.Clean()
# assert for cleanliness
self.ExpectClean()
# set up mock server
self.SetUpMockServer()
# start mock server
self.StartMockServer()
def tearDown(self):
logging.info('In test case tearDown.')
# cleanup after test finishes.
self.Clean()
self.ExpectClean()
super(UpdaterTestBase, self).tearDown()
def Clean(self):
"""Removes Chrome and Updater from system."""
updater_util.Clean()
def ExpectClean(self):
"""Checks if the requested apps are uninstalled from system."""
updater_util.ExpectClean()
def SetUpMockServer(self):
"""Prepares mock server for the test run."""
raise NotImplementedError('Test Case must set up mock server for its use.')
def StartMockServer(self):
"""Starts mock server on the local system."""
pass
def GetExecutablePath(self):
updater_util.GetExecutablePath()
def GetInstallerPath(self):
updater_util.GetInstallerPath()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment