Skip to content

Commit 7eb82e9

Browse files
author
Amit Kumar Das
authored
fix(recipe): fix issues due to job to recipe change (#100)
This commit has changes that fixes the manifests & code that were still referring to old job custom resource. In addition, this commit provides a way to trigger E to E testing as a make target. This has also been added to github actions to proactively verify any errors injected by changes during the review phase itself. E to E testing make use of local docker registry and K3s to test D-operators' controllers. README has been updated to highlight that fact that D-operators uses itself to perform end to end tests on its controllers. In other words Recipe custom resource is used to test Recipe & other resources. Signed-off-by: AmitKumarDas <[email protected]>
1 parent e71436b commit 7eb82e9

24 files changed

+591
-164
lines changed

.github/workflows/release-docker.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
---
2-
name: Release docker image
2+
name: Release Docker Image
33
on:
44
push:
55
tags:
66
- 'v[0-9]+.[0-9]+.[0-9]+'
77
jobs:
88
release-docker:
9-
name: Release docker image
9+
name: Release Docker Image
1010
runs-on: ubuntu-18.04
1111
steps:
12-
- name: Checkout
12+
- name: Checkout Code
1313
uses: actions/checkout@v2
14-
- name: Deploy docker image
14+
- name: Setup Docker
1515
uses: docker/build-push-action@v1
1616
with:
1717
username: ${{ secrets.DOCKER_USERNAME }}

.github/workflows/test-release.yaml

+28-10
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,57 @@
11
---
2-
name: Test and Release (if on master)
2+
name: Unit Test, E to E Test and Github Release (if on master)
33
on: [push, pull_request]
44
jobs:
5-
tests:
5+
unittest:
66
runs-on: ubuntu-18.04
77
strategy:
88
matrix:
99
test: ['test']
1010
name: ${{ matrix.test }}
1111
steps:
12-
- name: Checkout
12+
- name: Checkout Code
1313
uses: actions/checkout@v2
14-
- name: setup env
14+
- name: Setup GOPATH
1515
run: |
1616
echo "::set-env name=GOPATH::$(go env GOPATH)"
1717
echo "::add-path::$(go env GOPATH)/bin"
18-
- name: Setup go
18+
- name: Setup Golang
1919
uses: actions/setup-go@v1
2020
with:
2121
go-version: 1.13.5
2222
- run: make ${{ matrix.test }}
23+
e2etest:
24+
runs-on: ubuntu-18.04
25+
strategy:
26+
matrix:
27+
test: ['e2e-test']
28+
name: ${{ matrix.test }}
29+
steps:
30+
- name: Checkout Code
31+
uses: actions/checkout@v2
32+
- name: Setup GOPATH
33+
run: |
34+
echo "::set-env name=GOPATH::$(go env GOPATH)"
35+
echo "::add-path::$(go env GOPATH)/bin"
36+
- name: Setup Golang
37+
uses: actions/setup-go@v1
38+
with:
39+
go-version: 1.13.5
40+
- run: sudo make ${{ matrix.test }}
2341
release:
24-
name: Release
42+
name: Make Github Release
2543
runs-on: ubuntu-18.04
26-
needs: ['tests']
44+
needs: ['unittest', 'e2etest']
2745
steps:
28-
- name: Checkout
46+
- name: Checkout Code
2947
uses: actions/checkout@v1
3048
- name: Setup Node.js
3149
uses: actions/setup-node@v1
3250
with:
3351
node-version: 12
34-
- name: Install dependencies
52+
- name: Install NPM Dependencies to Make Release
3553
run: npm install ci
36-
- name: Release
54+
- name: Make Semantic Release
3755
env:
3856
GH_TOKEN: ${{ secrets.PAT }}
3957
run: npx semantic-release

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/vendor/
22
d-operators
33
test/bin/
4-
test/kubebin/
4+
test/kubebin/
5+
test/e2e/uninstall-k3s.txt

Dockerfile

-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ COPY common/ common/
2828
COPY config/ config/
2929
COPY controller/ controller/
3030
COPY pkg/ pkg/
31-
COPY test/ test/
3231
COPY types/ types/
3332

3433
# test d-operators
@@ -65,11 +64,6 @@ COPY controller/ controller/
6564
COPY pkg/ pkg/
6665
COPY types/ types/
6766

68-
# we run the test once again since this is one of the
69-
# ways to remind copying new source packages into this
70-
# build stage
71-
RUN make test
72-
7367
# build binary
7468
RUN make
7569

Makefile

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ test:
4141
testv:
4242
@go test ./... -cover -v -args --logtostderr -v=2
4343

44+
.PHONY: e2e-test
45+
e2e-test:
46+
@cd test/e2e && ./suite.sh
47+
4448
.PHONY: image
4549
image: $(GIT_TAGS)
4650
docker build -t $(IMG_REPO):$(PACKAGE_VERSION) .
4751

48-
4952
.PHONY: push
5053
push: image
51-
docker push $(IMG_REPO):$(PACKAGE_VERSION)
54+
docker push $(IMG_REPO):$(PACKAGE_VERSION

README.md

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,42 @@
1-
## d-operators
1+
## D-operators
22
D-operators define various declarative patterns to write kubernetes controllers. This uses [metac](https://github.com/AmitKumarDas/metac/) under the hood. Users can _create_, _delete_, _update_, _assert_, _patch_, _clone_, & _schedule_ one or more kubernetes resources _(native as well as custom)_ using a yaml file. D-operators expose a bunch of kubernetes custom resources that provide the building blocks to implement a higher order controller.
33

44
D-operators follow a pure intent based approach to writing specifications **instead of** having to deal with yamls that are cluttered with scripts, kubectl, loops, conditions, templating and so on.
55

66
### Programmatic vs. Declarative
7-
It is important to understand that these declarative patterns are built upon programmatic ones. The low level constructs _(read native k8s resources & custom resources)_ might be implemented in programming language(s) of one's choice. Use d-controller's YAMLs to aggregate these low level resources in a particular way to build a completely new kubernetes controller.
7+
It is important to understand that these declarative patterns are built upon programmatic ones. The low level constructs _(read native Kubernetes resources & custom resources)_ might be implemented in programming language(s) of one's choice. Use d-controller's YAMLs to aggregate these low level resources in a particular way to build a completely new kubernetes controller.
88

9-
### When to use d-operators
10-
D-operators is not meant to build complex controllers like Deployment, StatefulSet or Pod in a declarative yaml. However, if one needs to use Deployment, StatefulSet, Pod, etc. to build new k8s controller(s) then d-operators' declarative constructs _(read custom resources)_ should be considered to build one.
9+
### When to use D-operators
10+
D-operators is not meant to build complex controller logic like Deployment, StatefulSet or Pod in a declarative yaml. However, if one needs to use available Kubernetes resources to build new k8s controller(s) then d-operators should be considered to build one. D-operators helps implement the last mile automation needed to manage applications & infrastructure in Kubernetes clusters.
1111

12-
However, any controller which is complex and at the same time is **generic** enough to be used along with other kubernetes resources, can be implemented as a core d-operator custom resource.
12+
### E to E testing
13+
D-operators make use of d-operators _(i.e. its own self)_ to test its controllers. It does not need kubectl, bash, sed, awk etc to test its controllers. In addition, it does not depend on writing go code to write tests. It makes use of declarative YAMLs to test its controllers.
1314

14-
### Available controllers
15+
_NOTE: One can make use of these YAMLs (kind: Recipe) to test any Kubernetes controllers declaratively_
16+
17+
Navigate to test/experiments to learn more on these YAMLs.
18+
19+
```sh
20+
# Following runs the e2e test suite
21+
#
22+
# NOTE: test/e2e/suite.sh does the following:
23+
# - d-operators' image known as 'dope' is built
24+
# - a docker container is started & acts as the image registry
25+
# - dope image is pushed to this image registry
26+
# - k3s is installed with above image registry
27+
# - d-operators' manifests are applied
28+
# - experiments _(i.e. test code written as YAMLs)_ are applied
29+
# - experiments are asserted
30+
# - if all experiments pass then e2e is a success else it failed
31+
# - k3s is un-installed
32+
# - local image registry is stopped
33+
sudo make e2e-test
34+
```
35+
36+
### Available Kubernetes controllers
1537
- [x] kind: Recipe
1638
- [ ] kind: HTTP
17-
- [ ] kind: Chef
39+
- [ ] kind: HTTPPipe
1840
- [ ] kind: Command
1941
- [ ] kind: DaemonJob
20-
- [ ] kind: MasterChef
42+
- [ ] kind: UberLoop

config/metac.yaml

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
apiVersion: metac.openebs.io/v1alpha1
22
kind: GenericController
33
metadata:
4-
name: sync-job
4+
name: sync-recipe
55
namespace: dope
66
spec:
7-
watch:
8-
apiVersion: metacontroller.app/v1
9-
resource: jobs
7+
watch: # kind: Recipe custom resource is watched
8+
apiVersion: dope.metacontroller.io/v1
9+
resource: recipes
1010
hooks:
1111
sync:
1212
inline:
13-
funcName: sync/job
13+
funcName: sync/recipe
1414
---

0 commit comments

Comments
 (0)