Refactor of Deploy_Nexus 87/13487/18
authorBengt Thuree <bthuree@linuxfoundation.org>
Tue, 13 Nov 2018 11:25:56 +0000 (22:25 +1100)
committerBengt Thuree <bthuree@linuxfoundation.org>
Wed, 21 Nov 2018 04:32:15 +0000 (15:32 +1100)
Refactoring deploy_nexus as part of the lftools-deploy-refactor from
shell to python.

Issue-ID: RELENG-1379
Issue-ID: RELENG-1374
Change-Id: Ibcf732643649600fa7049d92cdf1ac1072590371
Signed-off-by: Bengt Thuree <bthuree@linuxfoundation.org>
13 files changed:
lftools/cli/deploy.py
lftools/deploy.py
releasenotes/notes/deploy_nexus-4feb8fc7e24daaf0.yaml [new file with mode: 0644]
tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml [new file with mode: 0644]
tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml.md5 [new file with mode: 0644]
tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml.sha1 [new file with mode: 0644]
tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom [new file with mode: 0644]
tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.md5 [new file with mode: 0644]
tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.sha1 [new file with mode: 0644]
tests/fixtures/deploy/m2repo/maven-metadata.xml [new file with mode: 0644]
tests/fixtures/deploy/m2repo/maven-metadata.xml.md5 [new file with mode: 0644]
tests/fixtures/deploy/m2repo/maven-metadata.xml.sha1 [new file with mode: 0644]
tests/test_deploy.py

