Skip to content

Commit

Permalink
Concise documentation (#96)
Browse files Browse the repository at this point in the history
* redo documentation

* change acct

* typo

* Update README.md

* Update README.md

* Update README.md

* Update README.md
  • Loading branch information
eytan-avisror authored May 12, 2020
1 parent a80898d commit 8d1a5e5
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 2,271 deletions.
119 changes: 40 additions & 79 deletions .github/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,29 @@

This document will walk you through setting up a basic testing environment, running unit tests or e2e functional tests.

## Setup EKS cluster

- Make sure you have access and valid credentials to an AWS account

- Run [setup.sh](../tests-bdd/setup/setup.sh) with appropriate flags.

### Example

```bash
$ ./setup.sh --region us-west-2 \
--vpc-id vpc-EXAMPLE6c75dd646 \
--cluster-name my-eks-cluster \
--ami-id ami-03a55127c613349a7 \
--cluster-subnets subnet-EXAMPLE2673de5e4,subnet-EXAMPLE4ad6eb0f5,subnet-EXAMPLE3ce858b2a \
--node-subnets subnet-EXAMPLEe074c46580,subnet-EXAMPLEd2673de5e4,subnet-EXAMPLE5fd80af561 \
--keypair-name MyKeyPair \
--template-path /absolute/path/to/instance-manager/docs/cloudformation \
create
```

## Running locally

Using the `Makefile` you can use `make run` to run instance-manager locally on your machine, and it will try to reconcile InstanceGroups in the cluster.
Make sure the context you are in is correct and that you scaled down the actual instance-manager controller pod.

1. You need to create 2 files(controller.conf and cloudformation.template) for controller config and cfn and copy controller.conf and cloudformation.template section from the data section from #config/crd/bases/instance-manager-configmap.yaml respectively
2. Make sure you have AWS Credentials and region exported so that your local instance-manager controller can execute a cloud formation template
Using the `Makefile` you can use `make run` to run instance-manager locally on your machine, and it will try to reconcile InstanceGroups in the cluster - if you do this, make sure another controller is not running in your cluster already to avoid conflict.

Make sure you have AWS credentials and a region exported so that your local instance-manager controller can make the required API calls.

### Example

```bash
$ kubectl scale deployment instance-manager --replicas 0
deployment.extensions/instance-manager scaled


$ make run
/Users/eibissror/go/bin/controller-gen object:headerFile=./hack/boilerplate.go.txt paths=./api/...
go fmt ./...
go vet ./...
go run ./main.go
2019-07-15T10:07:57.650-0700 INFO controller-runtime.controller Starting EventSource {"controller": "instancegroup", "source": "kind source: /, Kind="}
2019-07-15T10:07:57.650-0700 INFO setup starting manager
2019-07-15T10:07:57.751-0700 INFO controller-runtime.controller Starting Controller {"controller": "instancegroup"}
2019-07-15T10:07:57.851-0700 INFO controller-runtime.controller Starting workers {"controller": "instancegroup", "worker count": 1}
2020-05-12T01:43:05.970-0700 INFO controller-runtime.metrics metrics server is starting to listen {"addr": ":8080"}
2020-05-12T01:43:06.047-0700 INFO setup starting manager
2020-05-12T01:43:06.047-0700 INFO controller-runtime.manager starting metrics server {"path": "/metrics"}
2020-05-12T01:43:06.047-0700 INFO controller-runtime.controller Starting EventSource {"controller": "instancegroup", "source": "kind source: /, Kind="}
2020-05-12T01:43:06.150-0700 INFO controller-runtime.controller Starting EventSource {"controller": "instancegroup", "source": "kind source: /, Kind="}
2020-05-12T01:43:06.255-0700 INFO controller-runtime.controller Starting Controller {"controller": "instancegroup"}
2020-05-12T01:43:06.255-0700 INFO controller-runtime.controller Starting workers {"controller": "instancegroup", "worker count": 5}
```

## Running unit tests
Expand All @@ -57,46 +35,23 @@ Using the `Makefile` you can run basic unit tests.

```bash
$ make test

go fmt ./...
go vet ./...
/Users/eibissror/go/bin/controller-gen "crd:trivialVersions=true" rbac:roleName=instance-manager webhook paths="./api/...;./controllers/..." output:crd:artifacts:config=config/crd/bases
go test -v ./controllers/... -coverprofile coverage.txt
? github.com/keikoproj/instance-manager/controllers [no test files]
? github.com/keikoproj/instance-manager/controllers/common [no test files]
? github.com/keikoproj/instance-manager/controllers/providers/aws [no test files]
=== RUN TestStateDiscoveryInitUpdate
--- PASS: TestStateDiscoveryInitUpdate (0.00s)
=== RUN TestStateDiscoveryReconcileModifying
--- PASS: TestStateDiscoveryReconcileModifying (0.00s)
=== RUN TestStateDiscoveryReconcileInitCreate
--- PASS: TestStateDiscoveryReconcileInitCreate (0.00s)
=== RUN TestStateDiscoveryInitDeleting
--- PASS: TestStateDiscoveryInitDeleting (0.00s)
=== RUN TestStateDiscoveryReconcileDelete
--- PASS: TestStateDiscoveryReconcileDelete (0.00s)
=== RUN TestStateDiscoveryDeleted
--- PASS: TestStateDiscoveryDeleted (0.00s)
=== RUN TestStateDiscoveryDeletedExist
--- PASS: TestStateDiscoveryDeletedExist (0.00s)
=== RUN TestStateDiscoveryUpdateRecoverableError
--- PASS: TestStateDiscoveryUpdateRecoverableError (0.00s)
=== RUN TestStateDiscoveryUnrecoverableError
--- PASS: TestStateDiscoveryUnrecoverableError (0.00s)
=== RUN TestStateDiscoveryUnrecoverableErrorDelete
--- PASS: TestStateDiscoveryUnrecoverableErrorDelete (0.00s)
=== RUN TestNodeBootstrappingCreateConfigMap
--- PASS: TestNodeBootstrappingCreateConfigMap (0.00s)
=== RUN TestNodeBootstrappingUpdateConfigMap
--- PASS: TestNodeBootstrappingUpdateConfigMap (0.00s)
=== RUN TestNodeBootstrappingUpdateConfigMapWithExistingMembers
--- PASS: TestNodeBootstrappingUpdateConfigMapWithExistingMembers (0.00s)
=== RUN TestNodeBootstrappingRemoveMembers
--- PASS: TestNodeBootstrappingRemoveMembers (0.00s)
=== RUN TestCrdStrategyCRExist
--- PASS: TestCrdStrategyCRExist (0.00s)
? github.com/keikoproj/instance-manager/controllers/common [no test files]
? github.com/keikoproj/instance-manager/controllers/providers/aws [no test files]
? github.com/keikoproj/instance-manager/controllers/providers/kubernetes [no test files]
? github.com/keikoproj/instance-manager/controllers/provisioners [no test files]
PASS
coverage: 72.6% of statements
ok github.com/keikoproj/instance-manager/controllers/provisioners/ekscloudformation 5.352s coverage: 72.6% of statements
coverage: 86.5% of statements
ok github.com/keikoproj/instance-manager/controllers/provisioners/eks 0.472s coverage: 86.5% of statements
coverage: 81.0% of statements
ok github.com/keikoproj/instance-manager/controllers/provisioners/eksmanaged 0.785s coverage: 81.0% of statements
```

You can use `make vtest` to run test with verbose logging, you can also run `make coverage` to generate a coverage report.
You can also run `make coverage` to generate a coverage report.

## Running BDD tests

Expand All @@ -105,30 +60,36 @@ Export some variables and run `make bdd` to run a functional e2e test.
### Example

```bash
export EKS_CLUSTER=my-eks-cluster
export AWS_REGION=us-west-2
export KUBECONFIG=~/.kube/config

export EKS_CLUSTER=my-eks-cluster
export KEYPAIR_NAME=MyKeyPair
export VPC_ID=vpc-EXAMPLE23dk9
export STABLE_AMI=ami-EXAMPLEdk93
export LATEST_AMI=ami-EXAMPLE2e09
export AMI_ID=ami-EXAMPLEdk93
export SECURITY_GROUPS=sg-EXAMPLE2323,sg-EXAMPLE4433
export SUBNETS=subnet-EXAMPLE223d,subnet-EXAMPLEdkkf,subnet-EXAMPLEkkr9

$ make bdd

=== RUN TestE2e
Running Suite: InstanceGroup Type Suite
=======================================
Random Seed: 1563208279
Will run 4 of 4 specs
Feature: CRUD Create
In order to create instance-groups
As an EKS cluster operator
I need to submit the custom resource

Scenario: Resources can be submitted # features/01_create.feature:6
Given an EKS cluster # main_test.go:125 -> *FunctionalTest
Then I create a resource instance-group.yaml # main_test.go:165 -> *FunctionalTest
And I create a resource instance-group-crd.yaml # main_test.go:165 -> *FunctionalTest
And I create a resource instance-group-managed.yaml # main_test.go:165 -> *FunctionalTest

...
...

Ran 4 of 4 Specs in 635.904 seconds
SUCCESS! -- 4 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestE2e (635.90s)
15 scenarios (15 passed)
72 steps (72 passed)
22m40.347700419s
testing: warning: no tests to run
PASS
ok github.com/keikoproj/instance-manager/test-bdd 636.198s
ok github.com/keikoproj/instance-manager/test-bdd 1362.336s [no tests to run]
```
Loading

0 comments on commit 8d1a5e5

Please sign in to comment.