summaryrefslogtreecommitdiffstats
path: root/local-setup/src/main
diff options
context:
space:
mode:
authorkurczews <krzysztof.kurczewski@nokia.com>2019-01-07 07:10:10 +0100
committerkurczews <krzysztof.kurczewski@nokia.com>2019-01-07 07:27:21 +0100
commite64f08ac8242a7db6eb3238ee0ad1a30c8aecf0d (patch)
treed152c7418987fe79260943a6c8b1467d201f69cb /local-setup/src/main
parent57a4c074857c33ba74dcce1ae4818e56ceb6c603 (diff)
Add simplified local setup
Simplify local setup described at: https://wiki.onap.org/display/DW/AAI+Developer+Environment+Setup+-+Casablanca * simplified janus-server setup * simplified haproxy setup * added docker-compose * introduce automatic tests for containers * added run instruction Issue-ID: AAI-2049 Change-Id: I7c033c6a4464f3da94bdf11566060693c0f8b005 Signed-off-by: kurczews <krzysztof.kurczewski@nokia.com>
Diffstat (limited to 'local-setup/src/main')
-rw-r--r--local-setup/src/main/docker/docker-compose.yml23
-rw-r--r--local-setup/src/main/docker/haproxy/Dockerfile9
-rw-r--r--local-setup/src/main/docker/haproxy/aai.pem84
-rw-r--r--local-setup/src/main/docker/haproxy/haproxy.cfg120
-rw-r--r--local-setup/src/main/docker/janusgraph/Dockerfile37
-rwxr-xr-xlocal-setup/src/main/docker/janusgraph/entrypoint.sh24
-rw-r--r--local-setup/src/main/java/onap/aai/dto/Model.java93
-rw-r--r--local-setup/src/main/java/onap/aai/dto/ModelGenerator.java48
-rw-r--r--local-setup/src/main/java/onap/aai/util/AaiRequest.java62
-rw-r--r--local-setup/src/main/java/onap/aai/util/Resources.java40
10 files changed, 540 insertions, 0 deletions
diff --git a/local-setup/src/main/docker/docker-compose.yml b/local-setup/src/main/docker/docker-compose.yml
new file mode 100644
index 0000000..28e7360
--- /dev/null
+++ b/local-setup/src/main/docker/docker-compose.yml
@@ -0,0 +1,23 @@
+version: '2'
+
+services:
+
+ aai-storage:
+ image: onap/aai-janus-dev
+ container_name: aai-storage
+ network_mode: host
+
+ aai-resources:
+ image: onap/aai-resources
+ container_name: aai-resources
+ network_mode: host
+
+ aai-traversal:
+ image: onap/aai-traversal
+ container_name: aai-traversal
+ network_mode: host
+
+ aai-haproxy:
+ image: onap/aai-haproxy-dev
+ container_name: aai-haproxy
+ network_mode: host \ No newline at end of file
diff --git a/local-setup/src/main/docker/haproxy/Dockerfile b/local-setup/src/main/docker/haproxy/Dockerfile
new file mode 100644
index 0000000..121b698
--- /dev/null
+++ b/local-setup/src/main/docker/haproxy/Dockerfile
@@ -0,0 +1,9 @@
+FROM haproxy:1.6-alpine
+
+WORKDIR app/
+
+COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
+
+COPY aai.pem /etc/ssl/private/aai.pem
+
+RUN chmod 640 /etc/ssl/private/aai.pem && chown root:root /etc/ssl/private/aai.pem \ No newline at end of file
diff --git a/local-setup/src/main/docker/haproxy/aai.pem b/local-setup/src/main/docker/haproxy/aai.pem
new file mode 100644
index 0000000..ce97d30
--- /dev/null
+++ b/local-setup/src/main/docker/haproxy/aai.pem
@@ -0,0 +1,84 @@
+-----BEGIN CERTIFICATE-----
+MIIFEjCCA/qgAwIBAgIBBjANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQGEwJVUzEN
+MAsGA1UECgwET05BUDEOMAwGA1UECwwFT1NBQUYxGTAXBgNVBAMMEGludGVybWVk
+aWF0ZUNBXzEwHhcNMTgwNjA1MTIxOTU5WhcNMTkwNTMxMTIxOTU5WjBVMQswCQYD
+VQQGEwJVUzENMAsGA1UECgwET05BUDEZMBcGA1UECwwQYWFpQGFhaS5vbmFwLm9y
+ZzEOMAwGA1UECwwFT1NBQUYxDDAKBgNVBAMMA2FhaTCCASIwDQYJKoZIhvcNAQEB
+BQADggEPADCCAQoCggEBAMqVPBjn6pxPhAwRov+ApKxJkuSo/UNbwmc7eYC+eYiY
+SB35uI7Bt8UHWxxBNZdHpFbZUOuL2wWb7JYycML8gbsY2YF440K+X+TVTiVGSkv0
+L8MYwDTuCOn9YtlTEkKE6Wth4WPyEN3ZrQD7j7YGNr/3tK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sl4dEB
+xPdCg7SeLZYpMgOM5nIA7/BWiSL6AxhiA4C2QzsqSadp5vuyjw6PQ0YaTLPQcTHm
+mqbDfB4CEklRyxzm8EKDMsYwU9PRa4wyTMdFsblqQQKBgAwy06uFXXdXnoA3PI7J
+EJwRkChV4kR0dspAhIZsdfY6yw606IB+NvT48S5gLvMpxC8JGrCjKUkcw4e7lO+c
+oxIjEwLmqqYRktRTfWU6SeqrGiiS6/+jERVdVxJysF/0havDkXr27rymiCKb2k2F
+82R57RzJC+AYRYrpsJH8dMuA
+-----END PRIVATE KEY----- \ No newline at end of file
diff --git a/local-setup/src/main/docker/haproxy/haproxy.cfg b/local-setup/src/main/docker/haproxy/haproxy.cfg
new file mode 100644
index 0000000..0fecea0
--- /dev/null
+++ b/local-setup/src/main/docker/haproxy/haproxy.cfg
@@ -0,0 +1,120 @@
+global
+ log /dev/log local0
+ stats socket /usr/local/etc/haproxy/haproxy.socket mode 660 level admin
+ stats timeout 30s
+ user root
+ group root
+ daemon
+ #################################
+ # Default SSL material locations#
+ #################################
+ ca-base /etc/ssl/certs
+ crt-base /etc/ssl/private
+
+ # Default ciphers to use on SSL-enabled listening sockets.
+ # For more information, see ciphers(1SSL). This list is from:
+ # https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
+ # An alternative list with additional directives can be obtained from
+ # https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
+ tune.ssl.default-dh-param 2048
+
+defaults
+ log global
+ mode http
+ option httplog
+# option dontlognull
+# errorfile 400 /etc/haproxy/errors/400.http
+# errorfile 403 /etc/haproxy/errors/403.http
+# errorfile 408 /etc/haproxy/errors/408.http
+# errorfile 500 /etc/haproxy/errors/500.http
+# errorfile 502 /etc/haproxy/errors/502.http
+# errorfile 503 /etc/haproxy/errors/503.http
+# errorfile 504 /etc/haproxy/errors/504.http
+
+ option http-server-close
+ option forwardfor except 127.0.0.1
+ retries 6
+ option redispatch
+ maxconn 50000
+ timeout connect 50000
+ timeout client 480000
+ timeout server 480000
+ timeout http-keep-alive 30000
+
+
+frontend IST_8443
+ mode http
+ bind 0.0.0.0:8443 name https ssl crt /etc/ssl/private/aai.pem
+# log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ {%[ssl_c_verify],%{+Q}[ssl_c_s_dn],%{+Q}[ssl_c_i_dn]}\ %{+Q}r
+ log-format "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC \ %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"
+ option httplog
+ log global
+ option logasap
+ option forwardfor
+ capture request header Host len 100
+ capture response header Host len 100
+ option log-separate-errors
+ option forwardfor
+ http-request set-header X-Forwarded-Proto https if { ssl_fc }
+ http-request set-header X-AAI-Client-SSL TRUE if { ssl_c_used }
+ http-request set-header X-AAI-SSL %[ssl_fc]
+ http-request set-header X-AAI-SSL-Client-Verify %[ssl_c_verify]
+ http-request set-header X-AAI-SSL-Client-DN %{+Q}[ssl_c_s_dn]
+ http-request set-header X-AAI-SSL-Client-CN %{+Q}[ssl_c_s_dn(cn)]
+ http-request set-header X-AAI-SSL-Issuer %{+Q}[ssl_c_i_dn]
+ http-request set-header X-AAI-SSL-Client-NotBefore %{+Q}[ssl_c_notbefore]
+ http-request set-header X-AAI-SSL-Client-NotAfter %{+Q}[ssl_c_notafter]
+ http-request set-header X-AAI-SSL-ClientCert-Base64 %{+Q}[ssl_c_der,base64]
+ http-request set-header X-AAI-SSL-Client-OU %{+Q}[ssl_c_s_dn(OU)]
+ http-request set-header X-AAI-SSL-Client-L %{+Q}[ssl_c_s_dn(L)]
+ http-request set-header X-AAI-SSL-Client-ST %{+Q}[ssl_c_s_dn(ST)]
+ http-request set-header X-AAI-SSL-Client-C %{+Q}[ssl_c_s_dn(C)]
+ http-request set-header X-AAI-SSL-Client-O %{+Q}[ssl_c_s_dn(O)]
+ reqadd X-Forwarded-Proto:\ https
+ reqadd X-Forwarded-Port:\ 8443
+
+#######################
+#ACLS FOR PORT 8446####
+#######################
+
+ acl is_Port_8446_generic path_reg -i ^/aai/v[0-9]+/search/generic-query$
+ acl is_Port_8446_nodes path_reg -i ^/aai/v[0-9]+/search/nodes-query$
+ acl is_Port_8446_version path_reg -i ^/aai/v[0-9]+/query$
+ acl is_named-query path_beg -i /aai/search/named-query
+ acl is_search-model path_beg -i /aai/search/model
+ use_backend IST_AAI_8446 if is_Port_8446_generic or is_Port_8446_nodes or is_Port_8446_version or is_named-query or is_search-model
+
+ default_backend IST_Default_8447
+
+
+#######################
+#DEFAULT BACKEND 847###
+#######################
+
+backend IST_Default_8447
+ balance roundrobin
+ http-request set-header X-Forwarded-Port %[src_port]
+ http-response set-header Strict-Transport-Security max-age=16000000;\ includeSubDomains;\ preload;
+ server aai-resources.api.simpledemo.openecomp.org localhost:8447 port 8447 ssl verify none
+
+#######################
+# BACKEND 8446#########
+#######################
+
+backend IST_AAI_8446
+ balance roundrobin
+ http-request set-header X-Forwarded-Port %[src_port]
+ http-response set-header Strict-Transport-Security max-age=16000000;\ includeSubDomains;\ preload;
+ server aai-traversal.api.simpledemo.openecomp.org localhost:8446 port 8446 ssl verify none
+
+listen IST_AAI_STATS
+ mode http
+ bind *:8080
+ stats uri /stats
+ stats enable
+ stats refresh 30s
+ stats hide-version
+ stats auth admin:admin
+ stats show-legends
+ stats show-desc IST AAI APPLICATION NODES
+ stats admin if TRUE \ No newline at end of file
diff --git a/local-setup/src/main/docker/janusgraph/Dockerfile b/local-setup/src/main/docker/janusgraph/Dockerfile
new file mode 100644
index 0000000..76c3628
--- /dev/null
+++ b/local-setup/src/main/docker/janusgraph/Dockerfile
@@ -0,0 +1,37 @@
+FROM alpine:3.7
+
+WORKDIR app/
+
+RUN apk add --no-cache \
+ bash \
+ openjdk8 \
+ unzip \
+ wget
+
+ENV PATH $PATH:/usr/lib/jvm/java-1.8-openjdk/bin/
+
+ARG JANUS_VERSION=0.2.0
+ARG JANUS_ARTIFACT=janusgraph-${JANUS_VERSION}-hadoop2
+
+RUN wget -q --show-progress --progress=bar:force:noscroll \
+ http://github.com/JanusGraph/janusgraph/releases/download/v${JANUS_VERSION}/${JANUS_ARTIFACT}.zip && \
+ unzip ${JANUS_ARTIFACT}.zip && \
+ rm ${JANUS_ARTIFACT}.zip && \
+ mv ${JANUS_ARTIFACT} janusgraph
+
+# WARN: Instruction above takes long time. Make best effort to insert additional commands below this comment
+
+CMD ["./entrypoint.sh"]
+
+COPY entrypoint.sh .
+
+RUN chmod +x entrypoint.sh
+
+ARG USER=janusz
+ARG GROUP=aai
+
+RUN addgroup ${GROUP} && adduser -D ${USER} ${GROUP} && chown -R ${USER}:${GROUP} .
+
+USER ${USER}:${GROUP}
+
+HEALTHCHECK --interval=40s --timeout=10s --retries=3 CMD janusgraph/bin/janusgraph.sh status \ No newline at end of file
diff --git a/local-setup/src/main/docker/janusgraph/entrypoint.sh b/local-setup/src/main/docker/janusgraph/entrypoint.sh
new file mode 100755
index 0000000..8108866
--- /dev/null
+++ b/local-setup/src/main/docker/janusgraph/entrypoint.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# run short-living command and prevent docker from stopping
+
+JANUS_EXEC="janusgraph/bin/janusgraph.sh"
+
+onStart() {
+ ${JANUS_EXEC} start
+}
+
+onStop() {
+ ${JANUS_EXEC} stop
+}
+
+waitLoop() {
+ tail -f /dev/null &
+ wait $!
+}
+
+trap 'onStop; exit 0' SIGTERM SIGINT
+
+onStart || exit $?
+
+waitLoop \ No newline at end of file
diff --git a/local-setup/src/main/java/onap/aai/dto/Model.java b/local-setup/src/main/java/onap/aai/dto/Model.java
new file mode 100644
index 0000000..1cf9a41
--- /dev/null
+++ b/local-setup/src/main/java/onap/aai/dto/Model.java
@@ -0,0 +1,93 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2018-2019 Nokia 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=========================================================
+ */
+package onap.aai.dto;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Dummy model for testing purposes
+ */
+@SuppressWarnings("unused")
+public class Model {
+
+ private static final String MODEL_TYPE = "widget";
+ private static final String MODEL_VERSION = "1.0";
+
+ private final String modelInvariantId;
+ private final String modelType;
+ private final ModelVers modelVers;
+
+ public Model(String modelName, String modelInvariantId, String modelVersionId) {
+ this.modelInvariantId = modelInvariantId;
+ this.modelVers = new ModelVers(new ModelVer(modelVersionId, modelName));
+ this.modelType = MODEL_TYPE;
+ }
+
+ public String getModelInvariantId() {
+ return modelInvariantId;
+ }
+
+ public ModelVers getModelVers() {
+ return modelVers;
+ }
+
+ public String getModelType() {
+ return modelType;
+ }
+
+ private static class ModelVers {
+
+ private final List<ModelVer> modelVer;
+
+ ModelVers(ModelVer... modelVer) {
+ this.modelVer = Arrays.asList(modelVer);
+ }
+
+ public List<ModelVer> getModelVer() {
+ return modelVer;
+ }
+ }
+
+ private static class ModelVer {
+
+ private final String modelVersionId;
+ private final String modelVersion;
+ private final String modelName;
+
+ ModelVer(String modelVersionId, String modelName) {
+ this.modelVersionId = modelVersionId;
+ this.modelName = modelName;
+ this.modelVersion = MODEL_VERSION;
+ }
+
+ public String getModelVersionId() {
+ return modelVersionId;
+ }
+
+ public String getModelName() {
+ return modelName;
+ }
+
+ public String getModelVersion() {
+ return MODEL_VERSION;
+ }
+ }
+} \ No newline at end of file
diff --git a/local-setup/src/main/java/onap/aai/dto/ModelGenerator.java b/local-setup/src/main/java/onap/aai/dto/ModelGenerator.java
new file mode 100644
index 0000000..c6625e1
--- /dev/null
+++ b/local-setup/src/main/java/onap/aai/dto/ModelGenerator.java
@@ -0,0 +1,48 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2018-2019 Nokia 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=========================================================
+ */
+package onap.aai.dto;
+
+import static onap.aai.util.Resources.readerFrom;
+
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.util.stream.Stream;
+import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVParser;
+import org.apache.commons.csv.CSVRecord;
+
+public class ModelGenerator {
+
+ public static Stream<Model> generate(String fileName) {
+ try (CSVParser parser = CSVFormat.DEFAULT.withFirstRecordAsHeader().parse(readerFrom(fileName))) {
+ return parser.getRecords().stream().map(ModelGenerator::csvToModel);
+ } catch (IOException e) {
+ throw new UncheckedIOException(e);
+ }
+ }
+
+ private static Model csvToModel(CSVRecord csvRecord) {
+ return new Model(
+ csvRecord.get("model-name"),
+ csvRecord.get("model-invariant-id"),
+ csvRecord.get("model-version-id")
+ );
+ }
+}
diff --git a/local-setup/src/main/java/onap/aai/util/AaiRequest.java b/local-setup/src/main/java/onap/aai/util/AaiRequest.java
new file mode 100644
index 0000000..1875e41
--- /dev/null
+++ b/local-setup/src/main/java/onap/aai/util/AaiRequest.java
@@ -0,0 +1,62 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2018-2019 Nokia 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=========================================================
+ */
+package onap.aai.util;
+
+import com.github.kevinsawicki.http.HttpRequest;
+
+public class AaiRequest {
+
+ private static final String AAI_BASE_URL = "https://localhost:8443/aai";
+ private static final String AAI_AUTH = "Basic QUFJOkFBSQ==";
+ private static final String SCHEMA_VERSION = "/v14";
+
+ public static HttpRequest get(String endpoint) {
+ return aaiRequest(HttpRequest.get(aaiEndpoint(endpoint)));
+ }
+
+ public static HttpRequest post(String endpoint) {
+ return aaiRequest(HttpRequest.post(aaiEndpoint(endpoint)));
+ }
+
+ public static HttpRequest put(String endpoint) {
+ return aaiRequest(HttpRequest.put(aaiEndpoint(endpoint)));
+ }
+
+ public static HttpRequest delete(String endpoint) {
+ return aaiRequest(HttpRequest.delete(aaiEndpoint(endpoint)));
+ }
+
+ public static String v14(String endpoint) {
+ return SCHEMA_VERSION + endpoint;
+ }
+
+ private static HttpRequest aaiRequest(HttpRequest httpRequest) {
+ return httpRequest
+ .header("X-FromAppId", "dummy id")
+ .header("X-TransactionId", "1234")
+ .authorization(AAI_AUTH)
+ .trustAllCerts()
+ .trustAllHosts();
+ }
+
+ private static String aaiEndpoint(String endpoint) {
+ return AAI_BASE_URL + endpoint;
+ }
+} \ No newline at end of file
diff --git a/local-setup/src/main/java/onap/aai/util/Resources.java b/local-setup/src/main/java/onap/aai/util/Resources.java
new file mode 100644
index 0000000..54d21ec
--- /dev/null
+++ b/local-setup/src/main/java/onap/aai/util/Resources.java
@@ -0,0 +1,40 @@
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2018-2019 Nokia 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=========================================================
+ */
+package onap.aai.util;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.stream.Collectors;
+
+public class Resources {
+
+ public static InputStream inputStreamFrom(String fileName) {
+ return Resources.class.getClassLoader().getResourceAsStream(fileName);
+ }
+
+ public static BufferedReader readerFrom(String fileName) {
+ return new BufferedReader(new InputStreamReader(inputStreamFrom(fileName)));
+ }
+
+ public static String rawTextFrom(String fileName) {
+ return readerFrom(fileName).lines().collect(Collectors.joining());
+ }
+}