You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by sb...@apache.org on 2015/05/18 14:13:19 UTC

incubator-ignite git commit: # ignite-456: run all builds mode

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-456 07fadeefa -> 642a45a3a


# ignite-456: run all builds mode


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/642a45a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/642a45a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/642a45a3

Branch: refs/heads/ignite-456
Commit: 642a45a3aacc08dee40d167187047e9deb99cd99
Parents: 07fadee
Author: Artem Shutak <as...@gridgain.com>
Authored: Mon May 18 15:14:08 2015 +0300
Committer: Artem Shutak <as...@gridgain.com>
Committed: Mon May 18 15:14:08 2015 +0300

----------------------------------------------------------------------
 dev-tools/build.gradle                     |  34 +--
 dev-tools/src/main/groovy/jiraslurp.groovy | 275 +++++++++++++-----------
 2 files changed, 172 insertions(+), 137 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/642a45a3/dev-tools/build.gradle
----------------------------------------------------------------------
diff --git a/dev-tools/build.gradle b/dev-tools/build.gradle
index b760bc1..909ff53 100644
--- a/dev-tools/build.gradle
+++ b/dev-tools/build.gradle
@@ -25,21 +25,29 @@ dependencies {
 }
 
 task help {
-  println '''There are two interfaces to work with JIRA attachment validation tool
-  - to do the batch validation of all latest patch attachments
-     gradle slurp
-  - to grab a single JIRA's latest attachment and run test validation on it
-     JIRA_NUM=INGITE-### gradle patchapply'''
+    println '''There are 3 interfaces to work with JIRA attachment validation tool
+    - to do the batch validation of all latest patch attachments
+      gradle slurp
+    - to grab a single JIRA's latest attachment and run test validation on it
+      JIRA_NUM=INGITE-### gradle patchapply
+    - to run all test builds for a single JIRA's latest attachment and run test validation on it
+      JIRA_NUM=INGITE-### gradle runAllBuilds'''
 }
 
