Browse Source

Updated Makefile

ARMADA-29: CI/CD Armada Testing Framework Entrypoints defined

It does not appear the the docker run command to call tox tests/unit
is necessary.  The Makefile already includes several testing checks.

Added a few additional targets as specified in the upc-integration
code-convenstions to satisfy the clcp Makefile standards.

Change-Id: Ia920a856ed6d607fcf38d5f85dbb9a0c8aae4fa6
changes/20/570020/1
One-Fine-Day 1 year ago
parent
commit
ec252e7069
7 changed files with 145 additions and 11 deletions
  1. 37
    5
      Makefile
  2. 0
    5
      armada/conf/default.py
  3. 44
    0
      docs/source/development/getting-started.rst
  4. 1
    1
      entrypoint.sh
  5. 1
    0
      etc/armada/api-paste.ini
  6. 61
    0
      tools/armada_image_run.sh
  7. 1
    0
      tox.ini

+ 37
- 5
Makefile View File

@@ -1,11 +1,27 @@
1
+# Copyright 2018 AT&T Intellectual Property.  All other rights reserved.
2
+#
3
+# Licensed under the Apache License, Version 2.0 (the "License");
4
+# you may not use this file except in compliance with the License.
5
+# You may obtain a copy of the License at
6
+#
7
+#     http://www.apache.org/licenses/LICENSE-2.0
8
+#
9
+# Unless required by applicable law or agreed to in writing, software
10
+# distributed under the License is distributed on an "AS IS" BASIS,
11
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+# See the License for the specific language governing permissions and
13
+# limitations under the License.
14
+
1 15
 # APP INFO
2 16
 DOCKER_REGISTRY ?= quay.io
3 17
 IMAGE_PREFIX    ?= attcomdev
4 18
 IMAGE_NAME      ?= armada
19
+IMAGE_TAG       ?= latest
5 20
 HELM            ?= helm
6 21
 LABEL           ?= commit-id
7 22
 PYTHON          = python3
8 23
 CHART           = armada
24
+IMAGE           := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
9 25
 
10 26
 # VERSION INFO
11 27
 GIT_COMMIT = $(shell git rev-parse HEAD)
@@ -17,8 +33,7 @@ ifdef VERSION
17 33
 	DOCKER_VERSION = $(VERSION)
18 34
 endif
19 35
 
20
-IMAGE_TAG ?= git-${GIT_SHA}
21
-IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${IMAGE_NAME}:${IMAGE_TAG}
36
+
22 37
 SHELL = /bin/bash
23 38
 
24 39
 info:
@@ -58,9 +73,8 @@ check-tox:
58 73
 		exit 2; \
59 74
 	fi
60 75
 
61
-.PHONY: docker-build
62
-images: check-docker
63
-	docker build --rm -t ${IMAGE} --label $(LABEL) .
76
+.PHONY: images
77
+images: check-docker build_armada
64 78
 
65 79
 .PHONY: dry-run
66 80
 dry-run: clean
@@ -68,6 +82,24 @@ dry-run: clean
68 82
 	$(HELM) dep up charts/$(CHART)
69 83
 	$(HELM) template charts/$(CHART)
70 84
 
85
+.PHONY: docs
86
+docs: build_docs
87
+
88
+.PHONY: run_images
89
+run_images: run_armada
90
+
91
+.PHONY: run_armada
92
+run_armada: build_armada
93
+	./tools/armada_image_run.sh $(IMAGE)
94
+
95
+.PHONY: build_docs
96
+build_docs:
97
+	tox -e docs
98
+
99
+.PHONY: build_armada
100
+build_armada:
101
+	docker build -t $(IMAGE) --label $(LABEL) .
102
+
71 103
 # make tools
72 104
 .PHONY: protoc
73 105
 protoc:

+ 0
- 5
armada/conf/default.py View File

