You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by nc...@apache.org on 2016/01/11 15:38:02 UTC

ambari git commit: AMBARI-14573. Create Repository Version file and parser (ncole)

Repository: ambari
Updated Branches:
  refs/heads/branch-dev-patch-upgrade f662e407f -> 1c675d0a7


AMBARI-14573. Create Repository Version file and parser (ncole)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1c675d0a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1c675d0a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1c675d0a

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 1c675d0a7d1107da206a78f753e77343354038a6
Parents: f662e40
Author: Nate Cole <nc...@hortonworks.com>
Authored: Fri Jan 8 16:02:47 2016 -0500
Committer: Nate Cole <nc...@hortonworks.com>
Committed: Mon Jan 11 09:33:57 2016 -0500

----------------------------------------------------------------------
 .../ambari/server/state/RepositoryType.java     |   9 +-
 .../repository/AvailableServiceReference.java   |  44 +++++
 .../state/repository/ManifestService.java       |  51 +++++
 .../ambari/server/state/repository/Release.java |  70 +++++++
 .../state/repository/VersionDefinitionXml.java  | 135 ++++++++++++++
 .../src/main/resources/version_definition.xsd   | 185 +++++++++++++++++++
 ...ClusterStackVersionResourceProviderTest.java |   3 -
 .../RepositoryVersionResourceProviderTest.java  |  43 -----
 .../state/repository/VersionDefinitionTest.java |  83 +++++++++
 .../test/resources/version_definition_test.xml  |  77 ++++++++
 10 files changed, 653 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java b/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
