aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.md4
-rw-r--r--LICENSE.txt6
-rw-r--r--pom.xml46
-rw-r--r--project.clj7
-rwxr-xr-xresources/health.sh17
-rw-r--r--src/sch/core.clj10
-rw-r--r--src/sch/handle.clj2
-rw-r--r--src/sch/parse.clj2
-rw-r--r--test/sch/asdc_client_test.clj21
-rw-r--r--test/sch/core_test.clj31
-rw-r--r--test/sch/handle_test.clj78
-rw-r--r--test/sch/inventory_client_test.clj62
-rw-r--r--version.properties4
13 files changed, 262 insertions, 28 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index 7ed2195..e657225 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
+## [1.1.3]
+
+* DCAEGEN2-431
+
## [1.1.0]
This body of work is aimed at getting SCH to be run on the new DCAE platform.
diff --git a/LICENSE.txt b/LICENSE.txt
index 69d5fc1..9536f0b 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,11 +1,11 @@
/*
* ============LICENSE_START==========================================
* ===================================================================
-* Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+* Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
* ===================================================================
*
* Unless otherwise specified, all software contained herein is licensed
-* under the Apache License, Version 2.0 (the “License”);
+* under the Apache License, Version 2.0 (the "License");
* you may not use this software except in compliance with the License.
* You may obtain a copy of the License at
*
@@ -20,7 +20,7 @@
*
*
* Unless otherwise specified, all documentation contained herein is licensed
-* under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+* under the Creative Commons License, Attribution 4.0 Intl. (the "License");
* you may not use this documentation except in compliance with the License.
* You may obtain a copy of the License at
*
diff --git a/pom.xml b/pom.xml
index 14041d9..d9b81eb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+================================================================================
+Copyright (c) 2016-2018 AT&T Intellectual Property. All rights reserved.
+================================================================================
+Licensed 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.
+============LICENSE_END=========================================================
+
+ECOMP is a trademark and service mark of AT&T Intellectual Property.
+-->
+
<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">
@@ -6,13 +27,13 @@
<parent>
<groupId>org.onap.oparent</groupId>
<artifactId>oparent</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.1.0</version>
</parent>
<groupId>org.onap.dcaegen2.platform</groupId>
<artifactId>servicechange-handler</artifactId>
- <version>1.0.0</version>
+ <version>1.1.4</version>
<!-- Not sure why clojure-maven-plugin says packaging should be "clojure" -->
<packaging>jar</packaging>
@@ -26,7 +47,7 @@
</repositories>
<properties>
- <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
<nexusproxy>https://nexus.onap.org</nexusproxy>
<snapshots.path>content/repositories/snapshots/</snapshots.path>
<releases.path>content/repositories/releases/</releases.path>
@@ -41,23 +62,23 @@
<dependency>
<groupId>cheshire</groupId>
<artifactId>cheshire</artifactId>
- <version>5.6.3</version>
+ <version>5.8.0</version>
</dependency>
<dependency>
- <groupId>org.openecomp.sdc.sdc-distribution-client</groupId>
+ <groupId>org.onap.sdc.sdc-distribution-client</groupId>
<artifactId>sdc-distribution-client</artifactId>
- <version>1.1.32</version>
+ <version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.taoensso</groupId>
<artifactId>timbre</artifactId>
- <version>4.7.4</version>
+ <version>4.10.0</version>
</dependency>
<!-- Does magic so traditional Java loggers show up -->
<dependency>
<groupId>com.fzakaria</groupId>
<artifactId>slf4j-timbre</artifactId>
- <version>0.3.2</version>
+ <version>0.3.8</version>
</dependency>
<dependency>
<groupId>clj-http</groupId>
@@ -74,6 +95,12 @@
<artifactId>clj-yaml</artifactId>
<version>0.4.0</version>
</dependency>
+ <dependency>
+ <groupId>clj-fakes</groupId>
+ <artifactId>clj-fakes</artifactId>
+ <version>0.9.0</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
@@ -190,7 +217,8 @@
<maintainer>Michael Hwang</maintainer>
<imageName>${onap.nexus.dockerregistry.daily}/onap/${project.groupId}.${project.artifactId}</imageName>
<imageTags>
- <imageTag>${project.version}-${maven.build.timestamp}</imageTag>
+ <imageTag>${project.version}-SNAPSHOT-${maven.build.timestamp}Z</imageTag>
+ <imageTag>${project.version}</imageTag>
<imageTag>latest</imageTag>
</imageTags>
<baseImage>java:8-jre</baseImage>
diff --git a/project.clj b/project.clj
index 45976e5..67a294a 100644
--- a/project.clj
+++ b/project.clj
@@ -24,18 +24,21 @@
(defproject service-change-handler "0.1.0"
:description "Service change handler"
:dependencies [[org.clojure/clojure "1.8.0"]
- [cheshire/cheshire "5.6.3"]
+ [cheshire/cheshire "5.8.0"]
[com.taoensso/timbre "4.7.4"]
[com.fzakaria/slf4j-timbre "0.3.2"]
[clj-http/clj-http "3.3.0"]
[org.bovinegenius/exploding-fish "0.3.4"]
[clj-yaml/clj-yaml "0.4.0"]
- [org.openecomp.sdc.sdc-distribution-client/sdc-distribution-client "1.1.0-SNAPSHOT"]
+ [org.onap.sdc.sdc-distribution-client/sdc-distribution-client "1.3.0"]
]
; TODO: Fill in the onap maven repository info
:repositories [["onap nexus" "https://nexus.onap.org/content/repositories/snapshots/"]]
:plugins [[lein-cloverage "1.0.9"]]
+ :profiles { :test { :dependencies [[clj-fakes "0.9.0"]] }
+ ; Added this for cloverage
+ :dev { :dependencies [[clj-fakes "0.9.0"]] } }
)
diff --git a/resources/health.sh b/resources/health.sh
index 5fe8236..b2d0b4a 100755
--- a/resources/health.sh
+++ b/resources/health.sh
@@ -1,3 +1,20 @@
+# ================================================================================
+# Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed 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.
+# ============LICENSE_END=========================================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
#!/bin/bash
# Health check script for service change handler
diff --git a/src/sch/core.clj b/src/sch/core.clj
index d83d266..1852c76 100644
--- a/src/sch/core.clj
+++ b/src/sch/core.clj
@@ -29,11 +29,12 @@
[sch.inventory-client :refer [create-inventory-conn]]
[sch.parse :refer [get-dcae-artifact-types pick-out-artifact]]
[sch.util :refer [read-config]]
+ [clojure.string :as strlib]
)
- (:import (org.openecomp.sdc.impl DistributionClientFactory)
- (org.openecomp.sdc.api.consumer IConfiguration INotificationCallback
+ (:import (org.onap.sdc.impl DistributionClientFactory)
+ (org.onap.sdc.api.consumer IConfiguration INotificationCallback
IDistributionStatusMessage)
- (org.openecomp.sdc.utils DistributionActionResultEnum DistributionStatusEnum)
+ (org.onap.sdc.utils DistributionActionResultEnum DistributionStatusEnum)
(com.google.gson Gson)
)
(:gen-class))
@@ -93,6 +94,8 @@
(let [config-asdc (:asdcDistributionClient config)]
(proxy [IConfiguration] []
(getAsdcAddress [] (str (:asdcAddress config-asdc)))
+ (getMsgBusAddress [] (java.util.ArrayList.
+ (strlib/split (str (:msgBusAddress config-asdc)) #",")))
(getUser [] (str (:user config-asdc)))
(getPassword [] (str (:password config-asdc)))
(getPollingInterval [] (int (:pollingInterval config-asdc)))
@@ -111,6 +114,7 @@
(activateServerTLSAuth [] (boolean (:activateServerTLSAuth config-asdc)))
(isFilterInEmptyResources [] (boolean (:isFilterInEmptyResources config-asdc)))
(isUseHttpsWithDmaap [] (boolean (:useHttpsWithDmaap config-asdc false)))
+ (isConsumeProduceStatusTopic [] (boolean (:isConsumeProduceStatusTopic config-asdc false)))
)))
(defn run-distribution-client!
diff --git a/src/sch/handle.clj b/src/sch/handle.clj
index 13201c4..453b586 100644
--- a/src/sch/handle.clj
+++ b/src/sch/handle.clj
@@ -27,7 +27,7 @@
[sch.parse :refer [generate-dcae-service-type-requests
get-service-locations]]
)
- (:import (org.openecomp.sdc.utils DistributionStatusEnum))
+ (:import (org.onap.sdc.utils DistributionStatusEnum))
(:gen-class))
diff --git a/src/sch/parse.clj b/src/sch/parse.clj
index 7ce48e6..668dbf4 100644
--- a/src/sch/parse.clj
+++ b/src/sch/parse.clj
@@ -24,7 +24,7 @@
[sch.asdc-client :refer [construct-service-path]]
[cheshire.core :refer [parse-string]]
)
- (:import (org.openecomp.sdc.utils ArtifactTypeEnum))
+ (:import (org.onap.sdc.utils ArtifactTypeEnum))
(:gen-class))
diff --git a/test/sch/asdc_client_test.clj b/test/sch/asdc_client_test.clj
index ab84478..974dd40 100644
--- a/test/sch/asdc_client_test.clj
+++ b/test/sch/asdc_client_test.clj
@@ -1,7 +1,7 @@
; ============LICENSE_START=======================================================
; org.onap.dcae
; ================================================================================
-; Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+; Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
; ================================================================================
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
@@ -20,16 +20,17 @@
(ns sch.asdc-client-test
(:use (clojure test))
- (:require [sch.asdc-client :refer [create-asdc-conn]])
+ (:require [sch.asdc-client :as ac])
)
+
(deftest test-create-asdc-conn
(let [config-good { :asdcUri "https://asdc-please-work:8443"
:user "foo-user"
:password "foo-password"
:consumerId "foo-id"
:activateServerTLSAuth true }
- actual (create-asdc-conn { :asdcDistributionClient config-good })
+ actual (ac/create-asdc-conn { :asdcDistributionClient config-good })
[uri user password consumer-id insecure?] actual
]
(is (= (str uri) (:asdcUri config-good)))
@@ -38,3 +39,17 @@
(is (= consumer-id (:consumerId config-good)))
(is (= insecure? (not (:activateServerTLSAuth config-good))))
))
+
+
+(deftest test-get-consumer-id
+ (let [consumer-id "SOME-CONSUMER-ID"
+ asdc-conn [nil nil nil consumer-id nil]]
+ (is (= consumer-id (ac/get-consumer-id asdc-conn)))
+ ))
+
+
+(deftest test-construct-service-path
+ (let [service-uuid "abc123"]
+ (is (= "/sdc/v1/catalog/services/abc123/metadata"
+ (ac/construct-service-path service-uuid)))
+ ))
diff --git a/test/sch/core_test.clj b/test/sch/core_test.clj
index c0682f4..4d0ee2b 100644
--- a/test/sch/core_test.clj
+++ b/test/sch/core_test.clj
@@ -1,7 +1,7 @@
; ============LICENSE_START=======================================================
; org.onap.dcae
; ================================================================================
-; Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+; Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
; ================================================================================
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
@@ -20,12 +20,37 @@
(ns sch.core-test
(:use (clojure test))
- (:require [sch.core :refer [create-distribution-client-config]])
+ (:require [sch.core :refer [create-distribution-client-config deploy-artifacts-ex!]]
+ [clj-fakes.core :as f])
+ (:import (org.onap.sdc.utils DistributionStatusEnum))
)
+
+(deftest test-deploy-artifacts-ex
+ (letfn [(deploy-artifacts-echo [to-post posted to-delete deleted inventory-uri
+ service-metadata requests]
+ to-post posted to-delete deleted)
+ (send-dist-status-only-ok [artifact status]
+ (if (not= (. DistributionStatusEnum ALREADY_DEPLOYED) status)
+ (throw (Exception. "Distribution status should be ALREADY DEPLOYED"))
+ ))]
+ (let [service-metadata [{:resources [{:resourceInvariantUUID "123"
+ :artifacts [:artifactName "type-foo"]
+ }]}]
+ requests [{:asdcResourceId "123" :typeName "type-foo"}]
+ deploy-artifacts (partial deploy-artifacts-echo requests [] [] [])
+ ]
+ (f/with-fakes
+ (f/patch! #'sch.handle/deploy-artifacts! deploy-artifacts)
+ (is (= nil (deploy-artifacts-ex! "http://inventory" service-metadata requests
+ send-dist-status-only-ok))))
+ )))
+
+
(deftest test-create-distribution-client-config
(let [config { :asdcDistributionClient { :environmentName "ONAP-AMDOCS"
:asdcAddress "10.0.3.1:8443"
+ :msgBusAddress "message-router-hostname"
:keyStorePassword nil
:pollingInterval 20
:consumerGroup "dcae"
@@ -42,5 +67,7 @@
dcc (create-distribution-client-config config)
]
(is (= (. dcc isUseHttpsWithDmaap) true))
+ (is (= (. dcc getMsgBusAddress) ["message-router-hostname"]))
+ (is (= (. dcc isConsumeProduceStatusTopic) false))
)
)
diff --git a/test/sch/handle_test.clj b/test/sch/handle_test.clj
index 9cbf9f7..e986563 100644
--- a/test/sch/handle_test.clj
+++ b/test/sch/handle_test.clj
@@ -1,7 +1,7 @@
; ============LICENSE_START=======================================================
; org.onap.dcae
; ================================================================================
-; Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+; Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
; ================================================================================
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
@@ -21,9 +21,83 @@
(ns sch.handle-test
(:use (clojure test))
(:require [cheshire.core :refer [parse-stream]]
- [sch.handle :refer :all])
+ [sch.handle :refer :all]
+ [clj-fakes.core :as f])
)
+
+(deftest test-should-update
+ (is (= false (should-update? {:typeVersion 2} {:typeVersion 3})))
+ (is (= true (should-update? {:typeVersion 3} {:typeVersion 2})))
+ )
+
+
+(deftest test-should-insert
+ (is (= true (should-insert? {} nil)))
+ (is (= true (should-insert? {} {})))
+ (is (= false (should-insert? {} {:somekey "yo"})))
+ )
+
+
+(deftest test-find-service-types-to-post
+ (letfn [(fake-get-service-types [result inventory-uri query-params]
+ result)]
+ (let [find-service-types-to-post #'sch.handle/find-service-types-to-post!
+ service-type-requests [{:typeName "some-type" :asdcServiceId "abc"
+ :asdcResourceId "123" :typeVersion 3}]
+ fake-get-service-types-insert (partial fake-get-service-types {})
+ ]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/get-service-types! fake-get-service-types-insert)
+ (is (= service-type-requests (find-service-types-to-post "http://inventory"
+ service-type-requests)))
+ ))))
+
+
+(deftest test-post-service-types
+ (letfn [(fake-post-service-type [inventory-uri request]
+ (assoc request :typeId "123"))]
+ (let [service-type-requests [{:typeName "some-type" :asdcServiceId "abc"
+ :asdcResourceId "123" :typeVersion 3}]
+ post-service-types #'sch.handle/post-service-types!]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/post-service-type! fake-post-service-type)
+ (is (= {:typeId "123" :typeName "some-type" :asdcServiceId "abc"
+ :asdcResourceId "123" :typeVersion 3}
+ (first (post-service-types "http://inventory" service-type-requests)))))
+ )))
+
+
+(deftest test-find-service-types-to-delete
+ (letfn [(fake-get-service-types [result inventory-uri query-params]
+ result)]
+ (let [find-service-types-to-delete #'sch.handle/find-service-types-to-delete!
+ service-type-requests [{:typeName "some-type" :asdcServiceId "abc"
+ :asdcResourceId "123" :typeVersion 3}]
+ fake-get-service-types-delete (partial fake-get-service-types
+ [{ :typeName "some-type"
+ :asdcServiceId "abc"
+ :asdcResourceId "456"
+ :typeVersion 3 }])]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/get-service-types! fake-get-service-types-delete)
+ (is (= 1 (count (find-service-types-to-delete "http://inventory" "abc"
+ service-type-requests)))))
+ )))
+
+
+(deftest test-delete-service-types
+ (letfn [(fake-delete-service-type [inventory-uri type-id]
+ type-id)]
+ (let [service-type-requests [{:typeId "def" :typeName "some-type"
+ :asdcServiceId "abc" :asdcResourceId "123" :typeVersion 3}]
+ delete-service-types #'sch.handle/delete-service-types!]
+ (f/with-fakes
+ (f/patch! #'sch.inventory-client/delete-service-type! fake-delete-service-type)
+ (is (= "def" (first (delete-service-types "http://inventory" service-type-requests)))))
+ )))
+
+
(deftest deployed-funcs-test
(let [requests [{:asdcResourceId "123" :typeName "pizza"}
{:asdcResourceId "456" :typeName "hamburger"}
diff --git a/test/sch/inventory_client_test.clj b/test/sch/inventory_client_test.clj
new file mode 100644
index 0000000..493a186
--- /dev/null
+++ b/test/sch/inventory_client_test.clj
@@ -0,0 +1,62 @@
+; ============LICENSE_START=======================================================
+; org.onap.dcae
+; ================================================================================
+; Copyright (c) 2017-2018 AT&T Intellectual Property. All rights reserved.
+; ================================================================================
+; Licensed 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.
+; ============LICENSE_END=========================================================
+;
+; ECOMP is a trademark and service mark of AT&T Intellectual Property.
+
+(ns sch.inventory-client-test
+ (:use (clojure test))
+ (:require [sch.inventory-client :as ic]
+ [cheshire.core :refer [generate-string]]
+ [clj-fakes.core :as f])
+ )
+
+
+(deftest test-create-inventory-conn
+ (let [inventory-uri "http://inventory"]
+ (is (= inventory-uri (str (ic/create-inventory-conn {:dcaeInventoryClient {:uri inventory-uri}}))))
+ ))
+
+
+(deftest append-params
+ (let [append-params #'sch.inventory-client/append-params]
+ (is (= "http://inventory?some-field=some-value" (append-params "http://inventory" ["some-field" "some-value"])))
+ ))
+
+
+(deftest test-get-service-types
+ (letfn [(fake-get [result url request]
+ {:status 200 :body result})]
+ (let [results {:items [{:typeId "123"}]}
+ conn (ic/create-inventory-conn "http://inventory")
+ fake-get-success (partial fake-get (generate-string results))]
+ (f/with-fakes
+ (f/patch! #'clj-http.client/get fake-get-success)
+ (is (= (:items results) (ic/get-service-types! conn []))))
+ )))
+
+
+(deftest test-post-service-types
+ (letfn [(fake-post [result url request]
+ {:status 200 :body result})]
+ (let [result {:typeId "123"}
+ conn (ic/create-inventory-conn "http://inventory")
+ fake-post-success (partial fake-post (generate-string result))]
+ (f/with-fakes
+ (f/patch! #'clj-http.client/post fake-post-success)
+ (is (= result (ic/post-service-type! conn {}))))
+ )))
diff --git a/version.properties b/version.properties
index 1b04310..88990e7 100644
--- a/version.properties
+++ b/version.properties
@@ -1,6 +1,6 @@
major=1
-minor=0
-patch=0
+minor=1
+patch=4
base_version=${major}.${minor}.${patch}
release_version=${base_version}
snapshot_version=${base_version}-SNAPSHOT