Skip to content

Commit

Permalink
chore: separate search fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jul 27, 2023
1 parent 3f9ed9d commit 63f2f6b
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 190 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- minimal --skip-all
- k8s
- datasources
- search
- git
# - restic
runs-on: ubuntu-latest
Expand Down
9 changes: 0 additions & 9 deletions fixtures/datasources/_post_setup.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
#!/bin/bash

echo "Running kubectl wait for elasticsearch"
kubectl -n default wait --for=condition=ready pod -l app=elasticsearch --timeout=5m

echo "Fetching elastic search health";
curl -s "http://elasticsearch.default.svc.cluster.local:9200/_cluster/health" -H 'Content-Type: application/json';
curl -s "http://elasticsearch.default.svc.cluster.local:9200/_cluster/allocation/explain" -H 'Content-Type: application/json';

echo "Fetching populate-db logs from elasticsearch pod";
kubectl logs -n default -l app=elasticsearch -c populate-db
177 changes: 0 additions & 177 deletions fixtures/datasources/_setup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -580,183 +580,6 @@ metadata:
namespace: default
---
apiVersion: v1
kind: Secret
metadata:
name: search
namespace: default
stringData:
OPENSEARCH_USERNAME: admin
OPENSEARCH_PASSWORD: secret
ELASTIC_SEARCH_USERNAME: admin
ELASTIC_SEARCH_PASSWORD: secret
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: elasticsearch
name: elasticsearch
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:8.1.3
env:
- name: ES_JAVA_OPTS
value: "-Xms256m -Xmx256m"
- name: network.bind_host
value: 0.0.0.0
- name: network.host
value: 0.0.0.0
- name: discovery.type
value: single-node
- name: xpack.security.enabled
value: "false"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9200
name: http
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
readinessProbe:
httpGet:
path: /
port: 9200
initialDelaySeconds: 10
- name: populate-db
image: ellerbrock/alpine-bash-curl-ssl
command: ["/bin/sh", "-c"]
readinessProbe:
exec:
command:
- ls
- /tmp/done
args:
# We install wait-for-it and wait for elasticsearch to be ready and then
# populate it with dummy data
- >
echo "Starting Elasticsearch";
curl -s https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -o wait-for-it.sh;
chmod +x wait-for-it.sh; ./wait-for-it.sh localhost:9200 --timeout=0;
printf "\nWaiting for cluster status to be green\n";
curl -s -X GET "localhost:9200/_cluster/health?wait_for_status=green&wait_for_active_shards=all&timeout=2m" -H 'Content-Type: application/json';
printf "\nCreating new index\n";
curl -s -X PUT localhost:9200/index;
printf "\nReducing replicas to 0\n";
curl -s -X PUT "localhost:9200/index/_settings" -H 'Content-Type: application/json' -d '{"index" : {"number_of_replicas" : 0}}';
print "\nGetting Health data\n";
curl -s "localhost:9200/_cluster/health" -H 'Content-Type: application/json';
curl -s "localhost:9200/_cluster/allocation/explain" -H 'Content-Type: application/json';
printf "\nInserting dummy data\n";
curl -s -X POST localhost:9200/index/_doc -d '{"system": {"role": "api"}}' -H 'Content-Type: application/json';
printf "\nCreating /tmp/done\n";
touch /tmp/done;
sleep 365d;
---
apiVersion: v1
kind: Service
metadata:
name: elasticsearch
namespace: default
spec:
ports:
- name: elasticsearch
port: 9200
targetPort: 9200
protocol: TCP
selector:
app: elasticsearch
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: opensearch
name: opensearch
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: opensearch
template:
metadata:
labels:
app: opensearch
spec:
containers:
- name: opensearch
image: opensearchproject/opensearch:2.7.0
env:
- name: ES_JAVA_OPTS
value: "-Xms256m -Xmx256m"
- name: network.bind_host
value: 0.0.0.0
- name: network.host
value: 0.0.0.0
- name: discovery.type
value: single-node
- name: DISABLE_SECURITY_PLUGIN
value: "true"
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9200
name: http
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
readinessProbe:
httpGet:
path: /
port: 9200
initialDelaySeconds: 10
- name: populate-db
image: debian:bookworm
command: ["/bin/sh", "-c"]
readinessProbe:
exec:
command:
- ls
- /tmp/done
args:
# We install wait-for-it and wait for elasticsearch to be ready and then
# populate it with dummy data
- >
apt update && apt install -y curl;
curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -o wait-for-it.sh;
chmod +x wait-for-it.sh; ./wait-for-it.sh localhost:9200 --timeout=0;
curl -X PUT localhost:9200/index;
curl -X POST localhost:9200/index/_doc -d '{"system": {"role": "api", "version": "v1.0"}}' -H 'Content-Type: application/json';
touch /tmp/done;
sleep infinity
---
apiVersion: v1
kind: Service
metadata:
name: opensearch
namespace: default
spec:
ports:
- name: opensearch
port: 9200
targetPort: 9200
protocol: TCP
selector:
app: opensearch
---
apiVersion: v1
kind: Namespace
metadata:
name: ldap
Expand Down
4 changes: 0 additions & 4 deletions fixtures/datasources/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,4 @@ resources:
- prometheus.yaml
- redis_fail.yaml
- redis_pass.yaml
- elasticsearch_fail.yaml
- elasticsearch_pass.yaml
- opensearch_fail.yaml
- opensearch_pass.yaml
- alertmanager_fail.yaml
11 changes: 11 additions & 0 deletions fixtures/search/_post_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

echo "Running kubectl wait for elasticsearch"
kubectl -n default wait --for=condition=ready pod -l app=elasticsearch --timeout=5m

echo "Fetching elastic search health";
curl -s "http://elasticsearch.default.svc.cluster.local:9200/_cluster/health" -H 'Content-Type: application/json';
curl -s "http://elasticsearch.default.svc.cluster.local:9200/_cluster/allocation/explain" -H 'Content-Type: application/json';

echo "Fetching populate-db logs from elasticsearch pod";
kubectl logs -n default -l app=elasticsearch -c populate-db
Loading

0 comments on commit 63f2f6b

Please sign in to comment.