Skip to content

Instantly share code, notes, and snippets.

View lordofthejars's full-sized avatar
🏠
Working from home

Alex Soto lordofthejars

🏠
Working from home
View GitHub Profile
oc/kubectl create -f deploy/crds/hello_v1alpha1_hello_crd.yaml
#change lordofthejars to your docker hub account
operator-sdk build lordofthejars/hello-operator:v0.0.1
docker push lordofthejars/hello-operator:v0.0.1
func (r *ReconcileHello) Reconcile(request reconcile.Request) (reconcile.Result, error) {
reqLogger := log.WithValues("Request.Namespace", request.Namespace, "Request.Name", request.Name)
reqLogger.Info("Reconciling Hello")
// Fetch the Hello instance
instance := &hellov1alpha1.Hello{}
err := r.client.Get(context.TODO(), request.NamespacedName, instance)
...
// Define a new Pod object
// HelloSpec defines the desired state of Hello
type HelloSpec struct {
Message string `json:"message"`
}
// HelloStatus defines the observed state of Hello
type HelloStatus struct {
Nodes []string `json:"nodes"`
}
operator-sdk add api --api-version=hello.lordofthejars.com/v1alpha1 --kind=Hello
mkdir -p $GOPATH/src/github.com/lordofthejars/
cd $GOPATH/src/github.com/lordofthejars/
operator-sdk new hello-operator
cd hello-operator
minishift config set memory 8GB
minishift config set cpus 2
minishift config set image-caching true
minishift config set openshift-version v3.11.0
minishift addon enable admin-user
minishift addon enable anyuid
minishift start
apiVersion: v1
kind: Pod
metadata:
name: whalesay
spec:
containers:
- name: whalesay
image: docker/whalesay
imagePullPolicy: "IfNotPresent"
command: ["cowsay","Hello Alex"]
sudo: required
services:
- docker
addons:
apt:
sources:
- git-core
packages:
- git
@RunWith(Arquillian.class)
@Function(value = "file:src/test/resources/echo.jar", name = "echo", main = "org.projectodd.Echo")
public class EchoTest {
@ArquillianResource
OWskClient client;
@Test
public void should_invoke_echo() {
Ok, I understand your problem, in fact we found it several times, and this is how we tackle:
We have A->B->C and we want to validate contract between A and B, so we do not have to worry about B->C
So Consumer side (A) uses an stub to validate that it can communicate with B
Provider B part we just replay the contract (generated by A) to validate that is able to produce correct output. But then what's happening with C?
Do we need to boot up C in B? The answer is no, it is not necessary. You can use Service virtualization (or contract generated by C) to simulate interactions between B and C.
So when validating the provider side in contract testing of B you virtualize C so you do not need to worry about how to boot up C.