Skip to content
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
OPERATOR_SDK_VERSION: v0.12.0
steps:

- uses: actions/checkout@v1

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Install modules
run: go mod download

- name: Install operator-sdk
run: |
curl -LO https://github.com/operator-framework/operator-sdk/releases/download/${OPERATOR_SDK_VERSION}/operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu
chmod +x ./operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu

- name: Build operator
run: ./operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu build tarantool/tarantool-operator:${GITHUB_SHA}

- name: Setup test kubernetes cluster
uses: helm/kind-action@v1.0.0-rc.1
with:
cluster_name: kind

- name: Load operator image into test cluster
run: kind load docker-image tarantool/tarantool-operator:${GITHUB_SHA}

- name: Create CRDs
run: |
kubectl create \
-f deploy/crds/tarantool_v1alpha1_cluster_crd.yaml \
-f deploy/crds/tarantool_v1alpha1_replicasettemplate_crd.yaml \
-f deploy/crds/tarantool_v1alpha1_role_crd.yaml

- name: Test
run: |
./operator-sdk-${OPERATOR_SDK_VERSION}-x86_64-linux-gnu test local \
--image tarantool/tarantool-operator:${GITHUB_SHA} \
./test/e2e
2 changes: 1 addition & 1 deletion deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ spec:
image: tarantool/tarantool-operator:0.0.2
command:
- tarantool-operator
imagePullPolicy: Always
imagePullPolicy: IfNotPresent
env:
- name: WATCH_NAMESPACE
valueFrom:
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/tarantool/tarantool-operator

