You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
depot_tools/tests/gclient_cipd_smoketest.py

205 lines
6.8 KiB
Python

#!/usr/bin/env vpython3
# Copyright (c) 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.
"""Smoke tests for gclient.py.
Shell out 'gclient' and run cipd tests.
"""
import logging
import os
import sys
import unittest
import gclient_smoketest_base
ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CHROME_INFRA_URL = "https://chrome-infra-packages.appspot.com"
class GClientSmokeCipd(gclient_smoketest_base.GClientSmokeBase):
def setUp(self):
super(GClientSmokeCipd, self).setUp()
self.enabled = self.FAKE_REPOS.set_up_git()
if not self.enabled:
self.skipTest('git fake repos not available')
self.env['PATH'] = (os.path.join(ROOT_DIR, 'testing_support') +
os.pathsep + self.env['PATH'])
def testSyncCipd(self):
self.gclient(['config', self.git_base + 'repo_14', '--name', 'src'])
self.gclient(['sync'])
tree = self.mangle_git_tree(('repo_14@1', 'src'))
tree.update({
'_cipd':
'\n'.join([
'$ParanoidMode CheckPresence',
'$OverrideInstallMode copy',
'',
'@Subdir src/another_cipd_dep',
'package1 1.1-cr0',
'package2 1.13',
'',
'@Subdir src/cipd_dep',
'package0 0.1',
'',
'@Subdir src/cipd_dep_with_cipd_variable',
'package3/${platform} 1.2',
'',
'',
]),
'src/another_cipd_dep/_cipd':
'\n'.join([
'package1 1.1-cr0',
'package2 1.13',
]),
'src/cipd_dep/_cipd':
'package0 0.1',
'src/cipd_dep_with_cipd_variable/_cipd':
Revert "Reland "resolve CIPD package names in gclient"" This reverts commit d69302761b70d7bb660bcbd42b1395ee17b4f16b. Reason for revert: Broke Dart CI ``` gclient.py revinfo --output-json output.json --filter='https://chrome-infra-packages.appspot.com/dart/dart-sdk/${platform}' ``` No longer returns: ``` { "sdk/tools/sdks/dart-sdk:dart/dart-sdk/${platform}": { "rev": "git_revision:7a6514d1377175decd3a886fe4190fbbebddac3a", "url": "https://chrome-infra-packages.appspot.com/dart/dart-sdk/${platform}" } } ``` Bad build: https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/vm-aot-msan-linux-release-x64/90/overview Good build: https://ci.chromium.org/ui/p/dart/builders/ci.sandbox/vm-aot-msan-linux-release-x64/89/overview Original change's description: > Reland "resolve CIPD package names in gclient" > > This CL relands the below CL with the addition of handling situations where the CIPD package name has a variable=value and does not equate to true. In this case just return the original value in DEPS. > > This is a reland of commit 8faa5514ec0c4a36d65b44acbd98b2eb66b91405 > > Original change's description: > > resolve CIPD package names in gclient > > > > Currently the package names are not resolved in gclient output, see example below. > > > > This is part of broader work to improve CIPD output, the next CL will replace 'None'. > > > > ``` > > $~ gclient revinfo -a | grep '${platform}\|${arch}' > > > > src/buildtools/linux64:gn/gn/linux-${arch}: None > > src/buildtools/reclient:infra/rbe/client/${platform}: None > > src/third_party/dawn/third_party/ninja:infra/3pp/tools/ninja/${platform}: None > > src/third_party/dawn/tools/golang:infra/3pp/tools/go/${platform}: None > > src/third_party/devtools-frontend-internal/devtools-frontend/third_party/esbuild:infra/3pp/tools/esbuild/${platform}: None > > src/third_party/devtools-frontend/src/third_party/esbuild:infra/3pp/tools/esbuild/${platform}: None > > src/third_party/ninja:infra/3pp/tools/ninja/${platform}: None > > src/tools/luci-go:infra/tools/luci/isolate/${platform}: None > > src/tools/luci-go:infra/tools/luci/swarming/${platform}: None > > src/tools/resultdb:infra/tools/result_adapter/${platform}: None > > ``` > > > > Bug:b/279097790 > > Change-Id: I21abf2579910e9d79d9ee0dcd018ee761e3d3c1c > > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4463983 > > Reviewed-by: Rachael Newitt <renewitt@google.com> > > Reviewed-by: Gavin Mak <gavinmak@google.com> > > Commit-Queue: Dan Le Febvre <dlf@google.com> > > Bug: b/279097790 > Change-Id: Ib08dac506ce221243c595dde5cb00e8e0d7dc7ed > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4501582 > Reviewed-by: Gavin Mak <gavinmak@google.com> > Commit-Queue: Dan Le Febvre <dlf@google.com> Bug: b/279097790 Change-Id: Ibf82354ac5005d9d6279d88aa99c8fb344aa6833 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4518113 Owners-Override: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Daniel Cheng <dcheng@chromium.org> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Reviewed-by: Dan Le Febvre <dlf@google.com>
2 years ago
'package3/${platform} 1.2',
})
self.assertTree(tree)
def testConvertGitToCipd(self):
self.gclient(['config', self.git_base + 'repo_13', '--name', 'src'])
# repo_13@1 has src/repo12 as a git dependency.
self.gclient([
'sync', '-v', '-v', '-v', '--revision',
self.githash('repo_13', 1)
])
tree = self.mangle_git_tree(('repo_13@1', 'src'),
('repo_12@1', 'src/repo12'))
self.assertTree(tree)
# repo_13@3 has src/repo12 as a cipd dependency.
self.gclient([
'sync', '-v', '-v', '-v', '--revision',
self.githash('repo_13', 3), '--delete_unversioned_trees'
])
tree = self.mangle_git_tree(('repo_13@3', 'src'))
tree.update({
'_cipd':
'\n'.join([
'$ParanoidMode CheckPresence',
'$OverrideInstallMode copy',
'',
'@Subdir src/repo12',
'foo 1.3',
'',
'',
]),
'src/repo12/_cipd':
'foo 1.3',
})
self.assertTree(tree)
def testConvertCipdToGit(self):
self.gclient(['config', self.git_base + 'repo_13', '--name', 'src'])
# repo_13@3 has src/repo12 as a cipd dependency.
self.gclient([
'sync', '-v', '-v', '-v', '--revision',
self.githash('repo_13', 3), '--delete_unversioned_trees'
])
tree = self.mangle_git_tree(('repo_13@3', 'src'))
tree.update({
'_cipd':
'\n'.join([
'$ParanoidMode CheckPresence',
'$OverrideInstallMode copy',
'',
'@Subdir src/repo12',
'foo 1.3',
'',
'',
]),
'src/repo12/_cipd':
'foo 1.3',
})
self.assertTree(tree)
# repo_13@1 has src/repo12 as a git dependency.
self.gclient([
'sync', '-v', '-v', '-v', '--revision',
self.githash('repo_13', 1)
])
tree = self.mangle_git_tree(('repo_13@1', 'src'),
('repo_12@1', 'src/repo12'))
tree.update({
'_cipd':
'\n'.join([
'$ParanoidMode CheckPresence',
'$OverrideInstallMode copy',
'',
'@Subdir src/repo12',
'foo 1.3',
'',
'',
]),
'src/repo12/_cipd':
'foo 1.3',
})
self.assertTree(tree)
def testRevInfo(self):
self.gclient(['config', self.git_base + 'repo_18', '--name', 'src'])
self.gclient(['sync'])
results = self.gclient(['revinfo'])
out = ('src: %(base)srepo_18\n'
'src/cipd_dep:package0: %(instance_url1)s\n'
'src/cipd_dep:package0/${platform}: %(instance_url2)s\n'
'src/cipd_dep:package1/another: %(instance_url3)s\n' % {
'base':
self.git_base,
'instance_url1':
CHROME_INFRA_URL + '/package0@package0-fake-tag:1.0',
'instance_url2':
CHROME_INFRA_URL +
'/package0/${platform}@package0/${platform}-fake-tag:1.0',
'instance_url3':
CHROME_INFRA_URL +
'/package1/another@package1/another-fake-tag:1.0',
})
self.check((out, '', 0), results)
def testRevInfoActual(self):
self.gclient(['config', self.git_base + 'repo_18', '--name', 'src'])
self.gclient(['sync'])
results = self.gclient(['revinfo', '--actual'])
out = (
'src: %(base)srepo_18@%(hash1)s\n'
'src/cipd_dep:package0: %(instance_url1)s\n'
'src/cipd_dep:package0/${platform}: %(instance_url2)s\n'
'src/cipd_dep:package1/another: %(instance_url3)s\n' % {
'base':
self.git_base,
'hash1':
self.githash('repo_18', 1),
'instance_url1':
# The below 'fake-*' and 'platform-expanded-*' ID's are from:
# ../testing_support/fake_cipd.py. 'fake-resolved' represents
# the package being found in the batch resolution mechanism.
CHROME_INFRA_URL + '/p/package0/+/package0-fake-resolved-id',
'instance_url2':
CHROME_INFRA_URL + '/p/package0/platform-expanded-test-only' +
'/+/package0/${platform}-fake-instance-id',
'instance_url3':
CHROME_INFRA_URL + '/p/package1/another' +
'/+/package1/another-fake-resolved-id',
})
self.check((out, '', 0), results)
if __name__ == '__main__':
if '-v' in sys.argv:
logging.basicConfig(level=logging.DEBUG)
unittest.main()