blob: 7b8f003f2461eacf6596cc4818e1ba5b8065b12e [file] [log] [blame]
Ray Milkeyb46b11b2016-11-29 10:35:51 -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:
Ray Milkeyf3aba5f2017-01-09 16:47:14 -080027 print 'Cannot find jar file artifact at ' + remoteUrl
Ray Milkeyb46b11b2016-11-29 10:35:51 -080028 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:
Ray Milkey3ac00792016-12-01 14:28:15 -080041 print 'Size for ' + remoteUrl + ' is wrong local ' + str(localSize) + ' but found remote ' + str(remoteSize)
Ray Milkeyb46b11b2016-11-29 10:35:51 -080042 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)
Ray Milkeyf3aba5f2017-01-09 16:47:14 -080072checkArtifactsForComponent(version, 'onos-core-serializers', 'core/store/serializers', buildRoot, repoRoot)
73checkArtifactsForComponent(version, 'onos-cli', 'cli', buildRoot, repoRoot)
74checkArtifactsForComponent(version, 'onos-apps-optical-model', 'apps/optical-model', buildRoot, repoRoot)
75
76
77
Ray Milkeyb46b11b2016-11-29 10:35:51 -080078