blob: 0db1d0476596cc57b138ac3413cd07e6f1bd2e36 [file] [log] [blame]
Ray Milkey3c50bd42016-12-01 14:28:15 -08001#! /usr/bin/env python
2
3# Spot checks some published artifacts to be sure that they uploaded correctly
4# to the release repository
5
6import requests
7import sys
8import sha
9import os
10
11
12from requests.auth import HTTPBasicAuth
13
14if len(sys.argv) != 4:
15 print "usage: check-uploaded-maven-artifact version buildRoot repoRoot"
16 sys.exit(1)
17
18version = sys.argv[1]
19buildRoot = sys.argv[2]
20repoRoot = sys.argv[3]
21
22def checkArtifact(localPath, remoteUrl):
23
24 repoResponse = requests.head(remoteUrl)
25
26 if repoResponse.status_code != 200:
27 print 'Cannot find jar file artifact'
28 print repoResponse.text
29 sys.exit(1)
30
31 remoteSize = int(repoResponse.headers['content-length'])
32 etag = repoResponse.headers['etag']
33
34 localSize = os.path.getsize(localPath)
35
36 localArtifact = open(localPath)
37 localArtifactSha = sha.new(localArtifact.read())
38 expectedSha1 = localArtifactSha.hexdigest()
39
40 if localSize != remoteSize:
41 print 'Size for ' + remoteUrl + ' is wrong local ' + str(localSize) + ' but found remote ' + str(remoteSize)
42 sys.exit(1)
43
44 sha1 = ''
45 if '{SHA1{' in etag:
46 # this is a sonatype style artifact
47 sha1 = etag[7:len(etag)-3]
48 else:
49 sha1 = repoResponse.headers['x-checksum-sha1']
50
51 if sha1 != expectedSha1:
52 print 'SHA1 hash is wrong expected ' + expectedSha1 + ' but found ' + sha1
53 sys.exit(1)
54
55def checkArtifactsForComponent(version, name, component, buildRoot, repoRoot):
56 localArtifactRootPath = buildRoot + '/buck-out/gen/' + component
57 localArtifactJarPath = localArtifactRootPath + '/lib__' + name + '__output/' + name + '.jar'
58 localArtifactJavadocPath = localArtifactRootPath + '/' + name + '#javadoc,maven-sources.jar'
59 localArtifactSourcesPath = localArtifactRootPath + '/' + name + '#maven,src-sources.jar'
60
61 remoteArtifactBaseUrl = repoRoot + '/org/onosproject/' + name + '/' + version + '/' + name + '-' + version
62 remoteArtifactJarUrl = remoteArtifactBaseUrl + '.jar'
63 remoteArtifactJavadocUrl = remoteArtifactBaseUrl + '-javadoc.jar'
64 remoteArtifactSourcesUrl = remoteArtifactBaseUrl + '-sources.jar'
65
66 checkArtifact(localArtifactJarPath, remoteArtifactJarUrl)
67 checkArtifact(localArtifactJavadocPath, remoteArtifactJavadocUrl)
68 checkArtifact(localArtifactSourcesPath, remoteArtifactSourcesUrl)
69
70checkArtifactsForComponent(version, 'onos-api', 'core/api', buildRoot, repoRoot)
71checkArtifactsForComponent(version, 'onos-protocols-openflow-api', 'protocols/openflow/api', buildRoot, repoRoot)
72checkArtifactsForComponent(version, 'onos-drivers-ciena', 'drivers/ciena', buildRoot, repoRoot)
73checkArtifactsForComponent(version, 'onos-providers-lldp', 'providers/lldp', buildRoot, repoRoot)
74checkArtifactsForComponent(version, 'onos-apps-bgprouter', 'apps/bgprouter', buildRoot, repoRoot)
75