index 4da3ac3..e9b93a4 100644 (file)
@@ -239,15 +239,13 @@ def nexus(ctx, nexus_repo_url, deploy_dir, snapshot):
 
         https://nexus.example.org/content/repositories/release
     """
-    params = ['deploy', 'nexus']
-
-    if snapshot:
-        params.extend(["-s"])
-
-    params.extend([nexus_repo_url, deploy_dir])
-
-    status = subprocess.call(params)
-    sys.exit(status)
+    log.debug("nexus_repo_url={}, deploy_dir={}, snapshot={}".format(nexus_repo_url, deploy_dir, snapshot))
+    try:
+        deploy_sys.deploy_nexus(nexus_repo_url, deploy_dir, snapshot)
+    except IOError as e:
+        deploy_sys._log_error_and_exit(str(e))
+    except HTTPError as e:
+        deploy_sys._log_error_and_exit(str(e))
 
 
 @click.command(name='nexus-stage')
index 5032ccd..59404b9 100644 (file)
@@ -13,6 +13,8 @@
 import errno
 import gzip
 import logging
+import multiprocessing
+from multiprocessing.dummy import Pool as ThreadPool
 import os
 import re
 import shutil
@@ -352,7 +354,7 @@ def nexus_stage_repo_create(nexus_url, staging_profile_id):
     Returns:             staging_repo_id
 
     Sample:
-    lftools deploy nexus-stage-repo-create 192.168.1.26:8081/nexsus/ 93fb68073c18
+    lftools deploy nexus-stage-repo-create 192.168.1.26:8081/nexus/ 93fb68073c18
     """
     nexus_url = '{0}/service/local/staging/profiles/{1}/start'.format(
         _format_url(nexus_url),
@@ -488,3 +490,48 @@ def upload_maven_file_to_nexus(nexus_url, nexus_repo_id,
     if re.search('nexus-error', resp.text):
         error_msg = _get_node_from_xml(resp.text, 'msg')
         raise requests.HTTPError("Nexus Error: {}".format(error_msg))
+
+
+def deploy_nexus(nexus_repo_url, deploy_dir, snapshot=False):
+    """Deploy Maven artifacts to Nexus.
+
+    Parameters:
+        nexus_repo_url: URL to Nexus server. (Ex: https://nexus.example.org)
+        deploy_dir:     The directory to deploy. (Ex: /tmp/m2repo)
+
+    One purpose of this is so that we can get around the problematic
+    deploy-at-end configuration with upstream Maven.
+    https://issues.apache.org/jira/browse/MDEPLOY-193
+    Sample:
+        lftools deploy nexus \
+            http://192.168.1.26:8081/nexus/content/repositories/releases \
+            tests/fixtures/deploy/zip-test-files
+    """
+    def _deploy_nexus_upload(file):
+        """Fix file path, and call _request_post_file."""
+        nexus_url_with_file = '{}/{}'.format(_format_url(nexus_repo_url), file)
+        log.debug('Uploading {} to nexus : {}'.format(file, nexus_url_with_file))
+        _request_post_file(nexus_url_with_file, file)
+
+    file_list = []
+
+    previous_dir = os.getcwd()
+    os.chdir(deploy_dir)
+    log.debug('Current dir is deploy_dir: {}'.format(deploy_dir))
+    log.info('Uploading url  : {}'.format(nexus_repo_url))
+    files = glob2.glob('**/*')
+    for file in files:
+        if os.path.isfile(file):
+            if not file.endswith("_remote.repositories") and not file.endswith("resolver-status.properties"):
+                if snapshot:
+                    file_list.append(file)
+                else:
+                    if not "maven-metadata" in file:
+                        file_list.append(file)
+    # Perform parallel upload
+    pool = ThreadPool(multiprocessing.cpu_count())
+    pool.map(_deploy_nexus_upload, file_list)
+    pool.close()
+    pool.join()
+
+    os.chdir(previous_dir)
diff --git a/releasenotes/notes/deploy_nexus-4feb8fc7e24daaf0.yaml b/releasenotes/notes/deploy_nexus-4feb8fc7e24daaf0.yaml
new file mode 100644 (file)
index 0000000..9ba34ce
--- /dev/null
@@ -0,0 +1,13 @@
+---
+features:
+  - |
+    Refactored deploy_nexus function
+    from shell/deploy to pure Python to be more portable with Windows systems.
+    Also added a number of unit tests to cover all executable branches of the
+    code.
+
+deprecations:
+  - |
+    shell/deploy script's deploy_nexus
+    function is now deprecated and will be removed in a future release.
+
diff --git a/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml b/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml
new file mode 100644 (file)
index 0000000..a7d6af7
--- /dev/null
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata modelVersion="1.1.0">
+  <groupId>org.opendaylight.odlparent</groupId>
+  <artifactId>odlparent-lite</artifactId>
+  <version>4.0.3-SNAPSHOT</version>
+  <versioning>
+    <snapshot>
+      <timestamp>20181120.113136</timestamp>
+      <buildNumber>1</buildNumber>
+    </snapshot>
+    <lastUpdated>20181120113136</lastUpdated>
+    <snapshotVersions>
+      <snapshotVersion>
+        <extension>pom</extension>
+        <value>4.0.3-20181120.113136-1</value>
+        <updated>20181120113136</updated>
+      </snapshotVersion>
+    </snapshotVersions>
+  </versioning>
+</metadata>
diff --git a/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml.md5 b/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml.md5
new file mode 100644 (file)
index 0000000..8952e38
--- /dev/null
@@ -0,0 +1 @@
+49343dad0e0b29452b785ff50ca8809b
\ No newline at end of file
diff --git a/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml.sha1 b/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/maven-metadata.xml.sha1
new file mode 100644 (file)
index 0000000..07f4224
--- /dev/null
@@ -0,0 +1 @@
+90e26664185217e1fb1cd84b5a88626b01b452c4
\ No newline at end of file
diff --git a/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom b/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom
new file mode 100644 (file)
index 0000000..ae2014b
--- /dev/null
@@ -0,0 +1,542 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=2 tabstop=2: -->
+<!--
+ Copyright (c) 2015 The Linux Foundation and others.  All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <!--
+      Note: This parent is not meant to be used by code artifacts. Please use
+            odlparent instead.
+  -->
+
+  <groupId>org.opendaylight.odlparent</groupId>
+  <artifactId>odlparent-lite</artifactId>
+  <version>4.0.3-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <name>ODL :: odlparent :: ${project.artifactId}</name>
+
+  <!-- Sufficient Metadata for Maven Central Repository deployment
+       These are default, some of which project inheriting from this POM may override (but don't have to, typically)
+       see http://central.sonatype.org/pages/requirements.html
+   -->
+  <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+  <description>OpenDaylight is leading the transformation to Open Software Defined Networking (SDN). For more information, please see https://www.opendaylight.org</description>
+
+  <licenses>
+    <license>
+      <name>Eclipse Public License v1.0</name>
+      <url>https://www.eclipse.org/legal/epl-v10.html</url>
+    </license>
+  </licenses>
+
+  <organization>
+    <name>OpenDaylight</name>
+    <url>https://www.opendaylight.org</url>
+  </organization>
+
+  <issueManagement>
+    <system>JIRA</system>
+    <url>https://jira.opendaylight.org/</url>
+  </issueManagement>
+
+  <ciManagement>
+    <system>Jenkins</system>
+    <url>https://jenkins.opendaylight.org/releng/</url>
+  </ciManagement>
+
+  <scm>
+    <url>https://git.opendaylight.org/gerrit/</url>
+  </scm>
+
+  <developers>
+    <developer>
+      <id>*</id>
+      <name>Please consult the PROJECT_INFO.yaml, README* and/or CONTRIBUTORS which should be included with this JAR</name>
+      <url>https://www.opendaylight.org</url>
+      <email>helpdesk@opendaylight.org</email>
+    </developer>
+  </developers>
+
+  <properties>
+    <nexusproxy>https://nexus.opendaylight.org/content</nexusproxy>
+
+    <!-- Variables required for Maven Site generation -->
+    <nexus.site.url>file:${user.dir}/target/staged-site</nexus.site.url>
+    <odl.site.url>https://nexus.opendaylight.org/content/sites/site/</odl.site.url>
+    <stream>latest</stream><!-- CI should pass in -Dstream={stream} -->
+
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
+    <!-- This version property instead of just direct version in pluginManagement is the exception that confirms the rule
+         and is required so that downstream users of the archetype-packaging extension can use this (and get the same version
+         as the maven-archetype-plugin), because there is no "extensionManagement" in Maven -->
+    <maven.archetype.plugin.version>3.0.1</maven.archetype.plugin.version>
+
+    <!-- This property allows deployments to be skipped in child modules -->
+    <maven.deploy.skip>false</maven.deploy.skip>
+
+    <!-- This property allows installations to be skipped in child modules -->
+    <maven.install.skip>false</maven.install.skip>
+
+    <!-- Used in neutron, ovsdb -->
+    <jacoco.version>0.8.2</jacoco.version>
+  </properties>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <artifactId>maven-archetype-plugin</artifactId>
+          <version>${maven.archetype.plugin.version}</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-clean-plugin</artifactId>
+          <version>3.1.0</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-dependency-plugin</artifactId>
+          <version>3.1.1</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-deploy-plugin</artifactId>
+          <version>2.8.2</version>
+          <configuration>
+            <skip>${maven.deploy.skip}</skip>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-help-plugin</artifactId>
+          <version>3.1.0</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-install-plugin</artifactId>
+          <version>2.5.2</version>
+          <configuration>
+            <skip>${maven.install.skip}</skip>
+          </configuration>
+        </plugin>
+        <plugin>
+          <artifactId>maven-javadoc-plugin</artifactId>
+          <version>3.0.1</version>
+          <configuration combine.children="append">
+            <!-- Keep things quiet except for warnings/errors -->
+            <quiet>true</quiet>
+            <tags>
+              <!-- support for HelpMojo generated by the maven-plugin-plugin -->
+              <tag>
+                <name>goal</name>
+                <placement>t</placement>
+                <head>Goal:</head>
+              </tag>
+              <tag>
+                <name>requiresProject</name>
+                <placement>t</placement>
+                <head>Requires project:</head>
+              </tag>
+              <tag>
+                <name>threadSafe</name>
+                <placement>t</placement>
+                <head>Threadsafe</head>
+              </tag>
+              <tag>
+                <name>phase</name>
+                <placement>t</placement>
+                <head>Phase:</head>
+              </tag>
+              <!-- end HelpMojo support -->
+            </tags>
+            <detectLinks>false</detectLinks> <!-- TODO: It should work once https://issues.apache.org/jira/browse/MJAVADOC-427 is solved -->
+            <detectOfflineLinks>true</detectOfflineLinks>
+          </configuration>
+          <executions>
+            <execution>
+              <id>attach-javadocs</id>
+              <goals>
+                <goal>jar</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+        <plugin>
+          <artifactId>maven-project-info-reports-plugin</artifactId>
+          <version>3.0.0</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-release-plugin</artifactId>
+          <version>2.5.3</version>
+        </plugin>
+        <plugin>
+          <artifactId>maven-site-plugin</artifactId>
+          <version>3.7.1</version>
+          <configuration>
+            <asciidoc>
+              <attributes>
+                <imagesdir>./images</imagesdir>
+                <imagesoutdir>${project.build.directory}/site/images</imagesoutdir>
+                <icons>font</icons>
+                <source-highlighter>coderay</source-highlighter>
+                <coderay-css>style</coderay-css>
+              </attributes>
+              <requires>
+                <require>asciidoctor-diagram</require>
+              </requires>
+            </asciidoc>
+          </configuration>
+          <dependencies>
+            <dependency>
+              <groupId>org.asciidoctor</groupId>
+              <artifactId>asciidoctor-maven-plugin</artifactId>
+              <version>1.5.7.1</version>
+            </dependency>
+            <dependency>
+              <groupId>org.asciidoctor</groupId>
+              <artifactId>asciidoctorj-diagram</artifactId>
+              <version>1.5.10</version>
+            </dependency>
+          </dependencies>
+        </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>exec-maven-plugin</artifactId>
+          <version>1.6.0</version>
+        </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>jdepend-maven-plugin</artifactId>
+          <version>2.0</version>
+          <executions>
+            <execution>
+              <phase>site</phase>
+              <goals>
+                <goal>generate-no-fork</goal>
+              </goals>
+            </execution>
+          </executions>
+        </plugin>
+        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+        <plugin>
+          <groupId>org.eclipse.m2e</groupId>
+          <artifactId>lifecycle-mapping</artifactId>
+          <version>1.0.0</version>
+          <configuration>
+            <lifecycleMappingMetadata>
+              <pluginExecutions>
+                <pluginExecution>
+                  <pluginExecutionFilter>
+                    <groupId>pl.project13.maven</groupId>
+                    <artifactId>git-commit-id-plugin</artifactId>
+                    <versionRange>[1,)</versionRange>
+                    <goals>
+                      <goal>revision</goal>
+                    </goals>
+                  </pluginExecutionFilter>
+                  <action>
+                    <ignore></ignore>
+                  </action>
+                </pluginExecution>
+                <pluginExecution>
+                  <pluginExecutionFilter>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-dependency-plugin</artifactId>
+                    <versionRange>[2.10,)</versionRange>
+                    <goals>
+                      <goal>unpack</goal>
+                    </goals>
+                  </pluginExecutionFilter>
+                  <action>
+                    <ignore></ignore>
+                  </action>
+                </pluginExecution>
+                <pluginExecution>
+                  <pluginExecutionFilter>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-enforcer-plugin</artifactId>
+                    <versionRange>[1.0.0,)</versionRange>
+                    <goals>
+                      <goal>enforce</goal>
+                    </goals>
+                  </pluginExecutionFilter>
+                  <action>
+                    <ignore />
+                  </action>
+                </pluginExecution>
+              </pluginExecutions>
+            </lifecycleMappingMetadata>
+          </configuration>
+        </plugin>
+        <plugin>
+          <groupId>org.jacoco</groupId>
+          <artifactId>jacoco-maven-plugin</artifactId>
+          <version>${jacoco.version}</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+
+    <plugins>
+      <plugin>
+        <artifactId>maven-enforcer-plugin</artifactId>
+        <version>3.0.0-M2</version>
+        <executions>
+          <execution>
+            <id>enforce-maven</id>
+            <configuration>
+              <rules>
+                <requireJavaVersion>
+                  <version>1.8.0</version>
+                </requireJavaVersion>
+                <requireMavenVersion>
+                  <version>[3.5.0,)</version>
+                </requireMavenVersion>
+              </rules>
+            </configuration>
+            <goals>
+              <goal>enforce</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>pl.project13.maven</groupId>
+        <artifactId>git-commit-id-plugin</artifactId>
+        <version>2.2.5</version>
+        <executions>
+          <execution>
+            <id>get-git-infos</id>
+            <goals>
+              <goal>revision</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <failOnNoGitDirectory>false</failOnNoGitDirectory>
+          <generateGitPropertiesFile>true</generateGitPropertiesFile>
+          <generateGitPropertiesFilename>${project.build.outputDirectory}/META-INF/git.properties</generateGitPropertiesFilename>
+          <gitDescribe>
+            <skip>false</skip>
+            <always>true</always>
+            <tags>true</tags>
+          </gitDescribe>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>ide</id>
+      <activation>
+        <property>
+          <name>m2e.version</name>
+        </property>
+      </activation>
+      <build>
+        <!-- Put the IDE's build output in a folder other than target, so that IDE builds don't interact with Maven builds -->
+        <directory>target-ide</directory>
+      </build>
+    </profile>
+    <profile>
+        <!-- http://blog2.vorburger.ch/2016/06/improve-maven-build-speed-with-q.html
+             q = http://memory-alpha.wikia.com/wiki/Q ;)
+
+             The Quick profile is used during incremental local development, when you want to "just get that JAR built",
+             which is very handy e.g. for fast hot reloading cycles in Karaf with bundle watch.  It (intentionally!) skips
+             tests, quality checks etc. which are great and useful to run before finally submitting changes to Gerrit, and
+             which all must run on Gerrit, but which are overhead during ongoing fast iterative local development.
+
+             Note that the idea here is that your IDE will already have run quality checks such as e.g. Checkstyle
+             while you typed the code anyway.  Similarly, if you wrote a test, you'll probably already have compiled and run it
+             from your IDE, so when you want the OSGi bundle JAR for Karaf, ASAP, you typically don't want all that to run again.
+          -->
+      <id>q</id>
+      <properties>
+        <skipTests>true</skipTests>
+            <!-- But NOT <maven.test.skip>true, as that's for compiling, not running, tests;
+                 and that's usually quick.  Skipping test compilation with -Pq with maven.test.skip would be
+                 particularly confusing when used in a project with maven-jar-plugin <goal>test-jar, so don't.)  -->
+        <skipIT>true</skipIT>
+        <skipITs>true</skipITs>
+        <skip.karaf.featureTest>true</skip.karaf.featureTest>
+        <jacoco.skip>true</jacoco.skip>
+        <maven.javadoc.skip>true</maven.javadoc.skip>
+        <maven.source.skip>true</maven.source.skip>
+        <checkstyle.skip>true</checkstyle.skip>
+        <findbugs.skip>true</findbugs.skip>
+        <spotbugs.skip>true</spotbugs.skip>
+        <pmd.skip>true</pmd.skip>
+        <cpd.skip>true</cpd.skip>
+        <maven.site.skip>true</maven.site.skip>
+        <invoker.skip>true</invoker.skip>
+        <enforcer.skip>true</enforcer.skip>
+        <duplicate-finder.skip>true</duplicate-finder.skip>
+        <mdsal.skip.verbose>true</mdsal.skip.verbose> <!-- Bug 6236 -->
+        <maven.gitcommitid.skip>true</maven.gitcommitid.skip>
+        <modernizer.skip>true</modernizer.skip>
+      </properties>
+    </profile>
+    <profile>
+      <!-- http://blog2.vorburger.ch/2016/06/maven-install-into-additional.html
+           mvn [-o -Pq] install -DaddInstallRepositoryPath=.../karaf/system is used in development to directly
+           install artifacts such as bundles and KARs not just into the global shared ~/.m2/repository
+           but also into the isolated Maven repo of a Karaf distribution.
+       -->
+      <activation>
+        <property>
+          <name>addInstallRepositoryPath</name>
+        </property>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-install-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>additional-install</id>
+                <phase>install</phase>
+                <goals>
+                  <goal>install-file</goal>
+                </goals>
+                <configuration>
+                  <file>${project.build.directory}/${project.build.finalName}.jar</file>
+                  <localRepositoryPath>${addInstallRepositoryPath}</localRepositoryPath>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+    <profile>
+      <!--
+          This profile is to ensure we only build javadocs reports
+          when we plan to deploy Maven site for our project.
+
+          It activates by checking for the existance of deploy-site.xml in the
+          user's current working directory. (Intent is that this is run from
+          the Project root directory)
+      -->
+      <id>maven-site</id>
+      <activation>
+        <file>
+          <exists>${user.dir}/deploy-site.xml</exists>
+        </file>
+      </activation>
+
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-site-plugin</artifactId>
+
+            <executions>
+              <execution>
+                <id>generate-site</id>
+                <phase>install</phase>
+                <goals>
+                  <goal>site</goal>
+                  <goal>attach-descriptor</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+        </plugins>
+      </build>
+
+      <reporting>
+        <plugins>
+          <plugin>
+            <artifactId>maven-project-info-reports-plugin</artifactId>
+            <configuration>
+              <dependencyLocationsEnabled>false</dependencyLocationsEnabled>
+            </configuration>
+            <reportSets>
+              <reportSet>
+                <reports>
+                  <report>index</report>
+                </reports>
+              </reportSet>
+            </reportSets>
+          </plugin>
+          <plugin>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <reportSets>
+              <reportSet>
+                <reports>
+                  <report>javadoc-no-fork</report>
+                  <report>test-javadoc-no-fork</report>
+                </reports>
+              </reportSet>
+            </reportSets>
+          </plugin>
+        </plugins>
+      </reporting>
+    </profile>
+    <profile>
+      <!-- Javadocs with links -->
+      <id>javadoc-links</id>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <configuration combine.children="append">
+              <links>
+                <link>http://www.atetric.com/atetric/javadoc/junit/junit/4.11/</link>
+                <link>http://hamcrest.org/JavaHamcrest/javadoc/1.3/</link>
+                <link>http://google.github.io/truth/api/0.42/</link>
+                <link>https://www.slf4j.org/apidocs/</link>
+                <link>https://xerces.apache.org/xerces2-j/javadocs/api/</link>
+                <link>https://google.github.io/guava/releases/25.1-jre/api/docs/</link>
+                <link>http://doc.akka.io/japi/akka/2.5.14/</link>
+                <link>http://netty.io/4.1/api/</link>
+                <link>https://commons.apache.org/proper/commons-lang/javadocs/api-2.6/</link>
+                <link>https://commons.apache.org/proper/commons-lang/javadocs/api-3.8.1/</link>
+                <link>https://commons.apache.org/proper/commons-codec/apidocs/</link>
+              </links>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <profile>
+      <!-- On JDK9-and-later specify html4 javadoc -->
+      <id>jdk9-javadoc</id>
+      <activation>
+        <jdk>[9,)</jdk>
+      </activation>
+      <build>
+        <plugins>
+          <plugin>
+            <artifactId>maven-javadoc-plugin</artifactId>
+            <configuration combine.children="append">
+              <additionalOptions>
+                <additionalOption>-html4</additionalOption>
+              </additionalOptions>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+
+  <distributionManagement>
+    <repository>
+      <id>opendaylight-release</id>
+      <url>${nexusproxy}/repositories/opendaylight.release/</url>
+    </repository>
+    <snapshotRepository>
+      <id>opendaylight-snapshot</id>
+      <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+    </snapshotRepository>
+    <site>
+      <id>opendaylight-site</id>
+      <url>${nexus.site.url}/${project.artifactId}/</url>
+    </site>
+  </distributionManagement>
+</project>
diff --git a/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.md5 b/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.md5
new file mode 100644 (file)
index 0000000..6a8f929
--- /dev/null
@@ -0,0 +1 @@
+09be1f99c2ebd8952cdac8f9549c89ee
\ No newline at end of file
diff --git a/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.sha1 b/tests/fixtures/deploy/m2repo/4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.sha1
new file mode 100644 (file)
index 0000000..06dd2fa
--- /dev/null
@@ -0,0 +1 @@
+68e4c8d328543f76dbc14a36c73d16e51f8ee55a
\ No newline at end of file
diff --git a/tests/fixtures/deploy/m2repo/maven-metadata.xml b/tests/fixtures/deploy/m2repo/maven-metadata.xml
new file mode 100644 (file)
index 0000000..f133eaa
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+  <groupId>org.opendaylight.odlparent</groupId>
+  <artifactId>odlparent-lite</artifactId>
+  <versioning>
+    <versions>
+      <version>4.0.3-SNAPSHOT</version>
+    </versions>
+    <lastUpdated>20181120113136</lastUpdated>
+  </versioning>
+</metadata>
diff --git a/tests/fixtures/deploy/m2repo/maven-metadata.xml.md5 b/tests/fixtures/deploy/m2repo/maven-metadata.xml.md5
new file mode 100644 (file)
index 0000000..b536818
--- /dev/null
@@ -0,0 +1 @@
+b95fc576c7fdd297fcc015a9278cf287
\ No newline at end of file
diff --git a/tests/fixtures/deploy/m2repo/maven-metadata.xml.sha1 b/tests/fixtures/deploy/m2repo/maven-metadata.xml.sha1
new file mode 100644 (file)
index 0000000..05cdd4d
--- /dev/null
@@ -0,0 +1 @@
+aa3643f1cf459ad0ad17a3fa6f28c602e4511530
\ No newline at end of file
index 27b7d11..a0f2e34 100644 (file)
@@ -542,3 +542,60 @@ def test__upload_maven_file_to_nexus(responses, mocker):
     with pytest.raises(requests.HTTPError) as excinfo:
         resp = deploy_sys.upload_maven_file_to_nexus(test_url, nexus_repo_id, group_id, artifact_id, version, packaging, zip_file)
     assert 'Something went wrong' in str(excinfo.value)
+
+
+@pytest.mark.datafiles(
+    os.path.join(FIXTURE_DIR, 'deploy'),
+    )
+def test_deploy_nexus_snapshot(datafiles, responses):
+    """Test deploy_nexus with snapshot.
+
+    This test will send a directory of files to deploy_nexus, which should
+    call requests.post once for every valid (=3) file.
+    There are two files that should not be uploaded.
+    """
+    os.chdir(str(datafiles))
+    nexus_url = 'http://successfull.nexus.deploy/nexus/content/repositories/releases'
+    deploy_dir = 'm2repo'
+
+    # Test success - Snapshot
+    snapshot = True
+    test_files = ['4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom',
+                  '4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.sha1',
+                  '4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.md5',
+                  '4.0.3-SNAPSHOT/maven-metadata.xml',
+                  '4.0.3-SNAPSHOT/maven-metadata.xml.md5',
+                  '4.0.3-SNAPSHOT/maven-metadata.xml.sha1',
+                  'maven-metadata.xml',
+                  'maven-metadata.xml.md5',
+                  'maven-metadata.xml.sha1']
+    for file in test_files:
+        success_upload_url = '{}/{}'.format(nexus_url, file)
+        responses.add(responses.POST, success_upload_url,
+                      status=201)
+    deploy_sys.deploy_nexus(nexus_url, deploy_dir, snapshot)
+
+
+@pytest.mark.datafiles(
+    os.path.join(FIXTURE_DIR, 'deploy'),
+    )
+def test_deploy_nexus_nosnapshot(datafiles, responses):
+    """Test deploy_nexus with no snapshot.
+
+    This test will send a directory of files to deploy_nexus, which should
+    call requests.post once for every valid (=3) file.
+    There are six files that should not be uploaded, and three that should.
+    """
+    os.chdir(str(datafiles))
+    nexus_url = 'http://successfull.nexus.deploy/nexus/content/repositories/releases'
+    deploy_dir = 'm2repo'
+
+    # Test success - No Snapshot
+    test_files = ['4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom',
+                  '4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.sha1',
+                  '4.0.3-SNAPSHOT/odlparent-lite-4.0.3-20181120.113136-1.pom.md5']
+    for file in test_files:
+        success_upload_url = '{}/{}'.format(nexus_url, file)
+        responses.add(responses.POST, success_upload_url,
+                      status=201)
+    deploy_sys.deploy_nexus(nexus_url, deploy_dir)