index 4cc79e5..f79d828 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/RepositoryType.java
@@ -32,6 +32,13 @@ public enum RepositoryType {
    * Repository may have only minimum components and is used for patching
    * purposes
    */
-  PATCH
+  PATCH,
+
+  /**
+   * Repository is used to update services
+   */
+  SERVICE
+
+
 
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/AvailableServiceReference.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/AvailableServiceReference.java b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/AvailableServiceReference.java
new file mode 100644
index 0000000..35b6cea
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/AvailableServiceReference.java
@@ -0,0 +1,44 @@
+/**
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.ambari.server.state.repository;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * An available service can be upgraded.  This is mostly a marker class identifying the
+ * {@link ManifestService} with a set of optional components to upgrade.
+ */
+public class AvailableServiceReference {
+
+  /**
+   * The reference id back to the service in the repository.
+   */
+  @XmlAttribute(name="idref")
+  public String serviceIdReference;
+
+  /**
+   * Set of components to update.
+   */
+  @XmlElement(name="component")
+  public Set<String> components = new HashSet<>();
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ManifestService.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ManifestService.java b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ManifestService.java
new file mode 100644
index 0000000..0097110
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/ManifestService.java
@@ -0,0 +1,51 @@
+/**
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.ambari.server.state.repository;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * Represents a service definition in the manifest.  The service manifest is a list
+ * of all services available in a repository.
+ */
+public class ManifestService {
+
+  /**
+   * The unique id for the service and version.
+   */
+  @XmlAttribute(name="id")
+  public String serviceId;
+
+  /**
+   * Name of the service.
+   */
+  @XmlAttribute(name="name")
+  public String serviceName;
+
+  /**
+   * Version of the service.  This is the publicly available version.
+   */
+  @XmlAttribute(name="version")
+  public String version;
+
+  /**
+   * Version id of the service.  This may be a build number.
+   */
+  @XmlAttribute(name="version-id")
+  public String versionId;
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
new file mode 100644
index 0000000..450fd95
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/Release.java
@@ -0,0 +1,70 @@
+/**
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.ambari.server.state.repository;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.apache.ambari.server.state.RepositoryType;
+
+/**
+ * Release information for a repository.
+ */
+@XmlRootElement(name="release")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class Release {
+
+  /**
+   * The type of repository dictates how the repo should be installed and its upgradability.
+   */
+  @XmlElement(name="type")
+  public RepositoryType repositoryType;
+
+  /**
+   * The stack id for the repository.
+   */
+  @XmlElement(name="stack-id")
+  public String stackId;
+
+  /**
+   * The stack version.
+   */
+  @XmlElement(name="version")
+  public String version;
+
+  /**
+   * The build identifier.
+   */
+  @XmlElement(name="build")
+  public String build;
+
+  /**
+   * The compatability regex.  This is used to relate the release to another release.
+   */
+  @XmlElement(name="compatible-with")
+  public String compatibleWith;
+
+  /**
+   * The release notes or link.
+   */
+  @XmlElement(name="release-notes")
+  public String releaseNotes;
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
new file mode 100644
index 0000000..92ab6b3
--- /dev/null
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/repository/VersionDefinitionXml.java
@@ -0,0 +1,135 @@
+/**
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.ambari.server.state.repository;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.ambari.server.state.stack.RepositoryXml;
+import org.apache.commons.io.IOUtils;
+
+/**
+ * Class that wraps a repository definition file.
+ */
+@XmlRootElement(name="repository-version")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class VersionDefinitionXml {
+
+  /**
+   * Release details.
+   */
+  @XmlElement(name = "release")
+  public Release release;
+
+  /**
+   * The manifest of ALL services available in this repository.
+   */
+  @XmlElementWrapper(name="manifest")
+  @XmlElement(name="service")
+  public List<ManifestService> manifestServices = new ArrayList<>();
+
+  /**
+   * For PATCH and SERVICE repositories, this dictates what is available for upgrade
+   * from the manifest.
+   */
+  @XmlElementWrapper(name="available-services")
+  @XmlElement(name="service")
+  public List<AvailableServiceReference> availableServices = new ArrayList<>();
+
+  /**
+   * Represents the repository details.  This is reused from stack repo info.
+   */
+  @XmlElement(name="repository-info")
+  public RepositoryXml repositoryInfo;
+
+  /**
+   * Parses a URL for a definition XML file into the object graph.
+   * @param   url the URL to load.  Can be a file URL reference also.
+   * @return  the definition
+   */
+  public static VersionDefinitionXml load(URL url) throws Exception {
+
+    InputStream stream = null;
+    try {
+      stream = url.openStream();
+      return load(stream);
+    } finally {
+      IOUtils.closeQuietly(stream);
+    }
+  }
+
+  /**
+   * Parses an xml string.  Used when the xml is in the database.
+   * @param   xml the xml string
+   * @return  the definition
+   */
+  public static VersionDefinitionXml load(String xml) throws Exception {
+    return load(new ByteArrayInputStream(xml.getBytes("UTF-8")));
+  }
+
+  /**
+   * Parses a stream into an object graph
+   * @param stream  the stream
+   * @return the definition
+   * @throws Exception
+   */
+  private static VersionDefinitionXml load(InputStream stream) throws Exception {
+
+    XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
+    XMLStreamReader xmlReader = xmlFactory.createXMLStreamReader(stream);
+
+    xmlReader.nextTag();
+    String xsdName = xmlReader.getAttributeValue(XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI, "noNamespaceSchemaLocation");
+
+    JAXBContext ctx = JAXBContext.newInstance(VersionDefinitionXml.class);
+    Unmarshaller unmarshaller = ctx.createUnmarshaller();
+
+    if (null != xsdName) {
+      InputStream xsdStream = VersionDefinitionXml.class.getClassLoader().getResourceAsStream(xsdName);
+
+      if (null == xsdStream) {
+        throw new Exception(String.format("Could not load XSD identified by '%s'", xsdName));
+      }
+
+      SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+      Schema schema = factory.newSchema(new StreamSource(xsdStream));
+      unmarshaller.setSchema(schema);
+    }
+
+    return (VersionDefinitionXml) unmarshaller.unmarshal(xmlReader);
+  }
+
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/main/resources/version_definition.xsd
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/version_definition.xsd b/ambari-server/src/main/resources/version_definition.xsd
new file mode 100644
index 0000000..654ea08
--- /dev/null
+++ b/ambari-server/src/main/resources/version_definition.xsd
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   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.
+-->
+
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:annotation>
+    <xs:documentation>
+    This XSD is used to validate a repo definition file.  You can verify the XML is valid
+    by running (on Linux):
+    xmllint --noout --load-trace --schema [path-to-this-file] [path-to-xml]
+    </xs:documentation>
+  </xs:annotation>
+  
+  <xs:complexType name="release-type">
+    <xs:all>
+     <xs:element name="type" type="repo-type" />
+     <xs:element name="stack-id" type="xs:string" />
+     <xs:element name="version" type="xs:string" />
+     <xs:element name="build" type="xs:string" />
+     <xs:element name="compatible-with" type="xs:string" minOccurs="0" maxOccurs="1" />
+     <xs:element name="release-notes" type="xs:string" maxOccurs="1" />
+    </xs:all>
+  </xs:complexType>
+  
+  <xs:simpleType name="repo-type">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="STANDARD" />
+      <xs:enumeration value="SERVICE" />
+      <xs:enumeration value="PATCH" />
+    </xs:restriction>
+  </xs:simpleType>
+  
+  <xs:simpleType name="family-type">
+    <xs:restriction base="xs:string">
+      <xs:enumeration value="redhat6" />
+      <xs:enumeration value="redhat7" />
+      <xs:enumeration value="debian7" />
+      <xs:enumeration value="ubuntu12" />
+      <xs:enumeration value="ubuntu14" />
+      <xs:enumeration value="suse11" />
+    </xs:restriction>
+  </xs:simpleType>
+  
+  <xs:complexType name="manifest-service-type">
+    <xs:annotation>
+      <xs:documentation>
+      The manifest element describes what services are included in the repository.  This
+      is an exhaustive list and is NOT representative of what a cluster is allowed to
+      use for upgrading.
+      </xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="service" minOccurs="1" maxOccurs="unbounded">
+        <xs:annotation>
+          <xs:documentation>
+          A service includes both the name and version represented in the repository.
+          An ID is also required as a reference elsewhere in the document.
+          </xs:documentation>
+        </xs:annotation>
+        <xs:complexType>
+          <xs:attribute name="name" type="xs:string" use="required" />
+          <xs:attribute name="version" type="xs:string" use="required" />
+          <xs:attribute name="id" type="xs:string" use="required" />
+          <xs:attribute name="version-id" type="xs:string" />
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  
+  <xs:complexType name="available-services-type">
+    <xs:annotation>
+      <xs:documentation>
+      Provides a list of services that are available to upgrade out of this repository.
+      A service may include a list of components that can be upgraded.  These are specified
+      (generally) for patch upgrades only.
+      
+      A service must have an 'idref' attribute to tie it back to a service and version from
+      the 'manifest' element. 
+      </xs:documentation>
+    </xs:annotation>
+    <xs:sequence>
+      <xs:element name="service" maxOccurs="unbounded">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="component" minOccurs="0" maxOccurs="unbounded" />
+          </xs:sequence>
+          <xs:attribute name="idref" use="required" type="xs:string" />
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  
+  <xs:complexType name="repository-info-type">
+    <xs:sequence>
+      <xs:element name="os" maxOccurs="unbounded">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="repo" maxOccurs="unbounded">
+              <xs:complexType>
+                <xs:sequence>
+                  <xs:element name="baseurl" type="xs:string" />
+                  <xs:element name="repoid" type="xs:string" />
+                  <xs:element name="reponame" type="xs:string" />
+                </xs:sequence>
+              </xs:complexType>
+            </xs:element>
+          </xs:sequence>
+          <xs:attribute name="family" type="family-type" use="required" />
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  
+  <xs:complexType name="upgrade-type">
+    <xs:sequence>
+      <xs:element name="configuration" maxOccurs="unbounded">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element name="set" maxOccurs="unbounded">
+              <xs:complexType>
+                <xs:attribute name="key" use="required" />
+                <xs:attribute name="value" use="required" />
+              </xs:complexType>
+            </xs:element>
+          </xs:sequence>
+          <xs:attribute name="type" use="required" />
+        </xs:complexType>
+      </xs:element>
+    </xs:sequence>
+  </xs:complexType>
+  
+  <xs:element name="repository-version">
+    <xs:annotation>
+      <xs:documentation>
+        This is the root element for the xml file.
+      </xs:documentation>
+    </xs:annotation>
+    <xs:complexType>
+      <xs:sequence>
+        <xs:element name="release" type="release-type" />
+        <xs:element name="manifest" type="manifest-service-type" />
+        <xs:element name="available-services" type="available-services-type" />
+        <xs:element name="repository-info" type="repository-info-type"/>
+        <xs:element name="upgrade" minOccurs="0" type="upgrade-type" />
+      </xs:sequence>
+    </xs:complexType>
+
+    <xs:key name="service-id-key">
+      <xs:annotation>
+        <xs:documentation>
+        This key is used to identify services used in other elements to the services
+        from the 'manifest' element.
+        </xs:documentation>
+      </xs:annotation>
+      <xs:selector xpath="./manifest/service" />
+      <xs:field xpath="@id" />
+    </xs:key>
+    
+    <xs:keyref name="available-services-id-keyref" refer="service-id-key">
+      <xs:annotation>
+        <xs:documentation>
+        The key reference for 'available-services' to the 'manifest' service.
+        </xs:documentation>
+      </xs:annotation>
+      <xs:selector xpath="./available-services/service" />
+      <xs:field xpath="@idref" />
+    </xs:keyref>
+
+  </xs:element>
+  
+</xs:schema>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
index 5f8c25d..5c21433 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/ClusterStackVersionResourceProviderTest.java
@@ -62,7 +62,6 @@ import org.apache.ambari.server.orm.GuiceJpaInitializer;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
 import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
-import org.apache.ambari.server.orm.dao.HostDAO;
 import org.apache.ambari.server.orm.dao.HostVersionDAO;
 import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
 import org.apache.ambari.server.orm.dao.ResourceTypeDAO;
@@ -165,8 +164,6 @@ public class ClusterStackVersionResourceProviderTest {
     ambariMetaInfo = injector.getInstance(AmbariMetaInfo.class);
     resourceTypeDAO = injector.getInstance(ResourceTypeDAO.class);
     stackDAO = injector.getInstance(StackDAO.class);
-    clusterDAO = injector.getInstance(ClusterDAO.class);
-    hostDAO = injector.getInstance(HostDAO.class);
   }
 
   @After

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
index 611c186..17e983e 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/internal/RepositoryVersionResourceProviderTest.java
@@ -19,8 +19,6 @@
 package org.apache.ambari.server.controller.internal;
 
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
@@ -34,7 +32,6 @@ import org.apache.ambari.server.controller.ResourceProviderFactory;
 import org.apache.ambari.server.controller.predicate.AndPredicate;
 import org.apache.ambari.server.controller.spi.Predicate;
 import org.apache.ambari.server.controller.spi.Request;
-import org.apache.ambari.server.controller.spi.Resource;
 import org.apache.ambari.server.controller.spi.ResourceProvider;
 import org.apache.ambari.server.controller.utilities.PredicateBuilder;
 import org.apache.ambari.server.controller.utilities.PropertyHelper;
@@ -54,7 +51,6 @@ import org.apache.ambari.server.security.authorization.AuthorizationException;
 import org.apache.ambari.server.state.Clusters;
 import org.apache.ambari.server.state.OperatingSystemInfo;
 import org.apache.ambari.server.state.RepositoryInfo;
-import org.apache.ambari.server.state.RepositoryType;
 import org.apache.ambari.server.state.RepositoryVersionState;
 import org.apache.ambari.server.state.StackId;
 import org.apache.ambari.server.state.StackInfo;
@@ -526,45 +522,6 @@ public class RepositoryVersionResourceProviderTest {
     Assert.assertEquals(false, RepositoryVersionEntity.isVersionInStack(sid2, "2.1"));
   }
 
-  @Test
-  public void testCreateResourcesWithComponents() throws Exception {
-    final ResourceProvider provider = injector.getInstance(ResourceProviderFactory.class).getRepositoryVersionResourceProvider();
-
-    final Set<Map<String, Object>> propertySet = new LinkedHashSet<Map<String, Object>>();
-    final Map<String, Object> properties = new LinkedHashMap<String, Object>();
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_DISPLAY_NAME_PROPERTY_ID, "name");
-    properties.put(RepositoryVersionResourceProvider.SUBRESOURCE_OPERATING_SYSTEMS_PROPERTY_ID, new Gson().fromJson("[{\"OperatingSystems/os_type\":\"redhat6\",\"repositories\":[{\"Repositories/repo_id\":\"1\",\"Repositories/repo_name\":\"1\",\"Repositories/base_url\":\"1\"}]}]", Object.class));
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID, "HDP");
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_UPGRADE_PACK_PROPERTY_ID, "pack1");
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID, "1.1");
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_REPOSITORY_VERSION_PROPERTY_ID, "1.1.1.1");
-    properties.put(RepositoryVersionResourceProvider.REPOSITORY_VERSION_COMPONENTS + "/HDFS", Arrays.asList("NAMENODE", "DATANODE"));
-    propertySet.add(properties);
-
-    final Predicate predicateStackName = new PredicateBuilder().property(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_NAME_PROPERTY_ID).equals("HDP").toPredicate();
-    final Predicate predicateStackVersion = new PredicateBuilder().property(RepositoryVersionResourceProvider.REPOSITORY_VERSION_STACK_VERSION_PROPERTY_ID).equals("1.1").toPredicate();
-    final Request getRequest = PropertyHelper.getReadRequest("RepositoryVersions");
-    Assert.assertEquals(0, provider.getResources(getRequest, new AndPredicate(predicateStackName, predicateStackVersion)).size());
-
-    final Request createRequest = PropertyHelper.getCreateRequest(propertySet, null);
-    provider.createResources(createRequest);
-
-    Set<Resource> resources = provider.getResources(getRequest, new AndPredicate(predicateStackName, predicateStackVersion));
-
-    Assert.assertEquals(1, resources.size());
-
-    Resource r = resources.iterator().next();
-
-    Assert.assertEquals(RepositoryType.PATCH,
-        r.getPropertyValue(RepositoryVersionResourceProvider.REPOSITORY_VERSION_TYPE_PROPERTY_ID));
-
-    Object o = r.getPropertyValue(RepositoryVersionResourceProvider.REPOSITORY_VERSION_COMPONENTS + "/HDFS");
-
-    Assert.assertTrue(Collection.class.isInstance(o));
-    Assert.assertTrue(((Collection) o).contains("NAMENODE"));
-    Assert.assertTrue(((Collection) o).contains("DATANODE"));
-  }
-
 
   @After
   public void after() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