require (
github.com/ghodss/yaml v1.0.0
github.com/go-openapi/spec v0.19.0
github.com/google/uuid v1.1.1
github.com/machinebox/graphql v0.2.2
Expand Down Expand Up @@ -32,3 +33,5 @@ replace (
sigs.k8s.io/controller-runtime => sigs.k8s.io/controller-runtime v0.1.10
sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.1.11-0.20190411181648-9d55346c2bde
)

go 1.13
7 changes: 7 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ github.com/Azure/go-autorest v11.1.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSW
github.com/Azure/go-autorest v11.5.2+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
github.com/Azure/go-autorest v11.7.0+incompatible h1:gzma19dc9ejB75D90E5S+/wXouzpZyA+CV+/MJPSD/k=
github.com/Azure/go-autorest v11.7.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/MakeNowJust/heredoc v0.0.0-20171113091838-e9091a26100e/go.mod h1:64YHyfSL2R96J44Nlwm39UHepQbyR5q10x7iYa1ks2E=
github.com/Masterminds/goutils v1.1.0/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU=
Expand Down Expand Up @@ -80,6 +81,7 @@ github.com/emicklei/go-restful v2.9.3+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT
github.com/emicklei/go-restful-swagger12 v0.0.0-20170926063155-7524189396c6/go.mod h1:qr0VowGBT4CS4Q8vFF8BSeKz34PuqKGxs/L0IAQA9DQ=
github.com/evanphx/json-patch v3.0.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v4.0.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc=
github.com/evanphx/json-patch v4.1.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4=
github.com/fatih/camelcase v1.0.0/go.mod h1:yN2Sb0lFhZJUdVvtELVWefmrXpuZESvPmqwoZc+/fpc=
Expand Down Expand Up @@ -197,6 +199,7 @@ github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJ
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI=
github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
Expand All @@ -212,6 +215,7 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v0.0.0-20180402223658-b729f2633dfe/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
Expand All @@ -236,6 +240,7 @@ github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsO
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/maxbrunsfeld/counterfeiter v0.0.0-20181017030959-1aadac120687/go.mod h1:aoVsckWnsNzazwF2kmD+bzgdr4GBlbK91zsdivQJ2eU=
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
Expand Down Expand Up @@ -314,12 +319,14 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.1.1/go.mod h1:zrgwTnHtNr00buQ1vSptGe8m1f/BbgsPukg8qsT7A+A=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc=
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v0.0.3 h1:ZlrZ4XsMRm04Fr5pSFxBgfND2EBVa1nLpiy1stUsX/8=
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
Expand Down
21 changes: 21 additions & 0 deletions test/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Tarantool Operator end-2-end tests

Testing strategy:

1. provision kubernetes resources from YAML manifest

1. act on provisioned resources

1. assert expected system state

1. clean up

Some conventions:

1. setup manifests located under `scenario` dir

1. tests must be independent and no reliance on previous tests allowed

1. tests must be able to run in parallel each test in it's own namespace

1. each setup manifest must be written in a way that allows to use it without tests
11 changes: 11 additions & 0 deletions test/e2e/main_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package e2e

import (
"testing"

f "github.com/operator-framework/operator-sdk/pkg/test"
)

func TestMain(m *testing.M) {
f.MainEntry(m)
}
191 changes: 191 additions & 0 deletions test/e2e/scenario/basic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
apiVersion: tarantool.io/v1alpha1
kind: Cluster
metadata:
name: examples-kv-cluster
spec:
selector:
matchLabels:
tarantool.io/cluster-id: "examples-kv-cluster"
---
apiVersion: tarantool.io/v1alpha1
kind: Role
metadata:
name: storage
namespace: default
labels:
tarantool.io/cluster-id: "examples-kv-cluster"
tarantool.io/role: "storage"
spec:
selector:
matchLabels:
tarantool.io/replicaset-template: "storage-template"
numReplicasets: 1
---
apiVersion: tarantool.io/v1alpha1
kind: Role
metadata:
name: routers
namespace: default
labels:
tarantool.io/cluster-id: "examples-kv-cluster"
tarantool.io/role: "router"
spec:
selector:
matchLabels:
tarantool.io/replicaset-template: "router-template"
numReplicasets: 1
---
apiVersion: tarantool.io/v1alpha1
kind: ReplicasetTemplate
metadata:
name: storage-template
labels:
tarantool.io/cluster-id: "examples-kv-cluster"
tarantool.io/replicaset-template: "storage-template"
tarantool.io/role: "storage"
spec:
replicas: 1
selector:
matchLabels:
tarantool.io/pod-template: "storage-pod-template"
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
template:
metadata:
labels:
tarantool.io/cluster-id: "examples-kv-cluster"
tarantool.io/pod-template: "storage-pod-template"
spec:
terminationGracePeriodSeconds: 10
dnsConfig:
options:
- name: ndots
value: "1"
containers:
- name: pim-storage
image: tarantool/tarantool-operator-examples-kv:0.0.2
volumeMounts:
- mountPath: "/var/lib/tarantool"
name: www
ports:
- containerPort: 3301
- containerPort: 8081
env:
- name: TARANTOOL_INSTANCE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: TARANTOOL_WORK_DIR
value: "/var/lib/tarantool"
- name: TARANTOOL_MEMTX_MEMORY
value: "33554432"
- name: TARANTOOL_LOG
value: "/dev/stdout"
- name: TARANTOOL_ADVERTISE_HOST
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: TARANTOOL_ADVERTISE_URI
value: "$(TARANTOOL_ADVERTISE_HOST).examples-kv-cluster:3301"
---
apiVersion: tarantool.io/v1alpha1
kind: ReplicasetTemplate
metadata:
name: router-template
labels:
tarantool.io/cluster-id: "examples-kv-cluster"
tarantool.io/replicaset-template: "router-template"
tarantool.io/role: "router"
spec:
replicas: 1
selector:
matchLabels:
tarantool.io/pod-template: "router-pod-template"
volumeClaimTemplates:
- metadata:
name: www
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
template:
metadata:
labels:
tarantool.io/cluster-id: "examples-kv-cluster"
tarantool.io/pod-template: "router-pod-template"
spec:
terminationGracePeriodSeconds: 10
dnsConfig:
options:
- name: ndots
value: "1"
containers:
- name: pim-router
image: tarantool/tarantool-operator-examples-kv:0.0.2
volumeMounts:
- mountPath: "/var/lib/tarantool"
name: www
ports:
- containerPort: 3301
- containerPort: 8081
env:
- name: TARANTOOL_INSTANCE_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: TARANTOOL_WORK_DIR
value: "/var/lib/tarantool"
- name: TARANTOOL_MEMTX_MEMORY
value: "33554432"
- name: TARANTOOL_LOG
value: "/dev/stdout"
- name: TARANTOOL_ADVERTISE_HOST
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: TARANTOOL_ADVERTISE_URI
value: "$(TARANTOOL_ADVERTISE_HOST).examples-kv-cluster:3301"
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: examples-kv-topology
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
rules:
- http:
paths:
- backend:
serviceName: router
servicePort: 8081
path: /kv
- backend:
serviceName: router
servicePort: 8081
path: /kv_dump
- backend:
serviceName: router
servicePort: 8081
path: /
---
apiVersion: v1
kind: Service
metadata:
name: router
labels:
tarantool.io/role: "router"
spec:
ports:
- port: 8081
name: web
protocol: TCP
selector:
tarantool.io/role: "router"
Loading