-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from deepmind/update-tests
Update tests
- Loading branch information
Showing
44 changed files
with
1,262 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright 2018 The Kapitan Authors | ||
# | ||
# 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. | ||
|
||
"compile tests" | ||
|
||
import unittest | ||
import os | ||
import sys | ||
import shutil | ||
from kapitan.cli import main | ||
from kapitan.utils import get_directory_hash | ||
|
||
class CompileTest(unittest.TestCase): | ||
def setUp(self): | ||
os.chdir(os.getcwd() + '/examples/kubernetes/') | ||
|
||
def test_compile(self): | ||
sys.argv[1] = "compile" | ||
main() | ||
compiled_dir_hash = get_directory_hash(os.getcwd() + '/compiled') | ||
test_compiled_dir_hash = get_directory_hash(os.getcwd() + '/../../tests/test_kubernetes_compiled') | ||
self.assertEqual(compiled_dir_hash, test_compiled_dir_hash) | ||
|
||
def tearDown(self): | ||
compile_path = os.getcwd() + '/compiled' | ||
if os.path.exists(compile_path): | ||
shutil.rmtree(compile_path) | ||
os.chdir(os.getcwd() + '/../../') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Elasticsearch Minikube | ||
|
||
This is a specific version of Elasticsearch to run on a minikube instalation. | ||
|
||
## Prerequisites | ||
|
||
Elasticsearch is a resource hungry application, for this setup we require | ||
that minikube is running with the above options: | ||
|
||
``` | ||
$ minikube start --insecure-registry https://quay.io --memory=4096 --cpus=2 | ||
``` | ||
|
||
_If_ you have created the minikube VM previously, you will most likely need to | ||
delete the vm and recreate it with more memory/cpu. (i.e. | ||
```$ minikube delete```) | ||
|
||
## Setting up | ||
|
||
Assuming you're already running Minikube, setup for this target: | ||
|
||
``` | ||
$ scripts/setup.sh | ||
``` | ||
|
||
This will create a context in your minikube cluster called minikube-es-2. | ||
|
||
|
||
Apply the compiled manifests: | ||
|
||
``` | ||
$ scripts/kubectl.sh apply -f manifests/ | ||
``` | ||
|
||
If the commands above did not error, you should be good to go. | ||
|
||
Let's confirm everything is up: | ||
|
||
``` | ||
$ scripts/kubectl.sh get pods -w | ||
``` | ||
|
||
## Connecting to Elasticsearch | ||
|
||
List the elasticsearch service endpoints running in the cluster: | ||
|
||
``` | ||
$ minikube service -n minikube-es elasticsearch --url | ||
``` | ||
|
||
and curl the health endpoint, i.e.: | ||
```$ curl http://192.168.99.100:32130/_cluster/health?pretty``` | ||
|
||
|
||
## Deleting Elasticsearch | ||
|
||
Deleting is easy (warning, this will remove _everything_): | ||
|
||
``` | ||
$ scripts/kubectl.sh delete -f manifests/ | ||
``` |
67 changes: 67 additions & 0 deletions
67
tests/test_kubernetes_compiled/minikube-es-2/manifests/es-client.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: StatefulSet | ||
metadata: | ||
labels: | ||
name: cluster-client | ||
role: client | ||
name: cluster-client | ||
namespace: minikube-es-2 | ||
spec: | ||
replicas: 2 | ||
serviceName: cluster-client | ||
template: | ||
metadata: | ||
labels: | ||
name: cluster-client | ||
role: client | ||
spec: | ||
containers: | ||
- env: | ||
- name: CLUSTER_NAME | ||
value: cluster | ||
- name: ES_JAVA_OPTS | ||
value: -Xms512m -Xmx512m | ||
- name: HTTP_ENABLE | ||
value: 'true' | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: NODE_DATA | ||
value: 'false' | ||
- name: NODE_INGEST | ||
value: 'false' | ||
- name: NODE_MASTER | ||
value: 'false' | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NUMBER_OF_MASTERS | ||
value: '1' | ||
image: quay.io/pires/docker-elasticsearch-kubernetes:5.5.0 | ||
imagePullPolicy: Always | ||
name: client | ||
ports: | ||
- containerPort: 9200 | ||
name: client | ||
protocol: TCP | ||
- containerPort: 9300 | ||
name: transport | ||
protocol: TCP | ||
securityContext: | ||
capabilities: | ||
add: | ||
- IPC_LOCK | ||
- SYS_RESOURCE | ||
privileged: false | ||
initContainers: | ||
- command: | ||
- sysctl | ||
- -w | ||
- vm.max_map_count=262144 | ||
image: busybox | ||
imagePullPolicy: IfNotPresent | ||
name: sysctl | ||
securityContext: | ||
privileged: true |
64 changes: 64 additions & 0 deletions
64
tests/test_kubernetes_compiled/minikube-es-2/manifests/es-data.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: StatefulSet | ||
metadata: | ||
labels: | ||
name: cluster-data | ||
role: data | ||
name: cluster-data | ||
namespace: minikube-es-2 | ||
spec: | ||
replicas: 2 | ||
serviceName: cluster-data | ||
template: | ||
metadata: | ||
labels: | ||
name: cluster-data | ||
role: data | ||
spec: | ||
containers: | ||
- env: | ||
- name: CLUSTER_NAME | ||
value: cluster | ||
- name: ES_JAVA_OPTS | ||
value: -Xms512m -Xmx512m | ||
- name: HTTP_ENABLE | ||
value: 'false' | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: NODE_DATA | ||
value: 'true' | ||
- name: NODE_INGEST | ||
value: 'false' | ||
- name: NODE_MASTER | ||
value: 'false' | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NUMBER_OF_MASTERS | ||
value: '1' | ||
image: quay.io/pires/docker-elasticsearch-kubernetes:5.5.0 | ||
imagePullPolicy: Always | ||
name: data | ||
ports: | ||
- containerPort: 9300 | ||
name: transport | ||
protocol: TCP | ||
securityContext: | ||
capabilities: | ||
add: | ||
- IPC_LOCK | ||
- SYS_RESOURCE | ||
privileged: false | ||
initContainers: | ||
- command: | ||
- sysctl | ||
- -w | ||
- vm.max_map_count=262144 | ||
image: busybox | ||
imagePullPolicy: IfNotPresent | ||
name: sysctl | ||
securityContext: | ||
privileged: true |
16 changes: 16 additions & 0 deletions
16
tests/test_kubernetes_compiled/minikube-es-2/manifests/es-discovery-svc.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
name: elasticsearch-discovery | ||
name: elasticsearch-discovery | ||
namespace: minikube-es-2 | ||
spec: | ||
ports: | ||
- name: transport | ||
port: 9300 | ||
targetPort: transport | ||
selector: | ||
name: cluster-master | ||
role: master | ||
type: ClusterIP |
19 changes: 19 additions & 0 deletions
19
tests/test_kubernetes_compiled/minikube-es-2/manifests/es-elasticsearch-svc.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
name: elasticsearch | ||
name: elasticsearch | ||
namespace: minikube-es-2 | ||
spec: | ||
ports: | ||
- name: client | ||
port: 9200 | ||
targetPort: client | ||
- name: transport | ||
port: 9300 | ||
targetPort: transport | ||
selector: | ||
name: cluster-client | ||
role: client | ||
type: NodePort |
64 changes: 64 additions & 0 deletions
64
tests/test_kubernetes_compiled/minikube-es-2/manifests/es-master.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
apiVersion: apps/v1beta1 | ||
kind: StatefulSet | ||
metadata: | ||
labels: | ||
name: cluster-master | ||
role: master | ||
name: cluster-master | ||
namespace: minikube-es-2 | ||
spec: | ||
replicas: 2 | ||
serviceName: cluster-master | ||
template: | ||
metadata: | ||
labels: | ||
name: cluster-master | ||
role: master | ||
spec: | ||
containers: | ||
- env: | ||
- name: CLUSTER_NAME | ||
value: cluster | ||
- name: ES_JAVA_OPTS | ||
value: -Xms512m -Xmx512m | ||
- name: HTTP_ENABLE | ||
value: 'false' | ||
- name: NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
- name: NODE_DATA | ||
value: 'false' | ||
- name: NODE_INGEST | ||
value: 'false' | ||
- name: NODE_MASTER | ||
value: 'true' | ||
- name: NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.name | ||
- name: NUMBER_OF_MASTERS | ||
value: '1' | ||
image: quay.io/pires/docker-elasticsearch-kubernetes:5.5.0 | ||
imagePullPolicy: Always | ||
name: master | ||
ports: | ||
- containerPort: 9300 | ||
name: transport | ||
protocol: TCP | ||
securityContext: | ||
capabilities: | ||
add: | ||
- IPC_LOCK | ||
- SYS_RESOURCE | ||
privileged: false | ||
initContainers: | ||
- command: | ||
- sysctl | ||
- -w | ||
- vm.max_map_count=262144 | ||
image: busybox | ||
imagePullPolicy: IfNotPresent | ||
name: sysctl | ||
securityContext: | ||
privileged: true |
Oops, something went wrong.