new file mode 100644
index 0000000..9cf3aad
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/repository/VersionDefinitionTest.java
@@ -0,0 +1,83 @@
+/**
+ * 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
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 org.apache.ambari.server.state.repository;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.File;
+
+import org.apache.ambari.server.state.RepositoryType;
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+
+/**
+ * Tests for repository definitions.
+ */
+public class VersionDefinitionTest {
+
+  private static File file = new File("src/test/resources/version_definition_test.xml");
+
+  @Test
+  public void testLoadingString() throws Exception {
+    String xmlString = FileUtils.readFileToString(file);
+    VersionDefinitionXml xml = VersionDefinitionXml.load(xmlString);
+
+    validateXml(xml);
+  }
+
+  @Test
+  public void testLoadingUrl() throws Exception {
+    VersionDefinitionXml xml = VersionDefinitionXml.load(file.toURI().toURL());
+
+    validateXml(xml);
+  }
+
+  private void validateXml(VersionDefinitionXml xml) throws Exception {
+    assertNotNull(xml.release);
+    assertEquals(RepositoryType.PATCH, xml.release.repositoryType);
+    assertEquals("HDP-2.3", xml.release.stackId);
+    assertEquals("2.3.4.1", xml.release.version);
+    assertEquals("2.3.4.[1-9]", xml.release.compatibleWith);
+    assertEquals("http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.4/", xml.release.releaseNotes);
+
+    assertEquals(3, xml.manifestServices.size());
+    assertEquals("HDFS-271", xml.manifestServices.get(0).serviceId);
+    assertEquals("HDFS", xml.manifestServices.get(0).serviceName);
+    assertEquals("2.7.1", xml.manifestServices.get(0).version);
+    assertEquals("10", xml.manifestServices.get(0).versionId);
+
+    assertEquals(2, xml.availableServices.size());
+    assertEquals("HDFS-271", xml.availableServices.get(0).serviceIdReference);
+    assertEquals(0, xml.availableServices.get(0).components.size());
+
+    assertEquals("HIVE-110", xml.availableServices.get(1).serviceIdReference);
+    assertEquals(1, xml.availableServices.get(1).components.size());
+
+    assertNotNull(xml.repositoryInfo);
+    assertEquals(2, xml.repositoryInfo.getOses().size());
+
+    assertEquals("redhat6", xml.repositoryInfo.getOses().get(0).getFamily());
+    assertEquals(2, xml.repositoryInfo.getOses().get(0).getRepos().size());
+    assertEquals("http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.0.0",
+        xml.repositoryInfo.getOses().get(0).getRepos().get(0).getBaseUrl());
+    assertEquals("HDP-2.3", xml.repositoryInfo.getOses().get(0).getRepos().get(0).getRepoId());
+    assertEquals("HDP", xml.repositoryInfo.getOses().get(0).getRepos().get(0).getRepoName());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/ambari/blob/1c675d0a/ambari-server/src/test/resources/version_definition_test.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/resources/version_definition_test.xml b/ambari-server/src/test/resources/version_definition_test.xml
new file mode 100644
index 0000000..fadfeea
--- /dev/null
+++ b/ambari-server/src/test/resources/version_definition_test.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0"?>
+<!--
+   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
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   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.
+-->
+
+<repository-version xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:noNamespaceSchemaLocation="version_definition.xsd">
+  
+  <release>
+    <type>PATCH</type>
+    <stack-id>HDP-2.3</stack-id>
+    <version>2.3.4.1</version>
+    <build>1234</build>
+    <compatible-with>2.3.4.[1-9]</compatible-with>
+    <release-notes>http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.4/</release-notes>
+  </release>
+  
+  <manifest>
+    <service id="HDFS-271" name="HDFS" version="2.7.1" version-id="10" />
+    <service id="HIVE-110" name="HIVE" version="1.1.0" />
+    <service id="HIVE-200" name="HIVE" version="2.0.0" />
+  </manifest>
+  
+  <available-services>
+    <service idref="HDFS-271" />
+    <service idref="HIVE-110">
+      <component>HIVE_METASTORE</component>
+    </service>
+  </available-services>
+  
+  <repository-info>
+    <os family="redhat6">
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP/centos6/2.x/updates/2.3.0.0</baseurl>
+        <repoid>HDP-2.3</repoid>
+        <reponame>HDP</reponame>
+      </repo>
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos6</baseurl>
+        <repoid>HDP-UTILS-1.1.0.20</repoid>
+        <reponame>HDP-UTILS</reponame>
+      </repo>
+    </os>
+    <os family="redhat7">
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP/centos7/2.x/updates/2.3.0.0</baseurl>
+        <repoid>HDP-2.3</repoid>
+        <reponame>HDP</reponame>
+      </repo>
+      <repo>
+        <baseurl>http://public-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/centos7</baseurl>
+        <repoid>HDP-UTILS-1.1.0.20</repoid>
+        <reponame>HDP-UTILS</reponame>
+      </repo>
+    </os>
+
+  </repository-info>
+  
+  <upgrade>
+    <configuration type="hdfs-site">
+      <set key="foo" value="bar" />
+    </configuration>
+  </upgrade>
+</repository-version>