incubator-bigtop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aba...@apache.org
Subject svn commit: r1148501 [43/47] - in /incubator/bigtop: branches/ tags/ trunk/ trunk/docs/ trunk/src/ trunk/src/pkg/ trunk/src/pkg/common/ trunk/src/pkg/common/flume/ trunk/src/pkg/common/hadoop/ trunk/src/pkg/common/hadoop/conf.pseudo/ trunk/src/pkg/comm...
Date Tue, 19 Jul 2011 19:45:54 GMT
Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/DeployCDH.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/DeployCDH.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/DeployCDH.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/DeployCDH.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,110 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cloudera.itest.packagesmoke
+
+import org.junit.Test
+import com.cloudera.itest.pmanager.PackageManager
+import com.cloudera.itest.pmanager.PackageInstance
+import org.hamcrest.Matcher
+import org.junit.Rule
+import org.junit.rules.ErrorCollector
+import static org.hamcrest.CoreMatchers.equalTo
+
+class DeployCDH {
+    List<String> cdh2 = [
+     "hadoop-0.20", "hadoop-0.20-conf-pseudo", "hadoop-0.20-datanode",
+     "hadoop-0.20-fuse", "hadoop-0.20-jobtracker", "hadoop-0.20-namenode", "hadoop-0.20-native",
+     "hadoop-0.20-pipes", "hadoop-0.20-secondarynamenode", "hadoop-0.20-source",
+     "hadoop-0.20-tasktracker", "hadoop-hive", "hadoop-pig" ];
+    List<String> cdh3b2 = [
+     "flume", "flume-master", "flume-node", "hadoop-0.20", "hadoop-0.20-conf-pseudo", "hadoop-0.20-conf-pseudo-hue",
+     "hadoop-0.20-datanode", "hadoop-0.20-fuse", "hadoop-0.20-jobtracker", "hadoop-0.20-namenode", "hadoop-0.20-native",
+     "hadoop-0.20-pipes", "hadoop-0.20-secondarynamenode", "hadoop-0.20-source",
+     "hadoop-0.20-tasktracker", "hadoop-hbase",
+     "hadoop-hbase-master", "hadoop-hbase-regionserver", "hadoop-hbase-thrift", "hadoop-hive", "hadoop-pig",
+     "hadoop-zookeeper", "hadoop-zookeeper-server", "hue", "hue-about", "hue-beeswax", "hue-common",
+     "hue-filebrowser", "hue-help", "hue-jobbrowser", "hue-jobsub", "hue-plugins", "hue-proxy",
+     "hue-useradmin", "oozie", "sqoop" ];
+    List<String> cdh3b3 = [
+     "flume", "flume-master", "flume-node", "hadoop-0.20", "hadoop-0.20-conf-pseudo",
+     "hadoop-0.20-datanode", "hadoop-0.20-fuse", "hadoop-0.20-jobtracker", "hadoop-0.20-namenode", "hadoop-0.20-native",
+     "hadoop-0.20-pipes", "hadoop-0.20-sbin", "hadoop-0.20-secondarynamenode", "hadoop-0.20-source",
+     "hadoop-0.20-tasktracker", "hadoop-hbase", "hadoop-hbase-doc",
+     "hadoop-hbase-master", "hadoop-hbase-regionserver", "hadoop-hbase-thrift", "hadoop-hive", "hadoop-pig",
+     "hadoop-zookeeper", "hadoop-zookeeper-server", "hue", "hue-about", "hue-beeswax", "hue-common",
+     "hue-filebrowser", "hue-help", "hue-jobbrowser", "hue-jobsub", "hue-plugins", "hue-proxy",
+     "hue-useradmin", "oozie", "oozie-client", "sqoop", "sqoop-metastore", "whirr" ];
+
+    List<String> aptPkg = [ "hadoop-0.20-doc", "libhdfs0", "libhdfs0-dev", "python-hive" ];
+    List<String> yumPkg = [ "hadoop-0.20-debuginfo", "hadoop-0.20-libhdfs" ];
+    List<String> zypperPkg = [ "hadoop-0.20-libhdfs", "hadoop-0.20-doc" ];
+
+    Map<String, LinkedHashMap<String, Collection>> distPackages = [
+      "2" : [ "apt" : cdh2 + aptPkg,
+              "yum" : cdh2 + yumPkg + [ "hadoop-0.20-docs", "hadoop-hive-webinterface" ],
+              // "cloudera-desktop", "cloudera-desktop-plugins",
+            ],
+    "3b2" : [ "apt" : cdh3b2 + aptPkg,
+              "yum" : cdh3b2 + yumPkg + [ "hadoop-0.20-docs", "hadoop-hive-webinterface" ],
+            ],
+    "3b3" : [ "apt" : cdh3b3 + aptPkg + [ "hadoop-hbase-doc",  ],
+              "yum" : cdh3b3 + yumPkg + [ "hadoop-0.20-docs", "hadoop-hive-webinterface" ],
+            ],
+    "3b4" : [ "apt" : cdh3b3 + aptPkg + [ "hadoop-hbase-doc",  ],
+              "yum" : cdh3b3 + yumPkg + [ "hadoop-0.20-doc",  "hadoop-hive-webinterface" ],
+              "zypper" : cdh3b3 + zypperPkg,
+            ],
+    "3"   : [ "apt" : cdh3b3 + aptPkg + [ "hadoop-hbase-doc",  ],
+              "yum" : cdh3b3 + yumPkg + [ "hadoop-0.20-doc" ],
+              "zypper" : cdh3b3 + zypperPkg,
+            ],
+    "3u0" : [ "apt" : cdh3b3 + aptPkg + [ "hadoop-hbase-doc",  ],
+              "yum" : cdh3b3 + yumPkg + [ "hadoop-0.20-doc" ],
+              "zypper" : cdh3b3 + zypperPkg,
+            ],
+    ];
+
+  @Rule
+  public ErrorCollector errors = new ErrorCollector();
+
+  @Test
+  void deployCDH() {
+    PackageTestRepoMgr oldRepo = new PackageTestRepoMgr("cdh.prev.repo");
+    PackageManager pm = oldRepo.getPm();
+
+    List<String> packages = (distPackages[System.getProperty("cdh.prev.repo.version", "3b4")] ?: [:])[pm.type] ?: [];
+
+    oldRepo.addRepo();
+    checkThat("failed to add repository for pre-upgrade CDH deployment",
+              oldRepo.getPm().refresh(), equalTo(0));
+
+    packages.each {
+      PackageInstance pkg = PackageInstance.getPackageInstance(pm, it);
+      checkThat("failed to install required package ${pkg.getName()}",
+                pkg.install(), equalTo(0));
+      pkg.getServices().each { it.value.stop(); }
+    }
+
+    oldRepo.removeRepo();
+  }
+
+  public void checkThat(String msg, Object value, Matcher<Object> matcher) {
+    PackageTestErrorProxy.checkThat(errors, msg, value, matcher);
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestCommon.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestCommon.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestCommon.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestCommon.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,437 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cloudera.itest.packagesmoke
+
+import org.junit.rules.ErrorCollector
+import com.cloudera.itest.pmanager.PackageManager
+import com.cloudera.itest.pmanager.PackageInstance
+import com.cloudera.itest.posix.Service
+import com.cloudera.itest.posix.UGI
+import com.cloudera.itest.posix.Alternative
+import junit.framework.AssertionFailedError
+import static org.hamcrest.CoreMatchers.equalTo
+import org.hamcrest.Matcher
+
+import static com.cloudera.itest.packagesmoke.PackageTestMatchers.MapHasKeys.hasSameKeys
+import com.cloudera.itest.shell.Shell
+
+class PackageTestCommon {
+  static public PackageManager pm;
+
+  PackageInstance pkg;
+  String name;
+
+  ErrorCollector result;
+
+  public void checkThat(String msg, Object value, Matcher<Object> matcher) {
+    PackageTestErrorProxy.checkThat(result, msg, value, matcher);
+  }
+
+  public void recordFailure(String message) {
+    result.addError(new AssertionFailedError(message));
+  }
+
+  String formatDescription(String description, String summary) {
+    return ((summary ?: "") + ' ' + description).replaceAll(/\s+/,' ').trim();
+  }
+
+  private void checkMetadata(PackageInstance pkg, Map expected_metadata) {
+    boolean noSummary = (pm.type == "apt");
+
+    expected_metadata.each { key, expected ->
+      String actual = (pkg.meta["$key"] ?: "").toString().replaceAll(/\n/, ' ');
+
+      if (key == "summary") {
+        if (noSummary) {
+          expected = actual;
+        } else {
+          expected = formatDescription(expected, null);
+          actual = formatDescription(actual, null); 
+        }
+      }
+      if (key == "description") {
+        actual = formatDescription(actual, null);
+        expected = formatDescription(expected, noSummary ? expected_metadata["summary"] : null);
+      }
+
+      checkThat("checking $key on package $name",
+                actual, equalTo(expected));
+    }
+  }
+
+  public void checkMetadata(Map expected_metadata) {
+    checkMetadata(pkg, expected_metadata);
+  }
+
+  public void checkRemoteMetadata(Map expected_metadata, boolean unique) {
+    List<PackageInstance> pl = pm.lookup(name);
+
+    if (pm.getType() == "zypper") {
+      expected_metadata.remove("url");
+    }
+
+    if (unique && pl.size() != 1) {
+      recordFailure("more than one package is available for name $name");
+    } else if (pl.size() == 0) {
+      recordFailure("can not find $name in the repository");
+    } else {
+      checkMetadata(pl.get(0), expected_metadata);
+    }
+  }
+
+  public void checkPulledDeps(Map expected_deps) {
+    Map pkgDeps = pkg.getDeps();
+
+    checkThat("a set of dependencies of package $name is different from what was expected",
+              pkgDeps, hasSameKeys(expected_deps));
+
+    expected_deps.each { depName, version ->
+      if (version == "/self") {
+        PackageInstance dep = PackageInstance.getPackageInstance(pm, depName);
+        dep.refresh();
+        checkThat("checking that an expected dependecy $depName for the package $name has the same version",
+                  "${dep.getVersion()}-${dep.getRelease()}", equalTo("${pkg.getVersion()}-${pkg.getRelease()}"));
+      }
+      // checkThat("checking that and expected dependency $key for the package $name got pulled",
+      //           dep.isInstalled(), equalTo(true));
+    }
+  }
+
+  private String svcStatusDecoder(String status) {
+    if ((status =~ /\.\.failed|not running/).find()) {
+      return "stop";
+    } else if ((status =~ /run|start/).find()) {
+      return "start";
+    } else {
+      return "stop";
+    }
+  }
+
+  void checkService(Service svc, Map svc_metadata) {
+    String name = svc.getName();
+    Map runlevels = [:];
+
+    // TODO: this should really be taken care of by the matcher
+    svc.getRunLevels().each {
+      runlevels[it] = it;
+    }
+
+    checkThat("wrong list of runlevels for service $name",
+              runlevels, hasSameKeys(svc_metadata.runlevel));
+
+    checkThat("wrong state of service $name after installation",
+              svcStatusDecoder(svc.status()), equalTo(svc_metadata.oninstall));
+
+    svc.stop();
+    sleep(3001);
+    checkThat("service $name is expected to be stopped",
+              svcStatusDecoder(svc.status()), equalTo("stop"));
+
+    if (svc_metadata.configured == "true") {
+      checkThat("can not start service $name",
+                svc.start(), equalTo(0));
+      sleep(3001);
+      checkThat("service $name is expected to be started",
+                svcStatusDecoder(svc.status()), equalTo("start"));
+
+      checkThat("can not restart service $name",
+                svc.restart(), equalTo(0));
+      sleep(3001);
+      checkThat("service $name is expected to be re-started",
+                svcStatusDecoder(svc.status()), equalTo("start"));
+
+      checkThat("can not stop service $name",
+                svc.stop(), equalTo(0));
+      sleep(3001);
+      checkThat("service $name is expected to be stopped",
+                svcStatusDecoder(svc.status()), equalTo("stop"));
+    }
+
+    // Stopping 2nd time (making sure that a stopped service is
+    // not freaked out by an extra stop)
+    checkThat("can not stop an already stopped service $name",
+              svc.stop(), equalTo(0));
+    checkThat("wrong status after stopping service $name for the second time",
+              svcStatusDecoder(svc.status()), equalTo("stop"));
+  }
+
+  public void checkServices(Map expectedServices) {
+    Map svcs = pm.getServices(pkg);
+
+    checkThat("wrong list of services in a package $name",
+              expectedServices, hasSameKeys(svcs));
+
+    expectedServices.each { key, value ->
+      if (svcs[key] != null) {
+        checkService(svcs[key], value);
+      }
+    }
+  }
+
+  public void checkUsers(Map expectedUsers) {
+    UGI ugi = new UGI();
+
+    expectedUsers.each { key, value ->
+      Map user = ugi.getUsers()[key];
+      if (user != null) {
+        checkThat("checking user $key home directory",
+                  user.home, equalTo(value.home));
+        checkThat("checking user $key description",
+                  user.descr.replaceAll(/,*$/, ""), equalTo(value.descr));
+        checkThat("checking user $key shell",
+                  user.shell, equalTo(value.shell));
+      } else {
+        recordFailure("package $name is epected to provide user $key");
+      }
+    }
+  }
+
+  public void checkGroups(Map expectedGroups) {
+    UGI ugi = new UGI();
+
+    expectedGroups.each { key, value ->
+      Map group = ugi.getGroups()[key];
+      if (group != null) {
+        (value.user instanceof List ? value.user : [value.user]).each {
+          checkThat("group $key is expected to contain user $it",
+                    group.users.contains(it), equalTo(true));
+        }
+      } else {
+        recordFailure("package $name is epected to provide group $key");
+      }
+    }
+  }
+
+  public void checkAlternatives(Map expectedAlternatives) {
+    expectedAlternatives.each { key, value ->
+      Alternative alt = new Alternative(key);
+      if (alt.getAlts().size() > 0) {
+        checkThat("alternative link ${value.link} doesn't exist or does not point to /etc/alternatives",
+                  (new Shell()).exec("readlink ${value.link}").getOut().get(0),
+                  equalTo("/etc/alternatives/$key".toString()));
+
+        checkThat("alternative $key has incorrect status",
+                  alt.getStatus(), equalTo(value.status));
+        checkThat("alternative $key points to an unexpected target",
+                  alt.getValue(), equalTo(value.value));
+
+        def altMap = [:];
+        ((value.alt instanceof List) ? value.alt : [value.alt]).each { altMap[it] = it; }
+
+        checkThat("alternative $key has incorrect set of targets",
+                  alt.getAlts(), hasSameKeys(altMap));
+      } else {
+        recordFailure("package $name is expected to provide alternative $key");
+      }
+    }
+  }
+
+  List sliceUp(List l, int chunks) {
+    List res = [];
+    int i = 0;
+    while (i + chunks < l.size()) {
+      res.add(l.subList(i, i+chunks));
+      i += chunks;
+    }
+    res.add(l.subList(i, l.size()));
+    return res;
+  }
+
+  Map getLsMetadata(List files) {
+    Map lsFiles = [:];
+
+    sliceUp(files, 500).each { files_chunk ->
+    (new Shell()).exec("ls -ld '${files_chunk.join('\' \'')}'").out.each {
+      String fileName = it.replaceAll('^[^/]*/',"/");
+      def matcher = (it =~ /\S+/);
+
+      Map meta = [:];
+      if ((fileName =~ /->/).find()) {
+        meta.target = fileName.replaceAll(/^.*-> /, '');
+        fileName = fileName.replaceAll(/ ->.*$/, '');
+      }
+      meta.perm  = matcher[0];
+      meta.user  = matcher[2];
+      meta.group = matcher[3];
+      lsFiles[fileName] = meta;
+    }
+    }
+    return lsFiles;
+  }
+
+  // TODO: we might need to check that the files are actually owned by the installing package
+  // although this does sound like testing package manager itself
+  void updateOwners(Map files) {
+    Shell sh = new Shell();
+    List fileList = files.keySet().toList();
+
+    if (pm.type == "apt") {
+      int curFile = 0;
+      sliceUp(fileList, 500).each { fileList_chunk ->
+      sh.exec("dpkg -S '${fileList_chunk.join('\' \'')}'").out.each {
+        String n = it.replaceAll(/^.*: \//, "/");
+        while (fileList[curFile] != n) {
+          files[fileList[curFile]].owners = 0;
+          curFile++;
+        }
+        files[n].owners = it.replaceAll(/: \/.*$/,"").split(',').size();
+        curFile++;
+      }
+      }
+    } else {
+      int curFile = -1;
+      sliceUp(fileList, 500).each { fileList_chunk ->
+      sh.exec("rpm -qf /bin/cat '${fileList_chunk.join('\' /bin/cat \'')}'").out.each {
+        if ((it =~ /^coreutils/).find()) {
+          curFile++;
+          files[fileList[curFile]].owners = 0;
+        } else if (!(it =~ /not owned by any package/).find()) {
+          files[fileList[curFile]].owners++;
+        }
+      }
+      }
+    }
+  }
+
+  public void checkFiles(Map config, Map doc, Map file) {
+    Map files = [:];
+    Map docs = [:];
+    Map configs = [:];
+
+    pkg.getFiles().each { files[it.toString()] = it; }
+    pkg.getConfigs().each { configs[it.toString()] = it; files.remove(it.toString()); }
+    pkg.getDocs().each { docs[it.toString()] = it; files.remove(it.toString()); }
+
+    if (pm.type == "apt" && doc != null) {
+      file.putAll(doc);
+    } else {
+      checkThat("list of documentation files of pacakge $name is different from what was expected",
+                docs, hasSameKeys(doc));
+    }
+    checkThat("list of config files of pacakge $name is different from what was expected",
+              configs, hasSameKeys(config));
+    checkThat("list of regular files of pacakge $name is different from what was expected",
+              files, hasSameKeys(file));
+
+    // TODO: we should probably iterate over a different set of files to include loose files as well
+    Shell sh = new Shell();
+    List fileList = [];
+    file.each { fileList.add(it.key.toString()); }
+    doc.each { fileList.add(it.key.toString()); }
+    config.each { fileList.add(it.key.toString()); }
+    fileList.sort();
+
+    Map fileMeta = getLsMetadata(fileList);
+    if (fileMeta.size() != 0) {
+      updateOwners(fileMeta); // this is an expensive (and fragile operation)
+    }
+
+    List problemFiles = [];
+    Map goldenFileMeta = [:];
+    goldenFileMeta.putAll(file ?: [:]);
+    goldenFileMeta.putAll(config ?: [:]);
+    goldenFileMeta.putAll(doc ?: [:]);
+
+    fileList.each {
+      Map meta = fileMeta[it];
+      Map goldenMeta = goldenFileMeta[it];
+
+      if (goldenMeta.owners != "-1") { // TODO: we shouldn't really skip anything even for multi-owned dirs
+      if (meta == null ||
+          !meta.perm.equals(goldenMeta.perm) ||
+          !meta.user.equals(goldenMeta.user) ||
+          !meta.group.equals(goldenMeta.group) ||
+          (goldenMeta.target != null && !goldenMeta.target.equals(meta.target)) ||
+          (Integer.parseInt(goldenMeta.owners) == 1 && !meta.owners.toString().equals(goldenMeta.owners))) {
+        problemFiles.add(it);
+      }
+      }
+    }
+    checkThat("file metadata difference detected on the following files",
+                problemFiles, equalTo([]));
+
+    // a bit of debug output
+    pkg.getFiles().each {
+      Map meta = fileMeta[it] ?: [:];
+      String target = meta.target ? " target=\"${meta.target}\"" : "";
+      String tip = configs[it] ? "config" : (docs[it] ? "doc " : "file");
+      println "\n::: ${name}    <${tip} name=\"${it}\" owners=\"${meta.owners}\" perm=\"${meta.perm}\"" +
+                                  " user=\"${meta.user}\" group=\"${meta.group}\"${target}/>";
+    }
+    // println "";
+  }
+
+  public void checkComplimentary32bitInstall() {
+    // RedHat (5.X) systems are THE ONLY place where we can try
+    // installing amd64 and i386 packages at the same time. On top of
+    // that we have a pretty weird policy on which pairs are supposed
+    // to go together (short answer is -- not all of them).
+    Map complimentaryPackages = [
+      "hadoop-0.20-sbin.x86_64"      : "hadoop-0.20-sbin.i386",
+      "hadoop-0.20-pipes.x86_64"     : "hadoop-0.20-pipes.i386",
+      "hadoop-0.20-native.x86_64"    : "hadoop-0.20-native.i386",
+      "hadoop-0.20-libhdfs.x86_64"   : "hadoop-0.20-libhdfs.i386",
+      "hadoop-0.20-debuginfo.x86_64" : "hadoop-0.20-debuginfo.i386",
+    ];
+
+    if (complimentaryPackages[name] != null) {
+      PackageInstance pkg386 = PackageInstance.getPackageInstance(pm, complimentaryPackages[name]);
+
+      checkThat("complimentary native package ${pkg386.getName()} failed to be installed",
+                pkg386.install(), equalTo(0));
+      checkThat("complimentary native package ${pkg386.getName()} failed to be removed",
+                pkg386.remove(), equalTo(0));
+    }
+  }
+
+  public void checkPackageFilesGotRemoved(Map files) {
+    List allFiles = [];
+    (files.file   ?: [:]).each { if (it.value.owners == "1") { allFiles.add(it.key) } };
+    (files.doc    ?: [:]).each { if (it.value.owners == "1") { allFiles.add(it.key) } };
+    (files.config ?: [:]).each { if (it.value.owners == "1") { allFiles.add(it.key) } };
+
+    allFiles.each {
+      checkThat("file $it still present after package is being removed",
+                (new File(it)).exists(), equalTo(false));
+    }
+  }
+
+  public void checkRemoval() {
+    checkComplimentary32bitInstall();
+
+    // We need to start service for one more time to make sure that package
+    // removal would succeed even when services are still running
+    pkg.getServices().each { name, svc ->
+      checkThat("can not start service $name",
+                svc.start(), equalTo(0));
+    }
+    sleep(3001); // TODO FIXME: CDH-2816 should address the timing of daemons start.
+
+    checkThat("package $name failed to be removed",
+              pkg.remove(), equalTo(0));
+    checkThat("package $name is NOT expected to remain installed after removal",
+              pm.isInstalled(pkg), equalTo(false));
+
+    checkPackageFilesGotRemoved(getMap(golden.content));
+  }
+
+  static public boolean isUpgrade() {
+    return System.getProperty("cdh.prev.repo.version", "") != "";
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestErrorProxy.java
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestErrorProxy.java?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestErrorProxy.java (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestErrorProxy.java Tue Jul 19 19:44:48 2011
@@ -0,0 +1,34 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke;
+
+import org.hamcrest.Matcher;
+import org.junit.rules.ErrorCollector;
+import java.util.concurrent.Callable;
+import static org.junit.Assert.assertThat;
+
+public class PackageTestErrorProxy {
+  static public void checkThat(ErrorCollector ec, final String msg, final Object value, final Matcher<Object> matcher) {
+    ec.checkSucceeds(new Callable<Object>() {
+        public Object call() throws Exception {
+            assertThat(msg, value, matcher);
+            return value;
+        }
+    });
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestMatchers.java
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestMatchers.java?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestMatchers.java (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestMatchers.java Tue Jul 19 19:44:48 2011
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke;
+
+import org.hamcrest.Description;
+import org.hamcrest.Factory;
+import org.hamcrest.Matcher;
+import org.junit.internal.matchers.TypeSafeMatcher;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class PackageTestMatchers {
+  static public class MapHasKeys extends TypeSafeMatcher<Map<Object, Object>> {
+    private Map<Object, Object> golden_map;
+
+    public MapHasKeys(Map<Object, Object> map) {
+      golden_map = map;
+    }
+
+    @Override
+    public boolean matchesSafely(Map<Object, Object> map) {
+      if (map.size() != golden_map.size()) {
+        return false;
+      }
+      for (Map.Entry<Object, Object> entry : map.entrySet()) {
+        if (!golden_map.containsKey(entry.getKey())) {
+          return false;
+        }
+      }
+      return true;
+    }
+
+    public void describeTo(Description description) {
+      description.appendText("<[");
+      for (Map.Entry<Object, Object> entry : golden_map.entrySet()) {
+        description.appendText(entry.getKey().toString() + "=" + entry.getKey().toString() + ", ");
+      }
+      description.appendText("]>");
+    }
+
+    @Factory
+    public static <T> Matcher<Map<Object, Object>> hasSameKeys(Map<Object, Object> map) {
+      return new MapHasKeys(map);
+    }
+
+    @Factory
+    public static <T> Matcher<Map<Object, Object>> hasSameKeys(List<Object> list) {
+      return new MapHasKeys(mapify(list));
+    }
+
+    @Factory
+    public static <T> Matcher<Map<Object, Object>> hasSameKeys(String text) {
+      HashMap<Object, Object> map = new HashMap<Object, Object>();
+      map.put(text, text);
+      return new MapHasKeys(map);
+    }
+
+    private static Map<Object, Object> mapify(List<Object> list) {
+      HashMap<Object, Object> map = new HashMap<Object, Object>();
+      if (list != null) {
+        for (Object it : list) {
+          map.put(it, it);
+        }
+      }
+      return map;
+    }
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestRepoMgr.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestRepoMgr.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestRepoMgr.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/PackageTestRepoMgr.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.pmanager.PackageManager
+import static com.cloudera.itest.shell.OS.linux_codename
+import static com.cloudera.itest.shell.OS.linux_flavor
+
+
+class PackageTestRepoMgr {
+  PackageManager pm = PackageManager.getPackageManager();
+
+  String cdhRepoVersion;
+  String cdhRepoFileURL;
+  String cdhRepoURL;
+  String cdhKeyURL;
+  String cdhRepoHost;
+
+  String repoName;
+
+  public PackageTestRepoMgr(String _cdhRepoVersion, String _cdhRepoFileURL, String _cdhRepoURL, String _cdhKeyURL) {
+    cdhRepoVersion = _cdhRepoVersion;
+    cdhRepoFileURL = _cdhRepoFileURL;
+    cdhRepoURL = _cdhRepoURL;
+    cdhKeyURL = _cdhKeyURL;
+  }
+
+  public PackageTestRepoMgr(String prefix) {
+    parseRepoSpec(prefix);
+  }
+
+  public PackageTestRepoMgr() {
+    parseRepoSpec("cdh.repo");
+  }
+
+  public parseRepoSpec(String prefix) {
+    cdhRepoHost = System.getProperty("${prefix}.host", "nightly.cloudera.com");
+    cdhRepoVersion = System.getProperty("${prefix}.version", "3");
+
+    Map cdhKeys  = [ yum    : "http://${cdhRepoHost}/redhat/cdh/RPM-GPG-KEY-cloudera",
+                     zypper : null,
+                     apt    : "http://${cdhRepoHost}/debian/archive.key" ];
+    Map cdhRepos = [ yum    : "http://${cdhRepoHost}/redhat/cdh/${cdhRepoVersion}",
+                     zypper : "http://${cdhRepoHost}/sles/11/x86_64/cdh/${cdhRepoVersion}",
+                     apt    : "http://${cdhRepoHost}/debian/" ];
+
+    cdhRepoFileURL = System.getProperty("${prefix}.file.url.${linux_flavor.replaceAll(/\s/,'_')}",
+                       System.getProperty("${prefix}.file.url",
+                         "http://does.not.exist"));
+
+    cdhRepoURL = System.getProperty("${prefix}.url", cdhRepos[pm.getType()]);
+    cdhKeyURL = System.getProperty("${prefix}.key.url", cdhKeys[pm.getType()]);
+  }
+
+  public boolean addRepo() {
+    repoName = "cloudera-cdh${cdhRepoVersion}";
+    try {
+      String repoText = cdhRepoFileURL.toURL().text;
+      if (pm.addBinRepo(repoName, repoText)) {
+        return false;
+      }
+
+    } catch (Throwable ex) {
+      if (pm.addBinRepo(repoName, cdhRepoURL, cdhKeyURL, "${linux_codename}-cdh${cdhRepoVersion} contrib")) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  public boolean removeRepo() {
+    return (pm.removeBinRepo(repoName) == 0);
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifier.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifier.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifier.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifier.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+public class StateVerifier {
+  public boolean config() {
+    return true;
+  }
+
+  public void createState() {};
+  public boolean verifyState() {
+    return true;
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierFlume.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierFlume.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierFlume.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierFlume.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import java.security.MessageDigest
+import org.junit.Before
+import org.junit.After
+import org.junit.Test
+
+class StateVerifierFlume extends StateVerifier {
+  Shell shFlume = new Shell("flume shell");
+
+  public void createState() {
+    String node;
+    shFlume.exec("connect localhost",
+                 "getnodestatus",
+                 "quit\n");
+    node = shFlume.getOut().join(' ').replaceAll(/ --> IDLE.*$/,'')
+                                     .replaceAll(/^.*Master knows about [0-9]* nodes /,'')
+                                     .trim();
+    shFlume.exec("connect localhost",
+                 "exec config $node 'text(\"/etc/group\")' 'dfs(\"hdfs://localhost/flume.test\")'",
+                 "quit\n");
+    sleep(5001);
+    (new Shell()).exec("hadoop fs -rm /flume.test");
+  }
+
+  public boolean verifyState() {
+    sleep(5001);
+    return ((new Shell()).exec("hadoop fs -ls /flume.test >/dev/null 2>&1").getRet() == 0);
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHBase.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHBase.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHBase.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHBase.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import java.security.MessageDigest
+
+class StateVerifierHBase extends StateVerifier {
+  static Shell shHBase = new Shell('hbase shell');
+
+  public boolean config() {
+    Shell shRoot = new Shell("/bin/bash", "root");
+    return 0 == shRoot.exec("""echo '<configuration>
+                                       <property>
+                                         <name>hbase.rootdir</name>
+                                         <value>hdfs://localhost/hbase</value>
+                                       </property>
+                                     </configuration>' > /etc/hbase/conf/hbase-site.xml""").getRet();
+  }
+
+  public static void createStaticState() {
+    shHBase.exec("create 't1', 'f1'",
+                 "put 't1', 'r1', 'f1:q', 'val'",
+                 "quit\n");
+  }
+
+  public static boolean verifyStaticState() {
+    shHBase.exec("scan 't1'",
+                 "quit\n");
+
+    return (shHBase.getOut().join(' ') =~ /r1.*column=f1:q.*value=val/).find();
+  }
+
+  public void createState() {
+    createStaticState()
+  }
+
+  public boolean verifyState() {
+    return verifyStaticState()
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHDFS.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHDFS.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHDFS.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHDFS.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import java.security.MessageDigest
+
+class StateVerifierHDFS extends StateVerifier {
+  static Shell sh = new Shell();
+
+  /*
+  MessageDigest MD5 = MessageDigest.getInstance("MD5");
+  byte[] digest;
+  String hdfsName;
+
+  public void createState() {
+    File dataFile =  File.createTempFile("StateVerifierHDFS", ".bin");
+    String name = dataFile.getAbsolutePath();
+    dataFile.deleteOnExit();
+
+    sh.exec("dd if=/dev/urandom of=$name bs=4096 count=1024",
+            "hadoop fs -put $name $name");
+    MD5.update(dataFile.readBytes());
+    digest = MD5.digest();
+    hdfsName = name;
+  }
+
+  public boolean verifyState() {
+    File dataFile =  File.createTempFile("StateVerifierHDFS", ".bin");
+    String name = dataFile.getAbsolutePath();
+    dataFile.deleteOnExit();
+
+    dataFile.delete();
+    sh.exec("hadoop fs -get $hdfsName $name");
+    try {
+      MD5.update(dataFile.readBytes());
+    } catch (Throwable x) {
+      return false;
+    }
+    return (Arrays.equals(digest, MD5.digest()));
+  } */
+
+  public static void createStaticState() {
+    sh.exec("hadoop fs -put <(echo StateHDFSVErifier) /StateHDFSVErifier");
+  }
+
+  public static boolean verifyStaticState() {
+    return sh.exec("hadoop fs -cat /StateHDFSVErifier").getOut().join('') == "StateHDFSVErifier";
+  }
+
+  public void createState() {
+    createStaticState()
+  }
+
+  public boolean verifyState() {
+    return verifyStaticState()
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHue.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHue.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHue.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierHue.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import org.junit.Test
+
+class StateVerifierHue extends StateVerifier {
+  final static String hueServer = "http://localhost:8088"
+  final static String loginURL = "${hueServer}/accounts/login/";
+  final static String checkURL = "${hueServer}/debug/check_config";
+  final static String creds = "username=admin&password=admin";
+  final static List<String> checkApps = [ "about", "beeswax", "filebrowser", "help", "jobbrowser", "jobsub", "useradmin" ];
+
+  Shell sh = new Shell();
+
+  public boolean config() {
+    Shell shRoot = new Shell("/bin/bash", "root");
+    return 0 == shRoot.exec("sed -ie 's#^secret_key=#secret_key=1234567890#' /etc/hue/hue.ini").getRet();
+  }
+
+  public void createState() {
+    // first call creates admin/admin username/keypair
+    sh.exec("curl --data '${creds}' ${loginURL}");
+  }
+
+  public boolean verifyState() {
+    String sessionId;
+    boolean res;
+
+    sh.exec("curl -i --data '${creds}' ${loginURL} | sed -e 's#Set-Cookie: *##' -e 's#;.*\$##' | grep '^sessionid'");
+    sessionId = sh.getOut().join('');
+
+    res = (sh.exec("curl -b '${sessionId}' ${checkURL} | grep -q 'All ok. Configuration check passed'").getRet() == 0);
+    checkApps.each {
+      res = res && (sh.exec("curl -b '${sessionId}' ${hueServer}/${it}/ | grep -q 'Page Not Found'").getRet() != 0);
+    }
+    return res;
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierMapreduce.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierMapreduce.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierMapreduce.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierMapreduce.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import java.security.MessageDigest
+
+class StateVerifierMapreduce extends StateVerifier {
+  static Shell sh = new Shell();
+
+  public static void createStaticState() {
+    verifyStaticState();
+  }
+
+  public static boolean verifyStaticState() {
+    return sh.exec("hadoop jar `ls /usr/lib/hadoop-0.20/hadoop*examples*jar | head -1` pi 10 100").getRet() == 0;
+  }
+
+  void createState() {
+    createStaticState()
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierOozie.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierOozie.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierOozie.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierOozie.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import java.security.MessageDigest
+import org.junit.Test
+
+class StateVerifierOozie extends StateVerifier {
+  static Shell sh = new Shell();
+  final static String workflow = """<workflow-app xmlns="uri:oozie:workflow:0.1" name="no-op-wf">
+                                       <start to="end"/>
+                                       <end name="end"/>
+                                     </workflow-app>""";
+
+  public static void createStaticState() {
+    verifyStaticState();
+  }
+
+  public static boolean verifyStaticState() {
+    String jobID;
+    sh.exec("hadoop fs -put <(echo '$workflow') /oozie.xml");
+    sh.exec("oozie job -oozie http://localhost:11000/oozie -run -Doozie.wf.application.path=hdfs://localhost/oozie.xml");
+    jobID = sh.getOut().get(0).replaceAll(/job: /, '');
+
+    sleep(5001);
+
+    return (sh.exec("oozie job -oozie http://localhost:11000/oozie -info $jobID | grep -q 'Status *: SUCCEEDED'")
+              .getRet() == 0);
+  }
+
+  void createState() {
+    createStaticState()
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierSqoop.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierSqoop.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierSqoop.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierSqoop.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import java.security.MessageDigest
+import org.junit.Test
+
+class StateVerifierSqoop extends StateVerifier {
+  final static String jobSpec = "-- import-all-tables --connect jdbc:mysql://example.com/db";
+  final static String remoteOpt = "--meta-connect 'jdbc:hsqldb:hsql://localhost:16000/sqoop'";
+  Shell sh = new Shell();
+
+  public void createState() {
+    sh.exec("sqoop job              --create localJob ${jobSpec}");
+    sh.exec("sqoop job ${remoteOpt} --create storeJob ${jobSpec}");
+  }
+
+  public boolean verifyState() {
+    boolean localFound = (sh.exec("sqoop job              --show localJob | grep -q '^Job: localJob'").getRet() == 0);
+    boolean storeFound = (sh.exec("sqoop job ${remoteOpt} --show storeJob | grep -q '^Job: storeJob'").getRet() == 0);
+    return (localFound && storeFound);
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierZookeeper.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierZookeeper.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierZookeeper.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/StateVerifierZookeeper.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.shell.Shell
+import java.security.MessageDigest
+
+class StateVerifierZookeeper extends StateVerifier {
+  Shell shZK = new Shell("zookeeper-client");
+
+  public void createState() {
+    shZK.exec("create /bar bar123",
+              "quit\n");
+  }
+
+  public boolean verifyState() {
+    shZK.exec("get /bar",
+              "quit\n");
+    return (shZK.getOut().join(' ') =~ /bar123.*zk:.*CONNECTED/).find();
+  }
+}
\ No newline at end of file

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributed.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributed.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributed.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributed.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.junit.OrderedParameterized
+import org.junit.runner.RunWith
+import com.cloudera.itest.junit.OrderedParameterized.RunStage
+import org.junit.Test
+
+@RunWith(OrderedParameterized.class)
+class TestPackagesPseudoDistributed extends TestPackagesSingleNode {
+  public TestPackagesPseudoDistributed(String pkgName, Node pkgGolden) {
+    super(pkgName, pkgGolden);
+  }
+
+  @RunStage(level=-3)
+  @Test
+  synchronized void testRemoteMetadata() {
+  }
+
+  @RunStage(level=1)
+  @Test
+  void testPackageRemove() {
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedState.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedState.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedState.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedState.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import org.junit.runners.Suite
+import org.junit.runner.RunWith
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses([
+  TestPackagesPseudoDistributed.class,
+  TestServices.class,
+])
+class TestPackagesPseudoDistributedState {
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedUpgrade.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedUpgrade.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedUpgrade.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesPseudoDistributedUpgrade.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import org.junit.runners.Suite
+import org.junit.runner.RunWith
+
+@RunWith(Suite.class)
+
+@Suite.SuiteClasses([
+  DeployCDH.class,
+  TestServicesCreateState.class,
+  TestPackagesPseudoDistributed.class,
+  TestServicesCreateStateMissing.class,
+  TestServicesVerifyState.class,
+])
+class TestPackagesPseudoDistributedUpgrade {
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesReadiness.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesReadiness.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesReadiness.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesReadiness.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import com.cloudera.itest.junit.OrderedParameterized
+import org.junit.runner.RunWith
+import com.cloudera.itest.junit.OrderedParameterized.RunStage
+import org.junit.Test
+
+@RunWith(OrderedParameterized.class)
+class TestPackagesReadiness extends TestPackagesSingleNode {
+  public TestPackagesReadiness(String pkgName, Node pkgGolden) {
+    super(pkgName, pkgGolden);
+  }
+  
+  @RunStage(level=-1)
+  @Test
+  void testPackageUpgrade() {
+  }
+
+  @Test
+  void testRepoFile() {
+  }
+
+  @Test
+  void testPulledDeps() {
+  }
+
+  @Test
+  void testPackageMetadata() {
+  }
+
+  @Test
+  void testPackageContent() {
+  }
+
+  @Test
+  void testPackageServices() {
+  }
+
+  @Test
+  void testUsers() {
+  }
+
+  @Test
+  void testGroups() {
+  }
+
+  @Test
+  void testAlternatives() {
+  }
+
+  @RunStage(level=1)
+  @Test
+  void testPackageRemove() {
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesSingleNode.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesSingleNode.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesSingleNode.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestPackagesSingleNode.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,259 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.cloudera.itest.packagesmoke
+
+import org.junit.BeforeClass
+import org.junit.Test
+import org.junit.rules.ErrorCollector
+import org.junit.Rule
+import static org.junit.Assert.assertTrue
+import static org.hamcrest.CoreMatchers.equalTo
+import org.junit.runner.RunWith
+import org.junit.runners.Parameterized.Parameters
+import org.junit.AfterClass
+
+import com.cloudera.itest.pmanager.PackageInstance
+import com.cloudera.itest.junit.OrderedParameterized
+import com.cloudera.itest.junit.OrderedParameterized.RunStage
+
+import static com.cloudera.itest.shell.OS.linux_flavor
+import com.cloudera.itest.shell.Shell
+
+@RunWith(OrderedParameterized.class)
+class TestPackagesSingleNode extends PackageTestCommon {
+  private static PackageTestRepoMgr repo;
+  // Ideally, we would want to have PackageInstance implementation be efficient in how it manages different
+  // objects representing the same package. That would allow us to have PackageInstance per testcase and
+  // not worry about managing it ourselves via the following static Map. For now, however, we rely on
+  // constructors being synchronized and thus inserting just one copy of PackageInstance for each package we test
+  private static Map<String, PackageInstance> pkgs = [:];
+  private static String selectedTests = System.getProperty("cdh.packages.test", ".");
+  private static String skippedTests = System.getProperty("cdh.packages.skip", "\$^");
+
+  private Node golden;
+
+  static {
+    // repo = new PackageTestRepoMgr("3", "", "http://nightly.cloudera.com/debian/",
+    //                                       "http://nightly.cloudera.com/debian/archive.key");
+    repo = new PackageTestRepoMgr();
+    TestPackagesSingleNode.pm = repo.getPm();
+  }
+
+  @Rule
+  public ErrorCollector errors = new ErrorCollector();
+
+  @BeforeClass
+  public static void setUp() {
+    tryOrFail({repo.addRepo()}, 2, "adding repository failed");
+    tryOrFail({(repo.getPm().refresh() == 0)}, 1, "refreshing repository failed");
+  }
+
+  @AfterClass
+  public static void tearDown() {
+    repo.removeRepo();
+  }
+
+  @Parameters
+  public static Map<String, Object[]> generateTests() {
+    String type = TestPackagesSingleNode.pm.getType();
+    String arch = (new Shell()).exec("uname -m").getOut().get(0).replaceAll(/i.86/,"i386").replaceAll(/x86_64/,"amd64");
+    String archTranslated = (type == "apt") ? "" : ((arch == "amd64") ? ".x86_64" : ".${arch}");
+    def config = new XmlParser().parse(TestPackagesSingleNode.class.getClassLoader().
+                                       getResourceAsStream("package_data_${type}.xml"));
+
+    Map<String, Object[]> res = [:];
+
+    config.children().each {
+      String name = it.name();
+
+      if ((name =~ /\.(amd64|i386)$/).find()) {
+        name = (name =~ "${arch}\$").find() ? name.replaceAll("\\.${arch}\$", archTranslated) : null;
+
+        // TODO: this is a total hack
+        if ((name =~ /\.i386$/).find() && linux_flavor == "RedHatEnterpriseServer") {
+          name = null;
+        }
+      }
+
+      if (name != null && (name =~ selectedTests).find() && !(name =~ skippedTests).find()) {
+        res[name] = ([name, it] as Object[]);
+      }
+    };
+
+    return res;
+  }
+
+  public TestPackagesSingleNode(String pkgName, Node pkgGolden) {
+    result = errors;
+    name = pkgName;
+    golden = pkgGolden;
+    // hopefully the following line will go away soon, once PackageInstance becomes more sophisticated
+    synchronized (pkgs) { pkgs[name] = pkgs[name] ?: PackageInstance.getPackageInstance(pm, name); }
+    pkg = pkgs[name];
+  }
+
+  @RunStage(level=-3)
+  @Test
+  synchronized void testRemoteMetadata() { 
+    if (!isUpgrade()) {
+      if (pkg.isInstalled()) {
+        checkThat("package $name is alredy installed and could not be removed",
+                  pkg.remove(), equalTo(0));
+      }
+
+      checkRemoteMetadata(getMap(golden.metadata), false);
+    }
+  }
+
+  @RunStage(level=-2)
+  @Test
+  synchronized void testPackageInstall() {
+    // WARNING: sometimes packages do not install because the server is busy
+    int i;
+    for (i=3; pkg.install() && i>0; i--);
+    checkThat("could only install package $name on the ${3-i} try",
+              i, equalTo(3));
+
+    // TODO: we need to come up with a way to abort any further execution to avoid spurious failures
+
+    checkThat("package $name is expected to be installed",
+              pm.isInstalled(pkg), equalTo(true));
+
+    pkg.refresh();
+  }
+
+  @RunStage(level=-1)
+  @Test
+  void testPackageUpgrade() {
+    if (isUpgrade()) {
+      checkThat("upgrade sequence on a package $name failed to be executed",
+                CDHUpgradeSequence.execute(name, System.getProperty("cdh.prev.repo.version"), "3"), equalTo(0));
+    }
+  }
+
+  @Test
+  void testRepoFile() {
+    // TODO: not sure what level of textual comparison of repo files do we actually need to implement
+  }
+
+  @Test
+  void testPulledDeps() {
+    checkPulledDeps(getMap(golden.deps));
+  }
+
+  @Test
+  void testPackageMetadata() {
+    checkMetadata(getMap(golden.metadata));
+  }
+
+  @Test
+  void testPackageContent() {
+    Map files = getMap(golden.content);
+    checkFiles(files.config, files.doc, files.file);
+  }
+
+  @Test
+  void testPackageServices() {
+    checkServices(getMap(golden.services));
+  }
+
+  @Test
+  void testUsers() {
+    checkUsers(getMap(golden.users));
+  }
+
+  @Test
+  void testGroups() {
+    checkGroups(getMap(golden.groups));
+  }
+
+  @Test
+  void testAlternatives() {
+    checkAlternatives(getMap(golden.alternatives));
+  }
+
+  @RunStage(level=1)
+  @Test
+  void testPackageRemove() {
+    checkRemoval();
+  }
+
+  static void tryOrFail(Closure cl, int retries, String fail) {
+    while (!cl.call()) {
+      retries--;
+      assertTrue(fail, retries > 0);
+      sleep(3001);
+    }
+  }
+
+  Map getMap(NodeList nodeList) {
+    switch (nodeList.size()) {
+      case 0: return [:];
+      case 1: return getMapN(nodeList.get(0));
+      default: return null;  // poor man's XML validation
+    }
+  }
+
+  Map getMapN(Node node) {
+    String packagerType = pm.getType();
+    Map res = [:];
+                                 node.attributes()
+    node.children().each {
+      String key = it.name().toString();
+      if (key == "tag" && it.attributes()["name"] != null) { // <tag name="foo"/> -> <foo/>
+        key = it.attributes()["name"];
+      }
+      def value = null;
+      if (it.children().size() == 0) {  // empty tags <foo/>
+        Map attr = it.attributes();
+        value = (attr.size() > 0) ? attr : key;
+      } else if (it.children().size() == 1 && it.children().get(0) instanceof java.lang.String) { // text tags <foo>bar</foo>
+        value = it.text();
+      } else if (["apt", "yum", "zypper"].contains(key)) { // poor man's XML filtering
+        res.putAll((packagerType == key) ? getMapN(it) : [:]);
+      } else {
+        value = getMapN(it);
+      }
+
+      // this is a little bit more tricky than it has to be :-(
+      if (value != null) {
+        // turn tags with a property name into a tag of its own <tag name="foo"> -> <tag><foo name="foo"</foo></tag>
+        if (value instanceof Map && value.name != null) {
+          Map tmpMap = [:];
+          tmpMap.put(value.name, value);
+          value = tmpMap;
+        }
+        if (res[key] == null) {
+          res[key] = value;
+        } else {
+          if (res[key] instanceof Map && value instanceof Map) {
+            res[key].putAll(value);
+          } else {
+          if (!(res[key] instanceof List)) {
+            res[key] = [res[key]];
+          }
+          res[key].add(value);
+          }
+        }
+      }
+    }
+
+    return res;
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServices.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServices.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServices.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServices.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,105 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import org.junit.Test
+import org.junit.runner.RunWith
+import com.cloudera.itest.junit.OrderedParameterized
+import org.junit.Rule
+import org.junit.rules.ErrorCollector
+import org.junit.runners.Parameterized.Parameters
+import org.junit.AfterClass
+import com.cloudera.itest.posix.Service
+import com.cloudera.itest.junit.OrderedParameterized.RunStage
+import org.hamcrest.Matcher
+import static org.hamcrest.core.IsEqual.equalTo
+
+@RunWith(OrderedParameterized.class)
+class TestServices {
+  Map.Entry svcDescr;
+  List<Service> svcs;
+  StateVerifier verifier;
+
+  @Rule
+  public ErrorCollector errors = new ErrorCollector();
+
+  @Parameters
+  static Map<String, Object[]> generateTests() {
+    // Look for how it gets reset by CreateServiceState class to understand
+    // why it works in the upgrade scenario case
+    return selectServices(System.getProperty("cdh.repo.version", "3"));
+  }
+
+  TestServices(Map.Entry svc) {
+    svcDescr = svc;
+    svcs = svcDescr.value.services.collect { new Service(it); };
+    verifier = svcDescr.value.verifier;
+  }
+
+  static Map<String, Object[]> selectServices(String CDHrelease) {
+    Map<String, Object[]> res = [:];
+    CDHServices.getServices(CDHrelease).each {
+      String name = it.key.toString();
+      res[name] = ([it] as Object[]);
+    }
+    return res;
+  }
+
+  @RunStage(level=-1)
+  @Test
+  void createState() {
+    svcs.each {
+      checkThat("failed to configure service ${it.getName()}",
+                verifier.config(), equalTo(true));
+    }
+
+    svcs.each {
+      checkThat("service ${it.getName()} failed to start",
+                it.start(), equalTo(0));
+    }
+
+    sleep(60001);
+    verifier.createState();
+    checkThat("initial state verification failed",
+              verifier.verifyState(), equalTo(true));
+
+    svcs.reverseEach {
+      checkThat("service ${it.getName()} failed to stop",
+                it.stop(), equalTo(0));
+    }
+    sleep(5001);
+  }
+
+  @RunStage(level=1)
+  @Test
+  void verifyState() {
+    svcs.each {
+      checkThat("service ${it.getName()} failed to start",
+                it.start(), equalTo(0));
+    }
+    sleep(60001);
+    checkThat("state verification failed after daemons got restarted",
+              verifier.verifyState(), equalTo(true));
+
+    svcs.reverseEach { it.stop(); }
+  }
+
+  public void checkThat(String msg, Object value, Matcher<Object> matcher) {
+    PackageTestErrorProxy.checkThat(errors, msg, value, matcher);
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateState.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateState.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateState.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateState.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import org.junit.Test
+import com.cloudera.itest.junit.OrderedParameterized.RunStage
+import org.junit.runners.Parameterized.Parameters
+
+class TestServicesCreateState extends TestServices {
+  @Parameters
+  static Map<String, Object[]> generateTests() {
+    return selectServices(System.getProperty("cdh.prev.repo.version",
+                                      System.getProperty("cdh.repo.version", "3")));
+  }
+
+  TestServicesCreateState(Map.Entry ent) {
+    super(ent);
+  }
+
+  @RunStage(level=1)
+  @Test
+  void verifyState() {
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateStateMissing.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateStateMissing.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateStateMissing.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesCreateStateMissing.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import org.junit.runners.Parameterized.Parameters
+
+class TestServicesCreateStateMissing extends TestServicesCreateState {
+  @Parameters
+  static Map<String, Object[]> generateTests() {
+    return selectServices("${System.getProperty('cdh.prev.repo.version','3')}..${System.getProperty('cdh.repo.version', '3')}");
+  }
+
+  TestServicesCreateStateMissing(Map.Entry ent) {
+    super(ent);
+  }
+}

Added: incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesVerifyState.groovy
URL: http://svn.apache.org/viewvc/incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesVerifyState.groovy?rev=1148501&view=auto
==============================================================================
--- incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesVerifyState.groovy (added)
+++ incubator/bigtop/trunk/test/src/smokes/package/src/test/groovy/com/cloudera/itest/packagesmoke/TestServicesVerifyState.groovy Tue Jul 19 19:44:48 2011
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.cloudera.itest.packagesmoke
+
+import org.junit.Test
+import com.cloudera.itest.junit.OrderedParameterized.RunStage
+import org.junit.runners.Parameterized.Parameters
+
+class TestServicesVerifyState extends TestServices {
+  TestServicesVerifyState(Map.Entry ent) {
+    super(ent);
+  }
+
+  @RunStage(level=-1)
+  @Test
+  void createState() {
+  }
+}
\ No newline at end of file



Mime
View raw message