Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
- nginx
- node
- python
- elasticsearch
- opensearch
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ spec:
afterBuildScript:
rawData: |
#!/bin/bash -ex
curl -k -X POST https://elasticsearch:9200/test/_bulk -H 'Content-Type: application/json' --data-binary @index.json
curl -k -X POST https://opensearch:9200/test/_bulk -H 'Content-Type: application/json' --data-binary @index.json

repoURL: https://github.com/neco-test/honkit-sample.git
branch: main
Expand Down
6 changes: 0 additions & 6 deletions containers/elasticsearch/Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion containers/elasticsearch/TAG

This file was deleted.

6 changes: 6 additions & 0 deletions containers/opensearch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM opensearchproject/opensearch:2.19.7@sha256:3bfa1ec74d56928c2e018033d45c460ce2c0ea65a5cedd577de3102326c31b89

LABEL org.opencontainers.image.source=https://github.com/cybozu-go/website-operator

RUN opensearch-plugin install --batch analysis-kuromoji \
&& opensearch-plugin install --batch analysis-icu
1 change: 1 addition & 0 deletions containers/opensearch/TAG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.19.7.1
3 changes: 3 additions & 0 deletions e2e/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ test: launch-kind load-images setup-cluster
kustomize build ./manifests/manager | kubectl apply -f -
kubectl wait pod -l control-plane=controller-manager -n website-operator-system --for condition=Ready --timeout 180s
kustomize build ./manifests/website | kubectl apply -f -
kubectl apply -f ./manifests/sample/opensearch.yaml
kubectl rollout status statefulset/honkit-search -n default --timeout 300s
kustomize build ./manifests/sample | kubectl apply -f -
env E2E_TEST=1 go test -count=1 -v . -args -ginkgo.v -ginkgo.fail-fast

# Build all artifacts for the architecture of the host machine and load them into the kind cluster.
Expand Down
31 changes: 31 additions & 0 deletions e2e/bootstrap_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package e2e

import (
"encoding/json"
"errors"
"fmt"
"net/http"
Expand Down Expand Up @@ -77,4 +78,34 @@ func testBootstrap() {
It("should launch mkdocs-sample", func() {
testWebSite("mkdocs-sample")
})

It("should launch honkit-sample-es and register search index to OpenSearch", func() {
testWebSite("honkit-sample-es")

By("querying the search index via HTTPProxy")
req, err := http.NewRequest(http.MethodGet, "http://127.0.0.1/es/honkit-sample-es-*/_count", nil)
Expect(err).ShouldNot(HaveOccurred())
req.Host = "honkit-sample-es.default.example.com"
client := http.Client{}
Eventually(func() error {
res, err := client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return fmt.Errorf("status should be ok: %s", res.Status)
}
var result struct {
Count int `json:"count"`
}
if err := json.NewDecoder(res.Body).Decode(&result); err != nil {
return err
}
if result.Count == 0 {
return errors.New("search index should have documents")
}
return nil
}, 30*time.Second).Should(Succeed())
})
}
17 changes: 0 additions & 17 deletions e2e/manifests/manager/create-honkit-es-index.sh

This file was deleted.

22 changes: 22 additions & 0 deletions e2e/manifests/manager/create-honkit-search-index.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash -ex
cd $HOME
rm -rf $REPO_NAME
git clone $REPO_URL
cd $REPO_NAME
git checkout $REVISION

sed -i -e "/host/c\ \"host\": \"http://${RESOURCE_NAME}.${RESOURCE_NAMESPACE}.example.com/es\"," book.js
sed -i -e "/index/c\ \"index\": \"${RESOURCE_NAME}-${REVISION}\"," book.js

pnpm config set registry https://npm.flatt.tech/
pnpm install --frozen-lockfile
pnpm run build

INDEX_URL=${SEARCH_HOST}/${RESOURCE_NAME}-${REVISION}
curl -sS -X DELETE "${INDEX_URL}?ignore_unavailable=true"
curl -sSf -X PUT "${INDEX_URL}" -H 'Content-Type: application/json' -d @mappings.json
RESULT=$(curl -sSf -X POST "${INDEX_URL}/_bulk?refresh=true" -H 'Content-Type: application/json' --data-binary @_book/search_index.json)
if echo "${RESULT}" | grep -q '"errors":true'; then
echo "${RESULT}"
exit 1
fi
2 changes: 1 addition & 1 deletion e2e/manifests/manager/httpproxy-es.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
- conditions:
- prefix: /es
services:
- name: honkit-es
- name: honkit-search
port: 9200
pathRewritePolicy:
replacePrefix:
Expand Down
2 changes: 1 addition & 1 deletion e2e/manifests/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ configMapGenerator:
- name: after-build-scripts
files:
- after-build-honkit.sh
- create-honkit-es-index.sh
- create-honkit-search-index.sh
4 changes: 2 additions & 2 deletions e2e/manifests/sample/build-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ metadata:
name: build-secret
namespace: default
type: Opaque
data:
ELASTIC_HOST: aHR0cDovL2hvbmtpdC1lczo5MjAw # http://honkit-es:9200
stringData:
SEARCH_HOST: http://honkit-search:9200
60 changes: 0 additions & 60 deletions e2e/manifests/sample/elasticsearch.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions e2e/manifests/sample/honkit-es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ spec:
key: build-honkit.sh
buildSecrets:
- name: build-secret
key: ELASTIC_HOST
key: SEARCH_HOST
repoURL: https://github.com/neco-test/honkit-sample.git
afterBuildScript:
configMap:
name: after-build-scripts
key: create-honkit-es-index.sh
key: create-honkit-search-index.sh
branch: main
extraResources:
- configMap:
Expand Down
2 changes: 1 addition & 1 deletion e2e/manifests/sample/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- elasticsearch.yaml
- opensearch.yaml
- honkit-es.yaml
- build-secret.yaml
69 changes: 69 additions & 0 deletions e2e/manifests/sample/opensearch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app.kubernetes.io/name: opensearch
app.kubernetes.io/instance: honkit-search
name: honkit-search
namespace: default
spec:
replicas: 1
serviceName: honkit-search
selector:
matchLabels:
app.kubernetes.io/name: opensearch
app.kubernetes.io/instance: honkit-search
template:
metadata:
labels:
app.kubernetes.io/name: opensearch
app.kubernetes.io/instance: honkit-search
spec:
containers:
- env:
- name: OPENSEARCH_JAVA_OPTS
value: -Xms1g -Xmx1g
- name: discovery.type
value: single-node
# Disable the security plugin so that indices can be created over plain HTTP without credentials.
- name: DISABLE_SECURITY_PLUGIN
value: "true"
- name: DISABLE_INSTALL_DEMO_CONFIG
value: "true"
image: ghcr.io/cybozu-go/website-operator-opensearch:dev
imagePullPolicy: IfNotPresent
name: opensearch
ports:
- containerPort: 9200
name: http
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
readinessProbe:
httpGet:
path: /_cluster/health?wait_for_status=yellow&timeout=1s
port: http
periodSeconds: 5
resources:
limits:
memory: 2Gi
requests:
cpu: 500m
memory: 2Gi
---
apiVersion: v1
kind: Service
metadata:
labels:
app.kubernetes.io/name: opensearch
app.kubernetes.io/instance: honkit-search
name: honkit-search
namespace: default
spec:
ports:
- port: 9200
name: http
selector:
app.kubernetes.io/name: opensearch
app.kubernetes.io/instance: honkit-search
Loading