blob: 38e69e89319edeed19167edecfcdec79d126a2b1 [file] [log] [blame]
Thomas Vachuska4702a262016-03-02 15:31:52 -08001#!/bin/bash
2# -----------------------------------------------------------------------------
3# Validates that the local environment is ready to commence release process.
4# -----------------------------------------------------------------------------
5
6[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7
8GERRIT_USER=${GERRIT_USER:-$USER}
Brian O'Connor156c4802016-03-02 15:50:38 -08009WIKI_USER=${WIKI_USER:-$USER}
Thomas Vachuska4702a262016-03-02 15:31:52 -080010
11set -e
12
Thomas Vachuska68918842016-03-04 10:38:55 -080013# Tests availability of the specified tools
14function testTool {
15 trap "echo 'FAILED'" ERR
16 printf "Checking $1 availability... "
17 which -s $1
18 echo "OK"
19}
20
21# Tests availability of gerrit
22function testGerritTool {
23 trap "echo 'FAILED'" ERR
24 printf "Checking gerrit... "
25 git review --version 2>/dev/null
26 echo "OK"
27}
28
29# Tests availability of GPG or GPG2
30function testGpgTool {
31 trap "echo 'FAILED'" ERR
32 printf "Checking gpg or gpg2... "
33 which -s gpg || which -s gpg2
34 echo "OK"
35}
36
37# Tests Java version
38function testJavaVersion {
39 trap "echo 'FAILED'" ERR
40 printf "Checking Java version... "
41 v=$(javac -version 2>&1 | grep 1.8.0_ | sed -e 's/.*1.8.0_\([0-9]*\).*/\1/g')
Brian O'Connora3178722016-03-10 15:44:27 -080042 test "$v" -ge 73
Thomas Vachuska68918842016-03-04 10:38:55 -080043 echo "OK"
44}
45
46# Tests availability of the required tools
47function testToolchain {
48 for tool in bash python git java javac mvn tar; do
49 testTool $tool;
50 done
51 testGerritTool
52 testGpgTool
53 testJavaVersion
54}
55
56# Tests that the specified artifact dependency is not a snapshot version
57function testArtifactDependency {
58 trap "echo 'FAILED'" ERR
59 printf "Checking $1 dependency... "
60 grep "<$1.version>.*</$1.version>" $ONOS_ROOT/pom.xml | grep -q SNAPSHOT && false
61 echo "OK"
62}
63
64# Tests that the ONOS-base is not a snapshot version
65function testOnosBase {
66 trap "echo 'FAILED'" ERR
67 printf "Checking onos-base dependency... "
68 grep -A1 "onos-base" $ONOS_ROOT/pom.xml | grep -q SNAPSHOT && false
69 echo "OK"
70}
71
72# Tests that the root pom does not contain any snapshot dependencies
73# on anxillary artifacts, e.g. openflowj, copycat
74function testSnapshotDependencies {
75 testOnosBase
76 for artifact in onos-build-conf onos-maven-plugin openflowj atomix copycat; do
77 testArtifactDependency $artifact
78 done
79}
80
Thomas Vachuska4702a262016-03-02 15:31:52 -080081# Test access to Gerrit (Administrator)
82function testGerritAccess {
83 trap "echo 'FAILED'" ERR
Brian O'Connor156c4802016-03-02 15:50:38 -080084 printf "Checking Gerrit ONOS Release group access... "
85 ssh -p 29418 gerrit.onosproject.org gerrit ls-members "ONOS\ Release"\
86 --recursive | grep -q $GERRIT_USER
Thomas Vachuska4702a262016-03-02 15:31:52 -080087 echo "OK"
88}
89
90# Test access to wiki.onosproject.org
91function testWikiAccess {
92 trap "echo 'FAILED'" ERR
93 printf "Checking Wiki access... "
Brian O'Connor156c4802016-03-02 15:50:38 -080094 ssh $WIKI_USER@wiki.onosproject.org "test -w /var/www/api/index.html"
Thomas Vachuska4702a262016-03-02 15:31:52 -080095 echo "OK"
96}
97
98# Test access to EC2
99function testEC2Access {
100 aux=$(mktemp)
101 trap "cat $aux; rm -f $aux; echo 'FAILED'" ERR
102 printf "Checking EC2 access... "
103 uploadToS3.py -v 1>$aux 2>&1
104 rm -f $aux
105 echo "OK"
106}
107
108# Sonatype account must be created & ~/.m2/settings.xml must be configured
109# Test by "releasing" a fake project setup for that purpose to validate access.
110function testSonatypeAccess {
111 aux=$(mktemp)
112 trap "cat $aux; rm -f $aux; echo 'FAILED'" ERR
113 printf "Checking Sonatype access... "
114 pushd $ONOS_ROOT/tools/build/release-test >/dev/null
115 # TODO: Figure out how to supress the GPG note
116 mvn -Prelease clean deploy org.sonatype.plugins:nexus-staging-maven-plugin:drop \
117 1>$aux 2>&1 </dev/null
118 mvn clean >/dev/null
119 rm -f $aux
120 popd >/dev/null
121 echo "OK"
122}
123
Thomas Vachuska68918842016-03-04 10:38:55 -0800124testToolchain
125testSnapshotDependencies
Thomas Vachuska4702a262016-03-02 15:31:52 -0800126testGerritAccess
127testWikiAccess
128testEC2Access
129testSonatypeAccess
130
131echo "Ready to commence release process!"
132