@@ -89,11 +89,6 @@ path to the private key that includes the name of the key itself.""")),
89 89
         'tiller_release_roles',
90 90
         default=['admin'],
91 91
         help=utils.fmt('IDs of approved API access roles.')),
92
-
93
-    cfg.ListOpt(
94
-        'tiller_status_roles',
95
-        default=['admin'],
96
-        help=utils.fmt('IDs of approved API access roles.'))
97 92
 ]
98 93
 
99 94
 

+ 44
- 0
docs/source/development/getting-started.rst View File

@@ -211,6 +211,10 @@ To run the Python linter, execute::
211 211
 
212 212
   $ tox -e pep8
213 213
 
214
+  or
215
+
216
+  $ make test-pep8
217
+
214 218
 To lint Helm charts, execute::
215 219
 
216 220
   $ make lint
@@ -219,18 +223,58 @@ To run unit tests, execute::
219 223
 
220 224
   $ tox -e py35
221 225
 
226
+  or
227
+
228
+  $ make test-unit
229
+
222 230
 To run the test coverage job::
223 231
 
224 232
   $ tox -e coverage
225 233
 
234
+  or
235
+
236
+  $ make test-coverage
237
+
226 238
 To run security checks via `Bandit`_ execute::
227 239
 
228 240
   $ tox -e bandit
229 241
 
242
+  or
243
+
244
+  $ make test-bandit
245
+
246
+To build the docker images::
247
+
248
+  $ make images
249
+
230 250
 To build all Armada charts, execute::
231 251
 
232 252
   $ make charts
233 253
 
254
+To build a helm template for the charts::
255
+
256
+  $ make dry-run
257
+
258
+To run lint, charts, and image targets all at once::
259
+
260
+  $ make all
261
+
262
+To render any documentation that has build steps::
263
+
264
+  $ tox -e docs
265
+
266
+  or
267
+
268
+  $ make docs
269
+
270
+To build armada's image::
271
+
272
+  $ make run_armada
273
+
274
+To build all images::
275
+
276
+  $ make run_images
277
+
234 278
 To generate sample configuration and policy files needed for Armada deployment,
235 279
 execute (respectively)::
236 280
 

+ 1
- 1
entrypoint.sh View File

@@ -19,7 +19,7 @@ set -ex
19 19
 CMD="armada"
20 20
 
21 21
 # Define port
22
-PORT=${ARMADA_API_PORT:-8000}
22
+ARMADA_API_PORT=${ARMADA_API_PORT:-8000}
23 23
 # How long uWSGI should wait for each Armada response
24 24
 ARMADA_API_TIMEOUT=${ARMADA_API_TIMEOUT:-"3600"}
25 25
 # Number of uWSGI workers to handle API requests

+ 1
- 0
etc/armada/api-paste.ini View File

@@ -6,3 +6,4 @@ pipeline = authtoken armada-api
6 6
 
7 7
 [filter:authtoken]
8 8
 paste.filter_factory = keystonemiddleware.auth_token:filter_factory
9
+delay_auth_decision = True

+ 61
- 0
tools/armada_image_run.sh View File

@@ -0,0 +1,61 @@
1
+#!/bin/bash
2
+#
3
+# Copyright 2018 AT&T Intellectual Property.  All other rights reserved.
4
+#
5
+# Licensed under the Apache License, Version 2.0 (the "License");
6
+# you may not use this file except in compliance with the License.
7
+# You may obtain a copy of the License at
8
+#
9
+#     http://www.apache.org/licenses/LICENSE-2.0
10
+#
11
+# Unless required by applicable law or agreed to in writing, software
12
+# distributed under the License is distributed on an "AS IS" BASIS,
13
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+# See the License for the specific language governing permissions and
15
+# limitations under the License.
16
+
17
+IMAGE=$1
18
+
19
+set -x
20
+
21
+# Create container
22
+function create {
23
+	docker run \
24
+	  -v $(pwd)/etc:/etc \
25
+		-d \
26
+		--name armada-api-test \
27
+		-p 127.0.0.1:8000:8000 \
28
+		${IMAGE} \
29
+		server
30
+}
31
+
32
+# Verify container was successfully created
33
+# If not successful, print out logs
34
+function health_check {
35
+	GOOD="HTTP/1.1 204 No Content"
36
+	if curl\
37
+		-m 5 \
38
+		-v \
39
+		--silent \
40
+		127.0.0.1:8000/api/v1.0/health \
41
+		--stderr - \
42
+		| grep "$GOOD"
43
+	then
44
+		echo "Health Check Success"
45
+		exit 0
46
+	else
47
+		echo "Failed Health Check"
48
+		docker logs armada-api-test
49
+		exit 1
50
+	fi
51
+}
52
+
53
+# Remove container
54
+function cleanup {
55
+	docker rm -fv armada-api-test
56
+}
57
+
58
+trap cleanup EXIT
59
+
60
+create
61
+health_check

+ 1
- 0
tox.ini View File

@@ -22,6 +22,7 @@ commands =
22 22
 
23 23
 [testenv:docs]
24 24
 commands =
25
+    rm -rf doc/build
25 26
     python setup.py build_sphinx
26 27
 
27 28
 [testenv:genconfig]

Loading…
Cancel
Save