URL: https://github.com/SSSD/sssd/pull/796
Author: pbrezina
 Title: #796: ci: enable sssd-ci for 1-16 branch
Action: synchronized

To pull the PR as Git branch:
git remote add ghsssd https://github.com/SSSD/sssd
git fetch ghsssd pull/796/head:pr796
git checkout pr796
From 087abc6efc49776558b3fa6eee674e75f6fc2f22 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrez...@redhat.com>
Date: Fri, 29 Mar 2019 11:10:18 +0100
Subject: [PATCH 1/4] ci: enable sssd-ci for 1-16 branch

Fedora 28 is the latest version containing 1.16 so I think it is fine
to not run the test against Fedora 29+. Besides this change this patch
contains files from master without change.
---
 Jenkinsfile                      | 234 +++++++++++++++++++++++++++++++
 contrib/test-suite/README.md     |  38 +++++
 contrib/test-suite/run-client.sh |  37 +++++
 contrib/test-suite/run.sh        | 100 +++++++++++++
 4 files changed, 409 insertions(+)
 create mode 100644 Jenkinsfile
 create mode 100644 contrib/test-suite/README.md
 create mode 100755 contrib/test-suite/run-client.sh
 create mode 100755 contrib/test-suite/run.sh

diff --git a/Jenkinsfile b/Jenkinsfile
new file mode 100644
index 0000000000..9cd8cb6509
--- /dev/null
+++ b/Jenkinsfile
@@ -0,0 +1,234 @@
+/**
+ * Remember that the build failed because one of the untrusted files were
+ * modified.
+ */
+untrusted = false
+
+/**
+ * SSSD CI.
+ *
+ * This class hold SSSD CI settings and defines several helper methods
+ * that helps reducing code duplication. Unfortunately, it does not
+ * seem to be possible to run those methods directly from the pipeline
+ * as CI.MethodName() as it produces 'Expected a symbol' error therefore
+ * functions outside this class scope must be defined as well. These functions
+ * can be then called directly from the pipeline.
+ */
+class CI {
+  /**
+   * Absolute path to directory that holds the workspace on Jenkins slave.
+   */
+  public static String BaseDir = '/home/fedora'
+
+  /**
+   * Github status context name that is visible in pull request statuses.
+   */
+  public static String GHContext = 'sssd-ci'
+
+  /**
+   * URL that will be opened when user clicks on 'details' on 'sssd-ci' status.
+   */
+  public static String GHUrl = 'https://pagure.io/SSSD/sssd'
+
+  /**
+   * URL that will be opened when user clicks on 'details' on specific
+   * build status (e.g. sssd-ci/fedora28).
+   */
+  public static String AWS = 'https://s3.eu-central-1.amazonaws.com/sssd-ci'
+
+  /**
+   * Path to SSSD Test Suite on Jenkins slave.
+   */
+  public static String SuiteDir = this.BaseDir + '/sssd-test-suite'
+
+  /**
+   * Workaround for https://issues.jenkins-ci.org/browse/JENKINS-39203
+   *
+   * At this moment if one stage in parallel block fails, failure branch in
+   * post block is run in all stages even though they might have been successful.
+   *
+   * We remember result of test stages in this variable so we can correctly
+   * report a success or error even if one of the stages that are run in
+   * parallel failed.
+   */
+  public static def Results = [:]
+
+  /**
+   * Mark build as successfull.
+   */
+  public static def BuildSuccessful(build) {
+    this.Results[build] = "success"
+  }
+
+  /**
+   * Return true if the build was successful.
+   */
+  public static def IsBuildSuccessful(build) {
+    return this.Results[build] == "success"
+  }
+
+  /**
+   * Send commit status to Github for sssd-ci context.
+   */
+  public static def Notify(ctx, status, message) {
+    ctx.githubNotify status: status,
+      context: this.GHContext,
+      description: message,
+      targetUrl: this.GHUrl
+  }
+
+  /**
+   * Send commit status to Github for specific build (e.g. sssd-ci/fedora28).
+   */
+  public static def NotifyBuild(ctx, status, message) {
+    ctx.githubNotify status: status,
+      context: String.format('%s/%s', this.GHContext, ctx.env.TEST_SYSTEM),
+      description: message,
+      targetUrl: String.format(
+        '%s/%s/%s/%s/index.html',
+        this.AWS,
+        ctx.env.BRANCH_NAME,
+        ctx.env.BUILD_ID,
+        ctx.env.TEST_SYSTEM
+      )
+  }
+
+  /**
+   * Run tests. TEST_SYSTEM environment variable must be defined.
+   */
+  public static def RunTests(ctx) {
+    this.NotifyBuild(ctx, 'PENDING', 'Build is in progress.')
+
+    ctx.sh String.format(
+      './sssd/contrib/test-suite/run.sh %s %s %s %s',
+      "${ctx.env.WORKSPACE}/sssd",
+      "${this.SuiteDir}",
+      "${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}",
+      "${this.BaseDir}/configs/${ctx.env.TEST_SYSTEM}.json"
+    )
+
+    this.BuildSuccessful(ctx.env.TEST_SYSTEM)
+  }
+
+  /**
+   * Archive artifacts and notify Github about build result.
+   */
+  public static def WhenCompleted(ctx) {
+    ctx.archiveArtifacts artifacts: "artifacts/**", allowEmptyArchive: true
+    ctx.sh String.format(
+      "${this.BaseDir}/scripts/archive.sh %s %s %s",
+      ctx.env.TEST_SYSTEM,
+      "${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}",
+      "${ctx.env.BRANCH_NAME}/${ctx.env.BUILD_ID}"
+    )
+    ctx.sh "rm -fr ${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}"
+
+    if (this.IsBuildSuccessful(ctx.env.TEST_SYSTEM)) {
+      this.NotifyBuild(ctx, 'SUCCESS', 'Success.')
+      return
+    }
+
+    this.NotifyBuild(ctx, 'FAILURE', 'Build failed.')
+  }
+
+  /**
+   * Notify Github that the build was aborted.
+   */
+  public static def WhenAborted(ctx) {
+    this.NotifyBuild(ctx, 'ERROR', 'Aborted.')
+  }
+}
+
+/**
+ * CI class methods cannot be called directly from the pipeline as it
+ * yield 'Expected a symbol' error for some reason. This is a workaround
+ * for this issue.
+ */
+def CI_RunTests() { CI.RunTests(this) }
+def CI_Post() { CI.WhenCompleted(this) }
+def CI_Aborted() { CI.WhenAborted(this) }
+def CI_Notify(status, message) { CI.Notify(this, status, message) }
+
+pipeline {
+  agent none
+  options {
+    checkoutToSubdirectory('sssd')
+  }
+  stages {
+    stage('Prepare') {
+      steps {
+        CI_Notify('PENDING', 'Running tests.')
+      }
+    }
+    stage('Read trusted files') {
+      steps {
+        readTrusted './contrib/test-suite/run.sh'
+        readTrusted './contrib/test-suite/run-client.sh'
+      }
+      post {
+        failure {
+          script {
+            untrusted = true
+          }
+        }
+      }
+    }
+    stage('Run Tests') {
+      parallel {
+        stage('Test on Fedora 28') {
+          agent {label "sssd-ci"}
+          environment { TEST_SYSTEM = "fedora28" }
+          steps { CI_RunTests() }
+          post {
+            always { CI_Post() }
+            aborted { CI_Aborted() }
+          }
+        }
+        stage('Test on Fedora 29') {
+          agent {label "sssd-ci"}
+          environment { TEST_SYSTEM = "fedora29" }
+          steps { CI_RunTests() }
+          post {
+            always { CI_Post() }
+            aborted { CI_Aborted() }
+          }
+        }
+        stage('Test on Fedora 30') {
+          agent {label "sssd-ci"}
+          environment { TEST_SYSTEM = "fedora30" }
+          steps { CI_RunTests() }
+          post {
+            always { CI_Post() }
+            aborted { CI_Aborted() }
+          }
+        }
+        stage('Test on Fedora Rawhide') {
+          agent {label "sssd-ci"}
+          environment { TEST_SYSTEM = "fedora-rawhide" }
+          steps { CI_RunTests() }
+          post {
+            always { CI_Post() }
+            aborted { CI_Aborted() }
+          }
+        }
+      }
+    }
+  }
+  post {
+    failure {
+      script {
+        if (untrusted) {
+          CI_Notify('ERROR', 'Untrusted files were modified.')
+        } else {
+          CI_Notify('FAILURE', 'Some tests failed.')
+        }
+      }
+    }
+    aborted {
+      CI_Notify('ERROR', 'Builds were aborted.')
+    }
+    success {
+      CI_Notify('SUCCESS', 'All tests succeeded.')
+    }
+  }
+}
diff --git a/contrib/test-suite/README.md b/contrib/test-suite/README.md
new file mode 100644
index 0000000000..576d12d286
--- /dev/null
+++ b/contrib/test-suite/README.md
@@ -0,0 +1,38 @@
+# Run SSSD Test Suite
+
+Script `run.sh` will run all available SSSD test on a set of virtual machines created by vagrant. These virtual machines are part of separate project located at `https://github.com/SSSD/sssd-test-suite`.
+
+## Automated Testing
+
+These test are run automatically when you submit a Pull Request to SSSD project. Status report together with logs will be available in the Pull Request when testing is finished.
+
+## Steps to run the tests manually
+
+1. Checkout `https://github.com/SSSD/sssd-test-suite`
+2. Configure and setup SSSD test suite per instructions located at project readme.
+3. Make sssd-test-suite use already provisioned boxes (either manually created or maintained by SSSD team at https://app.vagrantup.com/sssd-vagrant).
+4. Run `run.sh`, please note that this script will call `vagrant destroy` and it will thus destroy your existing guests.
+
+```
+run.sh SSSD-SOURCE-DIR TEST-SUITE-DIR ARTIFACTS-DIR CONFIG-FILE
+  SSSD-SOURCE-DIR Path to SSSD source directory.
+  TEST-SUITE-DIR  Path to sssd-test-suite_dir directory.
+  ARTIFACTS-DIR   Path to directory where artifacts should be stored.
+  CONFIG-FILE     Path to sssd-test-suite_dir configuration file to use.
+```
+
+At this moment only `client` guest is required. We need to expand our test cases to test agains FreeIPA and Active Directory.
+
+## SSSD CI Architecture
+
+Jenkins master polls github for new branches and pull requests. When it discovers new pull request or branch or changes to existing pull request or branch it will allocate a jenkins agent and executes pipeline defined in `./Jenkinsfile` (in SSSD source) on this agent.
+
+The pipeline executes `./contrib/test-suite/run.sh` and archives logs when testing is finished. Script `./contrib/test-suite/run.sh` prepares sssd-test-suite, starts the vagrant machines and copy SSSD source code to the client machine. Then it calls `./contrib/test-suite/run-client.sh` on the client machine which runs continuous integration tests.
+
+### Extending current tests
+To extend current testing capabilities, modify `./contrib/test-suite/run.sh` and `./contrib/test-suite/run-client.sh` to new requirements. These files can be modified by anyone but are considered untrusted from contributor that is not an administrator of SSSD repository. This means that if a public contributor submits a pull request that changes those files, Jenkins will refuse to run tests.
+
+### Adding additional distribution to test on
+You need to modify `./Jenkinsfile`. Simply copy, paste and amend existing Fedora 28 stage. This file is also considered untrusted so only administrators can modify it within a pull request.
+
+You also need to extend `sssd-test-suite` and prepare vagrant boxes for this distro.
diff --git a/contrib/test-suite/run-client.sh b/contrib/test-suite/run-client.sh
new file mode 100755
index 0000000000..3b9eb606fa
--- /dev/null
+++ b/contrib/test-suite/run-client.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# DO NOT RUN THIS MANUALLY
+#
+
+sssd_source="/shared/sssd"
+artifacts_dir="/shared/artifacts"
+
+archive-artifacts() {
+    echo "Archiving artifacts..."
+
+    cp -f $sssd_source/ci-*.log $artifacts_dir
+    cp -f $sssd_source/ci-build-debug/ci-*.log $artifacts_dir
+    cp -f $sssd_source/ci-build-debug/test-suite.log $artifacts_dir
+}
+
+success-or-die() {
+    ret=$1
+    msg=$2
+    if [ $ret -eq 0 ]; then
+        return 0
+    fi
+
+    echo $msg
+    archive-artifacts
+
+    exit $ret
+}
+
+cd $sssd_source
+
+echo "[1/1] Running Continuous Integration Tests"
+./contrib/ci/run --moderate --no-deps
+success-or-die $? "CI Failed!"
+
+archive-artifacts
+exit 0
diff --git a/contrib/test-suite/run.sh b/contrib/test-suite/run.sh
new file mode 100755
index 0000000000..bb4c06f59e
--- /dev/null
+++ b/contrib/test-suite/run.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+print-usage() {
+    cat <<EOF
+Run SSSD Continuous Integration Tests
+Make sure to checkout and setup https://github.com/SSSD/sssd-test-suite
+
+run.sh SSSD-SOURCE-DIR TEST-SUITE-DIR ARTIFACTS-DIR CONFIG-FILE
+  SSSD-SOURCE-DIR Path to SSSD source directory.
+  TEST-SUITE-DIR  Path to sssd-test-suite_dir directory.
+  ARTIFACTS-DIR   Path to directory where artifacts should be stored.
+  CONFIG-FILE     Path to sssd-test-suite_dir configuration file to use.
+EOF
+}
+
+print-help-if-asked() {
+    while test $# -gt 0
+    do
+        case "$1" in
+            --help)
+                print-usage ; exit 0
+                ;;
+            -h) print-usage ; exit 0
+                ;;
+            -?) print-usage ; exit 0
+                ;;
+        esac
+        shift
+    done
+}
+
+success-or-die() {
+    if [ $1 -ne 0 ]; then
+        echo $2
+        exit 1
+    fi
+}
+
+print-help-if-asked "$@"
+if [[ $# -ne 4 ]]; then
+    print-usage
+    exit 1
+fi
+
+sssd_source=$1
+suite_dir=$2
+artifacts_dir=$3
+config=$4
+
+guest_source="/shared/sssd"
+guest_artifacts="/shared/artifacts"
+
+# Currently only client machine is needed.
+guests="client"
+
+run-vagrant() {
+    VAGRANT_CWD="$suite_dir" \
+    SSSD_TEST_SUITE_RSYNC="$sssd_source:$guest_source" \
+    SSSD_TEST_SUITE_SSHFS="$artifacts_dir:$guest_artifacts" \
+    SSSD_TEST_SUITE_CONFIG="$config" \
+    vagrant "$@"
+}
+
+start-guest() {
+    # This may fail if guest's box was not yet downloaded. We will ignore it.
+    run-vagrant destroy $1 &> /dev/null
+
+    run-vagrant box update $1
+    success-or-die $? "Unable to update guest: $1"
+
+    run-vagrant up $1
+    success-or-die $? "Unable to start guest: $1"
+}
+
+stop-guest() {
+    run-vagrant halt $1
+    success-or-die $? "Unable to halt guest: $1"
+}
+
+echo "[1/5] Creating $artifacts_dir"
+mkdir -p "$artifacts_dir"
+success-or-die $? "Unable to create directory: $artifacts_dir"
+
+echo "[2/5] Updating sssd-test-suite"
+git -C "$suite_dir" pull --rebase
+success-or-die $? "Unable to rebase sssd-test-suite at: $suite_dir"
+
+echo "[3/5] Preparing vagrant machines"
+for guest in $guests; do
+    start-guest $guest
+done
+
+echo "[4/5] Running tests"
+run-vagrant ssh client -- "$guest_source/contrib/test-suite/run-client.sh"
+success-or-die $? "SSSD Test Suite Failed: $?"
+
+echo "[5/5] Shutdown machines"
+for guest in $guests; do
+    stop-guest $guest
+done

From 67da861a71efb4f471979ef54665dfc388970d3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrez...@redhat.com>
Date: Thu, 4 Jul 2019 13:06:03 +0200
Subject: [PATCH 2/4] ci: switch to new tooling and remove 'Read trusted files'
 stage

The 'Read trusted files' stage was removed because all scripts are
now being executed on client machines so there is no point to prohibit
modification.
---
 Jenkinsfile                       |  57 +++++++----------
 contrib/test-suite/README.md      |  39 ++++--------
 contrib/test-suite/run-client.sh  |  37 -----------
 contrib/test-suite/run.sh         | 100 ------------------------------
 contrib/test-suite/test-suite.yml |  11 ++++
 5 files changed, 47 insertions(+), 197 deletions(-)
 delete mode 100755 contrib/test-suite/run-client.sh
 delete mode 100755 contrib/test-suite/run.sh
 create mode 100644 contrib/test-suite/test-suite.yml

diff --git a/Jenkinsfile b/Jenkinsfile
index 9cd8cb6509..6da9d26b84 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,9 +1,3 @@
-/**
- * Remember that the build failed because one of the untrusted files were
- * modified.
- */
-untrusted = false
-
 /**
  * SSSD CI.
  *
@@ -41,6 +35,11 @@ class CI {
    */
   public static String SuiteDir = this.BaseDir + '/sssd-test-suite'
 
+  /**
+   * Path to SSSD CI tools on Jenkins slave.
+   */
+  public static String CIDir = this.BaseDir + '/sssd-ci'
+
   /**
    * Workaround for https://issues.jenkins-ci.org/browse/JENKINS-39203
    *
@@ -99,12 +98,22 @@ class CI {
   public static def RunTests(ctx) {
     this.NotifyBuild(ctx, 'PENDING', 'Build is in progress.')
 
+    ctx.echo String.format(
+      'Executing tests, started at %s',
+      (new Date()).format('dd. MM. yyyy HH:mm:ss')
+    )
+
     ctx.sh String.format(
-      './sssd/contrib/test-suite/run.sh %s %s %s %s',
-      "${ctx.env.WORKSPACE}/sssd",
+      '%s/sssd-test-suite -c "%s" run --sssd "%s" --artifacts "%s" --update --prune',
       "${this.SuiteDir}",
-      "${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}",
-      "${this.BaseDir}/configs/${ctx.env.TEST_SYSTEM}.json"
+      "${this.BaseDir}/configs/${ctx.env.TEST_SYSTEM}.json",
+      "${ctx.env.WORKSPACE}/sssd",
+      "${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}"
+    )
+
+    ctx.echo String.format(
+      'Finished at %s',
+      (new Date()).format('dd. MM. yyyy HH:mm:ss')
     )
 
     this.BuildSuccessful(ctx.env.TEST_SYSTEM)
@@ -116,10 +125,11 @@ class CI {
   public static def WhenCompleted(ctx) {
     ctx.archiveArtifacts artifacts: "artifacts/**", allowEmptyArchive: true
     ctx.sh String.format(
-      "${this.BaseDir}/scripts/archive.sh %s %s %s",
+      '%s/sssd-ci archive --name "%s" --system "%s" --artifacts "%s"',
+      "${this.CIDir}",
+      "${ctx.env.BRANCH_NAME}/${ctx.env.BUILD_ID}",
       ctx.env.TEST_SYSTEM,
-      "${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}",
-      "${ctx.env.BRANCH_NAME}/${ctx.env.BUILD_ID}"
+      "${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}"
     )
     ctx.sh "rm -fr ${ctx.env.WORKSPACE}/artifacts/${ctx.env.TEST_SYSTEM}"
 
@@ -160,19 +170,6 @@ pipeline {
         CI_Notify('PENDING', 'Running tests.')
       }
     }
-    stage('Read trusted files') {
-      steps {
-        readTrusted './contrib/test-suite/run.sh'
-        readTrusted './contrib/test-suite/run-client.sh'
-      }
-      post {
-        failure {
-          script {
-            untrusted = true
-          }
-        }
-      }
-    }
     stage('Run Tests') {
       parallel {
         stage('Test on Fedora 28') {
@@ -216,13 +213,7 @@ pipeline {
   }
   post {
     failure {
-      script {
-        if (untrusted) {
-          CI_Notify('ERROR', 'Untrusted files were modified.')
-        } else {
-          CI_Notify('FAILURE', 'Some tests failed.')
-        }
-      }
+      CI_Notify('FAILURE', 'Some tests failed.')
     }
     aborted {
       CI_Notify('ERROR', 'Builds were aborted.')
diff --git a/contrib/test-suite/README.md b/contrib/test-suite/README.md
index 576d12d286..9d5b99a557 100644
--- a/contrib/test-suite/README.md
+++ b/contrib/test-suite/README.md
@@ -1,38 +1,23 @@
-# Run SSSD Test Suite
+# SSSD Test Suite
 
-Script `run.sh` will run all available SSSD test on a set of virtual machines created by vagrant. These virtual machines are part of separate project located at `https://github.com/SSSD/sssd-test-suite`.
+SSSD Test Suite is set of test that are being run automatically as part of Pull Request CI.
 
-## Automated Testing
+## Steps to run the tests manually on local machine
 
-These test are run automatically when you submit a Pull Request to SSSD project. Status report together with logs will be available in the Pull Request when testing is finished.
-
-## Steps to run the tests manually
+You need to clone and configure `sssd-test-suite` project to run these test manually on your local machine.
 
 1. Checkout `https://github.com/SSSD/sssd-test-suite`
 2. Configure and setup SSSD test suite per instructions located at project readme.
 3. Make sssd-test-suite use already provisioned boxes (either manually created or maintained by SSSD team at https://app.vagrantup.com/sssd-vagrant).
-4. Run `run.sh`, please note that this script will call `vagrant destroy` and it will thus destroy your existing guests.
+4. Run the tests with `sssd-test-suite` command line interface
 
+```bash
+$ git clone https://github.com/SSSD/sssd-test-suite
+$ cd sssd-test-suite
+$ cp ./configs/sssd-f30.json ./config.json
+$ ./sssd-test-suite run --sssd $path-to-sssd --artifacts /tmp/sssd-artifacts
 ```
-run.sh SSSD-SOURCE-DIR TEST-SUITE-DIR ARTIFACTS-DIR CONFIG-FILE
-  SSSD-SOURCE-DIR Path to SSSD source directory.
-  TEST-SUITE-DIR  Path to sssd-test-suite_dir directory.
-  ARTIFACTS-DIR   Path to directory where artifacts should be stored.
-  CONFIG-FILE     Path to sssd-test-suite_dir configuration file to use.
-```
-
-At this moment only `client` guest is required. We need to expand our test cases to test agains FreeIPA and Active Directory.
-
-## SSSD CI Architecture
-
-Jenkins master polls github for new branches and pull requests. When it discovers new pull request or branch or changes to existing pull request or branch it will allocate a jenkins agent and executes pipeline defined in `./Jenkinsfile` (in SSSD source) on this agent.
-
-The pipeline executes `./contrib/test-suite/run.sh` and archives logs when testing is finished. Script `./contrib/test-suite/run.sh` prepares sssd-test-suite, starts the vagrant machines and copy SSSD source code to the client machine. Then it calls `./contrib/test-suite/run-client.sh` on the client machine which runs continuous integration tests.
-
-### Extending current tests
-To extend current testing capabilities, modify `./contrib/test-suite/run.sh` and `./contrib/test-suite/run-client.sh` to new requirements. These files can be modified by anyone but are considered untrusted from contributor that is not an administrator of SSSD repository. This means that if a public contributor submits a pull request that changes those files, Jenkins will refuse to run tests.
 
-### Adding additional distribution to test on
-You need to modify `./Jenkinsfile`. Simply copy, paste and amend existing Fedora 28 stage. This file is also considered untrusted so only administrators can modify it within a pull request.
+See [sssd-test-suite documentation](https://github.com/SSSD/sssd-test-suite/blob/master/readme.md) for more information.
+See [running the tests documentation](https://github.com/SSSD/sssd-test-suite/blob/master/docs/running-tests.md) for more information about the process.
 
-You also need to extend `sssd-test-suite` and prepare vagrant boxes for this distro.
diff --git a/contrib/test-suite/run-client.sh b/contrib/test-suite/run-client.sh
deleted file mode 100755
index 3b9eb606fa..0000000000
--- a/contrib/test-suite/run-client.sh
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/bin/bash
-#
-# DO NOT RUN THIS MANUALLY
-#
-
-sssd_source="/shared/sssd"
-artifacts_dir="/shared/artifacts"
-
-archive-artifacts() {
-    echo "Archiving artifacts..."
-
-    cp -f $sssd_source/ci-*.log $artifacts_dir
-    cp -f $sssd_source/ci-build-debug/ci-*.log $artifacts_dir
-    cp -f $sssd_source/ci-build-debug/test-suite.log $artifacts_dir
-}
-
-success-or-die() {
-    ret=$1
-    msg=$2
-    if [ $ret -eq 0 ]; then
-        return 0
-    fi
-
-    echo $msg
-    archive-artifacts
-
-    exit $ret
-}
-
-cd $sssd_source
-
-echo "[1/1] Running Continuous Integration Tests"
-./contrib/ci/run --moderate --no-deps
-success-or-die $? "CI Failed!"
-
-archive-artifacts
-exit 0
diff --git a/contrib/test-suite/run.sh b/contrib/test-suite/run.sh
deleted file mode 100755
index bb4c06f59e..0000000000
--- a/contrib/test-suite/run.sh
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/bin/bash
-
-print-usage() {
-    cat <<EOF
-Run SSSD Continuous Integration Tests
-Make sure to checkout and setup https://github.com/SSSD/sssd-test-suite
-
-run.sh SSSD-SOURCE-DIR TEST-SUITE-DIR ARTIFACTS-DIR CONFIG-FILE
-  SSSD-SOURCE-DIR Path to SSSD source directory.
-  TEST-SUITE-DIR  Path to sssd-test-suite_dir directory.
-  ARTIFACTS-DIR   Path to directory where artifacts should be stored.
-  CONFIG-FILE     Path to sssd-test-suite_dir configuration file to use.
-EOF
-}
-
-print-help-if-asked() {
-    while test $# -gt 0
-    do
-        case "$1" in
-            --help)
-                print-usage ; exit 0
-                ;;
-            -h) print-usage ; exit 0
-                ;;
-            -?) print-usage ; exit 0
-                ;;
-        esac
-        shift
-    done
-}
-
-success-or-die() {
-    if [ $1 -ne 0 ]; then
-        echo $2
-        exit 1
-    fi
-}
-
-print-help-if-asked "$@"
-if [[ $# -ne 4 ]]; then
-    print-usage
-    exit 1
-fi
-
-sssd_source=$1
-suite_dir=$2
-artifacts_dir=$3
-config=$4
-
-guest_source="/shared/sssd"
-guest_artifacts="/shared/artifacts"
-
-# Currently only client machine is needed.
-guests="client"
-
-run-vagrant() {
-    VAGRANT_CWD="$suite_dir" \
-    SSSD_TEST_SUITE_RSYNC="$sssd_source:$guest_source" \
-    SSSD_TEST_SUITE_SSHFS="$artifacts_dir:$guest_artifacts" \
-    SSSD_TEST_SUITE_CONFIG="$config" \
-    vagrant "$@"
-}
-
-start-guest() {
-    # This may fail if guest's box was not yet downloaded. We will ignore it.
-    run-vagrant destroy $1 &> /dev/null
-
-    run-vagrant box update $1
-    success-or-die $? "Unable to update guest: $1"
-
-    run-vagrant up $1
-    success-or-die $? "Unable to start guest: $1"
-}
-
-stop-guest() {
-    run-vagrant halt $1
-    success-or-die $? "Unable to halt guest: $1"
-}
-
-echo "[1/5] Creating $artifacts_dir"
-mkdir -p "$artifacts_dir"
-success-or-die $? "Unable to create directory: $artifacts_dir"
-
-echo "[2/5] Updating sssd-test-suite"
-git -C "$suite_dir" pull --rebase
-success-or-die $? "Unable to rebase sssd-test-suite at: $suite_dir"
-
-echo "[3/5] Preparing vagrant machines"
-for guest in $guests; do
-    start-guest $guest
-done
-
-echo "[4/5] Running tests"
-run-vagrant ssh client -- "$guest_source/contrib/test-suite/run-client.sh"
-success-or-die $? "SSSD Test Suite Failed: $?"
-
-echo "[5/5] Shutdown machines"
-for guest in $guests; do
-    stop-guest $guest
-done
diff --git a/contrib/test-suite/test-suite.yml b/contrib/test-suite/test-suite.yml
new file mode 100644
index 0000000000..2b091349f6
--- /dev/null
+++ b/contrib/test-suite/test-suite.yml
@@ -0,0 +1,11 @@
+- name: Integration Tests
+  machines:
+  - client
+  tasks:
+  - name: Running ./contrib/ci/run
+    shell: ./contrib/ci/run --moderate --no-deps
+  artifacts:
+  - ci-*.log
+  - ci-build-debug/ci-*.log
+  - ci-build-debug/test-suite.log
+  timeout: 6 hours

From 33bfcebab3f3ff1733329d68679b377547d06b6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrez...@redhat.com>
Date: Wed, 10 Jul 2019 15:30:24 +0200
Subject: [PATCH 3/4] ci: rebase pull request on the target branch

---
 Jenkinsfile | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/Jenkinsfile b/Jenkinsfile
index 6da9d26b84..333b22c4e7 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -51,6 +51,7 @@ class CI {
    * parallel failed.
    */
   public static def Results = [:]
+  public static def RebaseResults = [:]
 
   /**
    * Mark build as successfull.
@@ -66,6 +67,20 @@ class CI {
     return this.Results[build] == "success"
   }
 
+  /**
+   * Mark build as successfully rebased.
+   */
+  public static def RebaseSuccessful(build) {
+    this.RebaseResults[build] = "success"
+  }
+
+  /**
+   * Return true if the rebase was successful.
+   */
+  public static def IsRebaseSuccessful(build) {
+    return this.RebaseResults[build] == "success"
+  }
+
   /**
    * Send commit status to Github for sssd-ci context.
    */
@@ -92,11 +107,36 @@ class CI {
       )
   }
 
+  public static def Rebase(ctx) {
+    if (!ctx.env.CHANGE_TARGET) {
+      this.RebaseSuccessful(ctx.env.TEST_SYSTEM)
+      return
+    }
+
+    ctx.echo String.format('Rebasing on %s', ctx.env.CHANGE_TARGET)
+
+    ctx.sh String.format(
+      'git -C %s fetch --no-tags --progress origin +refs/heads/%s:refs/remotes/origin/%s',
+      "${ctx.env.WORKSPACE}/sssd",
+      ctx.env.CHANGE_TARGET,
+      ctx.env.CHANGE_TARGET
+    )
+
+    ctx.sh String.format(
+      'git -C %s rebase origin/%s',
+      "${ctx.env.WORKSPACE}/sssd",
+      ctx.env.CHANGE_TARGET
+    )
+
+    this.RebaseSuccessful(ctx.env.TEST_SYSTEM)
+  }
+
   /**
    * Run tests. TEST_SYSTEM environment variable must be defined.
    */
   public static def RunTests(ctx) {
     this.NotifyBuild(ctx, 'PENDING', 'Build is in progress.')
+    this.Rebase(ctx)
 
     ctx.echo String.format(
       'Executing tests, started at %s',
@@ -123,6 +163,12 @@ class CI {
    * Archive artifacts and notify Github about build result.
    */
   public static def WhenCompleted(ctx) {
+    if (!this.IsRebaseSuccessful(ctx.env.TEST_SYSTEM)) {
+      ctx.echo "Unable to rebase on target branch."
+      this.NotifyBuild(ctx, 'FAILURE', 'Unable to rebase on target branch.')
+      return
+    }
+
     ctx.archiveArtifacts artifacts: "artifacts/**", allowEmptyArchive: true
     ctx.sh String.format(
       '%s/sssd-ci archive --name "%s" --system "%s" --artifacts "%s"',

From 6f9988f0ff588f0e3b6e3cf4a58f0957d0d3c606 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrez...@redhat.com>
Date: Thu, 11 Jul 2019 10:04:06 +0200
Subject: [PATCH 4/4] ci: print node on which the test is being run

---
 Jenkinsfile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Jenkinsfile b/Jenkinsfile
index 333b22c4e7..2ebfe52ece 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -135,6 +135,7 @@ class CI {
    * Run tests. TEST_SYSTEM environment variable must be defined.
    */
   public static def RunTests(ctx) {
+    ctx.echo "Running on ${ctx.env.NODE_NAME}"
     this.NotifyBuild(ctx, 'PENDING', 'Build is in progress.')
     this.Rebase(ctx)
 
_______________________________________________
sssd-devel mailing list -- sssd-devel@lists.fedorahosted.org
To unsubscribe send an email to sssd-devel-le...@lists.fedorahosted.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedorahosted.org/archives/list/sssd-devel@lists.fedorahosted.org

Reply via email to