-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from Quentin-M/func_testing
Introduce functional testing
- Loading branch information
Showing
7,460 changed files
with
2,913 additions
and
3,808,524 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.idea/ | ||
docs/ | ||
terraform/ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.idea/ | ||
.terraform | ||
*.tfstate | ||
*.tfstate.backup | ||
*.tfvars | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,45 @@ | ||
FROM golang:1.9-alpine AS build-env | ||
|
||
WORKDIR /go/src/github.com/quentin-m/etcd-cloud-operator | ||
COPY . . | ||
RUN go-wrapper install github.com/quentin-m/etcd-cloud-operator/cmd/operator | ||
|
||
# Install & Cache dependencies | ||
RUN apk add --no-cache git jq && \ | ||
go get github.com/Masterminds/glide && \ | ||
go get github.com/creack/yaml2json | ||
|
||
RUN apk add --update openssl && \ | ||
wget https://github.com/coreos/etcd/releases/download/v3.3.0-rc.1/etcd-v3.3.0-rc.1-linux-amd64.tar.gz -O /tmp/etcd.tar.gz && \ | ||
wget https://github.com/coreos/etcd/releases/download/v3.3.3/etcd-v3.3.3-linux-amd64.tar.gz -O /tmp/etcd.tar.gz && \ | ||
mkdir /etcd && \ | ||
tar xzvf /tmp/etcd.tar.gz -C /etcd --strip-components=1 && \ | ||
rm /tmp/etcd.tar.gz | ||
|
||
ADD glide.* ./ | ||
RUN glide install --strip-vendor && yaml2json < glide.lock | \ | ||
jq -r -c '.imports[], .testImports[] | {name: .name, subpackages: (.subpackages + [""])}' | \ | ||
jq -r -c '.name as $name | .subpackages[] | [$name, .] | join("/")' | sed 's|/$||' | \ | ||
while read pkg; do \ | ||
echo "${pkg}..."; \ | ||
go install ./vendor/${pkg} 2> /dev/null; \ | ||
done | ||
|
||
# Fetch etcdctl | ||
COPY . . | ||
RUN go-wrapper install github.com/quentin-m/etcd-cloud-operator/cmd/operator | ||
RUN go-wrapper install github.com/quentin-m/etcd-cloud-operator/cmd/tester | ||
|
||
# Install ECO | ||
COPY . . | ||
RUN go-wrapper install github.com/quentin-m/etcd-cloud-operator/cmd/operator | ||
RUN go-wrapper install github.com/quentin-m/etcd-cloud-operator/cmd/tester | ||
|
||
# Copy ECO and etcdctl into an Alpine Linux container image. | ||
FROM alpine | ||
|
||
COPY --from=build-env /go/bin/operator /operator | ||
COPY --from=build-env /go/bin/tester /tester | ||
COPY --from=build-env /etcd/etcdctl /usr/local/bin/etcdctl | ||
|
||
RUN apk add --no-cache ca-certificates | ||
|
||
ENTRYPOINT ["/operator"] | ||
CMD ["-config /etc/eco/eco.yaml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2017 Quentin Machu & eco authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package main | ||
|
||
import ( | ||
"io/ioutil" | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"gopkg.in/yaml.v2" | ||
|
||
"github.com/quentin-m/etcd-cloud-operator/pkg/tester" | ||
) | ||
|
||
// config represents a YAML configuration file that namespaces all ECO tester configuration under the | ||
// top-level "eco-tester" key. | ||
type config struct { | ||
ECOTester tester.Config `yaml:"eco-tester"` | ||
} | ||
|
||
// loadConfig is a shortcut to open a file, read it, and generate a | ||
// config. | ||
// | ||
// It supports relative and absolute paths. Given "", it returns defaultConfig. | ||
func loadConfig(path string) (config, error) { | ||
config := config{} | ||
|
||
f, err := os.Open(os.ExpandEnv(path)) | ||
if err != nil { | ||
return config, err | ||
} | ||
defer f.Close() | ||
|
||
d, err := ioutil.ReadAll(f) | ||
if err != nil { | ||
return config, err | ||
} | ||
|
||
err = yaml.Unmarshal(d, &config) | ||
if err != nil { | ||
return config, err | ||
} | ||
|
||
log.Infof("loaded configuration file %v", path) | ||
return config, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2017 Quentin Machu & eco authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// Package main implements basic logic to start the etcd-cloud-operator. | ||
package main | ||
|
||
import ( | ||
"flag" | ||
"os" | ||
"strings" | ||
|
||
"github.com/coreos/pkg/capnslog" | ||
log "github.com/sirupsen/logrus" | ||
|
||
"github.com/quentin-m/etcd-cloud-operator/pkg/tester" | ||
) | ||
|
||
func main() { | ||
// Parse command-line arguments. | ||
flag.CommandLine = flag.NewFlagSet(os.Args[0], flag.ExitOnError) | ||
flagConfigPath := flag.String("config", "", "Load configuration from the specified file.") | ||
flagLogLevel := flag.String("log-level", "info", "Define the logging level.") | ||
flag.Parse() | ||
|
||
// Initialize logging system. | ||
logLevel, err := log.ParseLevel(strings.ToUpper(*flagLogLevel)) | ||
log.SetOutput(os.Stdout) | ||
log.SetLevel(logLevel) | ||
log.SetFormatter(&log.TextFormatter{FullTimestamp: true}) | ||
capnslog.MustRepoLogger("github.com/coreos/etcd").SetLogLevel(map[string]capnslog.LogLevel{"etcdserver/api/v3rpc": capnslog.CRITICAL}) | ||
|
||
// Read configuration. | ||
config, err := loadConfig(*flagConfigPath) | ||
if err != nil { | ||
log.WithError(err).Fatal("failed to load configuration") | ||
} | ||
|
||
// Run. | ||
tester.Run(config.ECOTester) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
## Functional Testing | ||
|
||
The functional test suite verifies that the an etcd cluster, managed by the | ||
etcd-cloud-operator, is able to cope with severe failures injected while the cluster | ||
is under high pressure. This is similar to the upstream's [functional test suite]. | ||
|
||
There are obviously smarter ways to automate/run this test suite, but its development | ||
time is limited, therefore focus was on making this happen quickly. | ||
|
||
### Running the tests. | ||
|
||
- Make sure the ECO deployment has a sufficient backend quota (e.g. `8589934592`). | ||
- Open port 22 on the security group for ECO instances | ||
|
||
- Edit the present config.yaml to match the ECO deployment | ||
- Create an Ubuntu EC2 instance in the same VPC as the ECO deployment, with ports 22/3000 opened | ||
- Open four shells and execute the following commands: | ||
|
||
``` | ||
fswatch -o ./ | while read num; do rsync -avz ./ ubuntu@<ubuntu instance's address> | ||
``` | ||
|
||
``` | ||
ssh -A ubuntu@<ubuntu instance's address> | ||
sudo -E su | ||
apt update && apt install docker.io | ||
curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose && chmod +x /usr/bin/docker-compose | ||
cd /home/ubuntu/docs/testing && docker-compose up | ||
``` | ||
|
||
``` | ||
ssh -A ubuntu@<ubuntu instance's address> | ||
sudo -E su | ||
docker exec -it $(docker ps|grep tester|awk '{print $1}') bash | ||
cd /go/src/github.com/quentin-m/etcd-cloud-operator/docs/testing/ | ||
go install -v github.com/quentin-m/etcd-cloud-operator/cmd/tester && tester -config=config.yaml -log-level=debug | ||
``` | ||
|
||
``` | ||
ssh -A ubuntu@<ubuntu instance's address> | ||
watch e --endpoints=<1rd instance's ip>:2379,<2nd instance's ip>:2379,<3rd instance's ip>:2379 --dial-timeout=1s --command-timeout=1s endpoint status -w table | ||
``` | ||
|
||
- Login to `http://<ubuntu instance's address>:3000` with `admin:password` | ||
|
||
[functional test suite]: https://github.com/coreos/etcd/tree/master/tools/functional-tester |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
eco-tester: | ||
cluster: | ||
address: <cluster's load balancer address> | ||
size: 3 | ||
tls: | ||
cert-file: client.crt | ||
key-file: client.key | ||
trusted-ca-file: ca.crt |
Oops, something went wrong.