-task slurp (dependsOn: 'classes', type: JavaExec) {
-  args (project.buildDir, 'slurp')
-  main = 'jiraslurp'
-  classpath = sourceSets.main.runtimeClasspath
+task slurp(dependsOn: 'classes', type: JavaExec) {
+    args(project.buildDir, 'slurp')
+    main = 'jiraslurp'
+    classpath = sourceSets.main.runtimeClasspath
 }
 
-task patchapply (dependsOn: 'classes', type: JavaExec) {
-  args ("JIRA_NUM=${System.getenv('JIRA_NUM')}")
-  main = 'jiraslurp'
-  classpath = sourceSets.main.runtimeClasspath
+task patchapply(dependsOn: 'classes', type: JavaExec) {
+    args("patchApply,${System.getenv('JIRA_NUM')}")
+    main = 'jiraslurp'
+    classpath = sourceSets.main.runtimeClasspath
+}
+
+task runAllBuilds(dependsOn: 'classes', type: JavaExec) {
+    args("runAllBuilds,${System.getenv('JIRA_NUM')}")
+    main = 'jiraslurp'
+    classpath = sourceSets.main.runtimeClasspath
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/642a45a3/dev-tools/src/main/groovy/jiraslurp.groovy
----------------------------------------------------------------------
diff --git a/dev-tools/src/main/groovy/jiraslurp.groovy b/dev-tools/src/main/groovy/jiraslurp.groovy
index fb449a9..26a0711 100644
--- a/dev-tools/src/main/groovy/jiraslurp.groovy
+++ b/dev-tools/src/main/groovy/jiraslurp.groovy
@@ -27,31 +27,31 @@ final def JIRA_CMD = System.getProperty('JIRA_COMMAND', 'jira.sh')
 LinkedHashMap<String, String> jirasAttached = [:]
 
 def readHistory = {
-  final int MAX_HISTORY = 5000
+    final int MAX_HISTORY = 5000
 
-  List validated_list = []
+    List validated_list = []
 
-  def validated = new File(validated_filename)
+    def validated = new File(validated_filename)
 
-  if (validated.exists()) {
-    validated_list = validated.text.split('\n')
-    validated.delete()
-  }
-  else {
-    try {
-      validated_list = new URL("http://204.14.53.152/$LAST_SUCCESSFUL_ARTIFACT").text.split('\n')
+    if (validated.exists()) {
+        validated_list = validated.text.split('\n')
+        validated.delete()
     }
-    catch (Exception e) {
-      println e.getMessage()
+    else {
+        try {
+            validated_list = new URL("http://204.14.53.152/$LAST_SUCCESSFUL_ARTIFACT").text.split('\n')
+        }
+        catch (Exception e) {
+            println e.getMessage()
+        }
     }
-  }
 
-  // Let's make sure the preserved history isn't too long
-  if (validated_list.size > MAX_HISTORY) {
-    validated_list = validated_list[validated_list.size-MAX_HISTORY..validated_list.size-1]
-  }
+    // Let's make sure the preserved history isn't too long
+    if (validated_list.size > MAX_HISTORY) {
+        validated_list = validated_list[validated_list.size - MAX_HISTORY..validated_list.size - 1]
+    }
 
-  validated_list
+    validated_list
 }
 
 /**
@@ -59,154 +59,181 @@ def readHistory = {
  * @return <code>null</code> or <code>JIRA-###,latest_attach_id</code>
  */
 def getLatestAttachment = { jira ->
-  def latestAttr = jira.attachments[0].attachment.list().sort {
-    it.@id.toInteger()
-  }.reverse()[0]
-
-  String row = null
-
-  if (latestAttr == null) {
-    println "${jira.key} is in invalid state: patch is not available"
-  }
-  else {
-    row = "${jira.key},${latestAttr.@id}"
-  }
+    def latestAttr = jira.attachments[0].attachment.list().sort {
+        it.@id.toInteger()
+    }.reverse()[0]
+
+    String row = null
+
+    if (latestAttr == null) {
+        println "${jira.key} is in invalid state: patch is not available"
+    }
+    else {
+        row = "${jira.key},${latestAttr.@id}"
+    }
 }
 
 def checkForAttachments = {
-  def JIRA_FILTER =
-      "https://issues.apache.org/jira/sr/jira.issueviews:searchrequest-xml/12330308/SearchRequest-12330308.xml?tempMax=100&field=key&field=attachments"
-  def rss = new XmlSlurper().parse(JIRA_FILTER)
+    def JIRA_FILTER =
+        "https://issues.apache.org/jira/sr/jira.issueviews:searchrequest-xml/12330308/SearchRequest-12330308.xml?tempMax=100&field=key&field=attachments"
+    def rss = new XmlSlurper().parse(JIRA_FILTER)
 
-  List list = readHistory{}
+    List list = readHistory {}
 
-  rss.channel.item.each { jira ->
-    String row = getLatestAttachment (jira)
+    rss.channel.item.each { jira ->
+        String row = getLatestAttachment(jira)
 
-    if (row != null && !list.contains(row)) {
-      def pair = row.split(',')
+        if (row != null && !list.contains(row)) {
+            def pair = row.split(',')
 
-      jirasAttached.put(pair[0] as String, pair[1] as String)
+            jirasAttached.put(pair[0] as String, pair[1] as String)
 
-      list.add(row)
+            list.add(row)
+        }
     }
-  }
 
-  // Write everything back to persist the list
-  def validated = new File(validated_filename)
+    // Write everything back to persist the list
+    def validated = new File(validated_filename)
 
-  validated << list.join('\n')
+    validated << list.join('\n')
 }
 
 def checkprocess = { process ->
-  process.waitFor()
+    process.waitFor()
 
-  if (process.exitValue() != 0) {
-    println "Return code: " + process.exitValue()
-    println "Errout:\n" + process.err.text
+    if (process.exitValue() != 0) {
+        println "Return code: " + process.exitValue()
+        println "Errout:\n" + process.err.text
 
-    assert process.exitValue() == 0 || process.exitValue() == 128
-  }
+        assert process.exitValue() == 0 || process.exitValue() == 128
+    }
 }
 
-def create_gitbranch = {jira, attachementURL ->
-  println jira
-  GIT_REPO
-  println "$ATTACHMENT_URL/$attachementURL/"
+def create_gitbranch = { jira, attachementURL ->
+    println jira
+    GIT_REPO
+    println "$ATTACHMENT_URL/$attachementURL/"
 
-  def patchFile = new File("${jira}.patch")
+    def patchFile = new File("${jira}.patch")
 
-  patchFile << new URL("$ATTACHMENT_URL/$attachementURL/").text
+    patchFile << new URL("$ATTACHMENT_URL/$attachementURL/").text
 
-  checkprocess "git clone --depth 1 $GIT_REPO".execute()
-  checkprocess "git checkout -b ignite-sprint-5 origin/ignite-sprint-5".execute(null, new File('incubator-ignite'))
-  checkprocess "git am ../${patchFile.name}".execute(null, new File('incubator-ignite'))
+    checkprocess "git clone --depth 1 $GIT_REPO".execute()
+    checkprocess "git checkout -b ignite-sprint-5 origin/ignite-sprint-5".execute(null, new File('incubator-ignite'))
+    checkprocess "git am ../${patchFile.name}".execute(null, new File('incubator-ignite'))
 
-  patchFile.delete()
+    patchFile.delete()
 }
 
 def JIRA_xml = { jiranum ->
-  "https://issues.apache.org/jira/si/jira.issueviews:issue-xml/$jiranum/${jiranum}.xml"
+    "https://issues.apache.org/jira/si/jira.issueviews:issue-xml/$jiranum/${jiranum}.xml"
 }
 
 def run
 
 def runAllTestBuilds = { jiraNum ->
-  def tcURL = System.getenv('TC_URL')
-  def user = System.getenv('TASK_RUNNER_USER')
-  def pwd = System.getenv('TASK_RUNNER_PWD')
-
-  ["Ignite_IgniteBasic",
-   "Ignite_IgniteCache"].each {
-    String postData =
-        "<build>" +
-        "  <buildType id='$it'/>" +
-        "  <properties>" +
-        "    <property name='JIRA_NUM' value='$jiraNum'/>" +
-        "  </properties>" +
-        "</build>";
-
-    URL url = new URL("http://$tcURL:80/httpAuth/app/rest/buildQueue");
-      
-    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-
-    String encoded = new sun.misc.BASE64Encoder().encode("$user:$pwd".getBytes());
-
-    conn.setRequestProperty("Authorization", "Basic "+encoded);
-
-    conn.setDoOutput(true);
-    conn.setRequestMethod("POST");
-    conn.setRequestProperty("Content-Type", "application/xml");
-    conn.setRequestProperty("Content-Length", String.valueOf(postData.length()));
-
-    OutputStream os = conn.getOutputStream();
-    os.write(postData.getBytes());
-    os.flush();
-    os.close();
-
-    conn.connect();
-
-    // Read response.
-    println "Response: "  
-      
-    BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
-
-    String line;
-    while ( (line = br.readLine()) != null)
-      println line
-
-    br.close();
-  }
+    assert jiraNum != 'null', 'Jira number should not be null.'
+    assert jiraNum != null, 'Jira number should not be null.'
+
+    if (jiraNum) {
+        def tcURL = System.getenv('TC_URL')
+        def user = System.getenv('TASK_RUNNER_USER')
+        def pwd = System.getenv('TASK_RUNNER_PWD')
+
+        ["Ignite_IgniteBasic",
+         "Ignite_IgniteDataGrid"].each {
+            try {
+                println "Triggering $it build for $jiraNum jira..."
+
+                String postData =
+                    "<build>" +
+                        "  <buildType id='$it'/>" +
+                        "  <properties>" +
+                        "    <property name='JIRA_NUM' value='$jiraNum'/>" +
+                        "  </properties>" +
+                        "</build>";
+
+                URL url = new URL("http://$tcURL:80/httpAuth/app/rest/buildQueue");
+
+                HttpURLConnection conn = (HttpURLConnection)url.openConnection();
+
+                String encoded = new sun.misc.BASE64Encoder().encode("$user:$pwd".getBytes());
+
+                conn.setRequestProperty("Authorization", "Basic " + encoded);
+
+                conn.setDoOutput(true);
+                conn.setRequestMethod("POST");
+                conn.setRequestProperty("Content-Type", "application/xml");
+                conn.setRequestProperty("Content-Length", String.valueOf(postData.length()));
+
+                OutputStream os = conn.getOutputStream();
+                os.write(postData.getBytes());
+                os.flush();
+                os.close();
+
+                conn.connect();
+
+                // Read response.
+                println "Response: "
+
+                BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
+
+                String line;
+                while ((line = br.readLine()) != null)
+                    println line
+
+                br.close();
+            }
+            catch (Exception e) {
+                e.printStackTrace()
+            }
+        }
+    }
 }
 
 args.each {
-  println it
+    println it
 
-  def parameters = it.split('=')
+    def parameters = it.split(",")
 
-  if (parameters[0] == 'slurp') {
-    checkForAttachments()
+    println parameters
 
-    // For each ticket with new attachment, let's trigger remove build
-    jirasAttached.each { k, v ->
-      //  Trailing slash is important for download; only need to pass JIRA number
-      println "Triggering the test builds for: $k = $ATTACHMENT_URL/$v/"
+    if (parameters[0] == 'slurp') {
+        println "Running in 'slurp' mode."
 
-      runAllTestBuilds k
+        checkForAttachments()
+
+        // For each ticket with new attachment, let's trigger remove build
+        jirasAttached.each { k, v ->
+            //  Trailing slash is important for download; only need to pass JIRA number
+            println "Triggering the test builds for: $k = $ATTACHMENT_URL/$v/"
+
+            runAllTestBuilds k
+        }
     }
-  }
-  else if (parameters.length == 2 && parameters[0] == 'JIRA_NUM' && parameters[1] ==~ /\w+-\d+/) {
-    // Extract JIRA rss from the and pass the ticket element into attachment extraction
-    def rss = new XmlSlurper().parse(JIRA_xml(parameters[1]))
+    else if (parameters.length == 2 && parameters[0] == "patchApply" && parameters[1] ==~ /\w+-\d+/) {
+        def jiraNum = parameters[1]
+
+        println "Running in 'patch apply' mode with jira number '$jiraNum'"
+
+        // Extract JIRA rss from the and pass the ticket element into attachment extraction
+        def rss = new XmlSlurper().parse(JIRA_xml(parameters[1]))
 
-    String row = getLatestAttachment(rss.channel.item)
+        String row = getLatestAttachment(rss.channel.item)
+
+        if (row != null) {
+            def pair = row.split(',')
+
+            create_gitbranch(pair[0], pair[1])
+        }
+    }
+    else if (parameters.length == 2 && parameters[0] == "runAllBuilds" && parameters[1] ==~ /\w+-\d+/) {
+        def jiraNum = parameters[1]
 
-    if (row != null) {
-      def pair = row.split(',')
+        println "Running in 'all builds' mode with jira number '$jiraNum'"
 
-      create_gitbranch(pair[0], pair[1])
+        runAllTestBuilds parameters[1]
     }
-  }
 }
 
 /* Workflow: