Skip to content

Commit

Permalink
Integration framework improvement (istio#2110)
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Integration framework improvement

**What this PR does / why we need it**:

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```

1. Add `config` into components
2. Add `status` into components
3. Use fortio from vendor
4. Download proxy from GCS instead of build (able to run on gLinux)
5. Integrated into Prow presubmit
  • Loading branch information
yutongz authored and istio-merge-robot committed Feb 14, 2018
1 parent 17d6d49 commit f58c575
Show file tree
Hide file tree
Showing 21 changed files with 467 additions and 233 deletions.
14 changes: 7 additions & 7 deletions mixer/pkg/attribute/list.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions prow/istio-presubmit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ if [[ -n $(git diff) ]]; then
git diff
fi

# upload images - needed by the subsequent tests
# Upload images - needed by the subsequent tests
time ISTIO_DOCKER_HUB="gcr.io/istio-testing" make push HUB="gcr.io/istio-testing" TAG="${GIT_SHA}"

# run security e2e test
# Run integration framework sample
./tests/integration/example/integration.sh

# Run security e2e test
CERT_DIR=$(make where-is-docker-temp) ${ROOT}/security/bin/e2e.sh --hub "gcr.io/istio-testing" --tag "${GIT_SHA}"
6 changes: 3 additions & 3 deletions security/bin/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ if [[ "$HUB" =~ ^gcr\.io ]]; then
fi

# Run integration tests
go test istio.io/istio/security/tests/integration/certificateRotationTest $ARGS \
go test -v istio.io/istio/security/tests/integration/certificateRotationTest $ARGS \
-kube-config=$HOME/.kube/config \
-stderrthreshold=INFO --alsologtostderr

go test istio.io/istio/security/tests/integration/secretCreationTest $ARGS \
go test -v istio.io/istio/security/tests/integration/secretCreationTest $ARGS \
-kube-config=$HOME/.kube/config \
-stderrthreshold=INFO --alsologtostderr

#See issue #3181 test below fails automated tests
#go test istio.io/istio/security/tests/integration/nodeAgentTest $ARGS \
#go test -v istio.io/istio/security/tests/integration/nodeAgentTest $ARGS \
#-kube-config=$HOME/.kube/config \
#-root-cert=${CERT_DIR}/istio_ca.crt \
#-cert-chain=${CERT_DIR}/node_agent.crt \
Expand Down
32 changes: 18 additions & 14 deletions security/tests/integration/istio_ca_cert_rotation_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type (
CertRotationTestEnv struct {
framework.TestEnv
name string
comps []framework.Component
ClientSet *kubernetes.Clientset
NameSpace string
Hub string
Expand Down Expand Up @@ -71,21 +72,24 @@ func (env *CertRotationTestEnv) GetName() string {
// It defines what components a environment contains.
// Components will be stored in framework for start and stop
func (env *CertRotationTestEnv) GetComponents() []framework.Component {
return []framework.Component{
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
istioCaSelfSignedShortTTL,
fmt.Sprintf("%s/istio-ca:%s", env.Hub, env.Tag),
[]string{
"/usr/local/bin/istio_ca",
},
[]string{
"--self-signed-ca",
"--workload-cert-ttl", "60s",
},
),
if env.comps == nil {
env.comps = []framework.Component{
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
istioCaSelfSignedShortTTL,
fmt.Sprintf("%s/istio-ca:%s", env.Hub, env.Tag),
[]string{
"/usr/local/bin/istio_ca",
},
[]string{
"--self-signed-ca",
"--workload-cert-ttl", "60s",
},
),
}
}
return env.comps
}

// Bringup doing general setup for environment level, not components.
Expand Down
86 changes: 45 additions & 41 deletions security/tests/integration/istio_ca_node_agent_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type (
NodeAgentTestEnv struct {
framework.TestEnv
name string
comps []framework.Component
ClientSet *kubernetes.Clientset
NameSpace string
Hub string
Expand Down Expand Up @@ -76,48 +77,51 @@ func (env *NodeAgentTestEnv) GetName() string {
// It defines what components a environment contains.
// Components will be stored in framework for start and stop
func (env *NodeAgentTestEnv) GetComponents() []framework.Component {
return []framework.Component{
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
istioCaWithGivenCertificate,
fmt.Sprintf("%v/istio-ca-test:%v", env.Hub, env.Tag),
[]string{},
[]string{},
),
NewKubernetesService(
env.ClientSet,
env.NameSpace,
"istio-ca",
v1.ServiceTypeClusterIP,
8060,
map[string]string{
"pod-group": istioCaWithGivenCertificate + podGroupPostfix,
},
map[string]string{
kube.KubeServiceAccountsOnVMAnnotation: "nodeagent.google.com",
},
),
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
nodeAgent,
fmt.Sprintf("%v/node-agent-test:%v", env.Hub, env.Tag),
[]string{},
[]string{},
),
NewKubernetesService(
env.ClientSet,
env.NameSpace,
nodeAgentService,
v1.ServiceTypeLoadBalancer,
8080,
map[string]string{
"pod-group": nodeAgent + podGroupPostfix,
},
map[string]string{},
),
if env.comps == nil {
env.comps = []framework.Component{
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
istioCaWithGivenCertificate,
fmt.Sprintf("%v/istio-ca-test:%v", env.Hub, env.Tag),
[]string{},
[]string{},
),
NewKubernetesService(
env.ClientSet,
env.NameSpace,
"istio-ca",
v1.ServiceTypeClusterIP,
8060,
map[string]string{
"pod-group": istioCaWithGivenCertificate + podGroupPostfix,
},
map[string]string{
kube.KubeServiceAccountsOnVMAnnotation: "nodeagent.google.com",
},
),
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
nodeAgent,
fmt.Sprintf("%v/node-agent-test:%v", env.Hub, env.Tag),
[]string{},
[]string{},
),
NewKubernetesService(
env.ClientSet,
env.NameSpace,
nodeAgentService,
v1.ServiceTypeLoadBalancer,
8080,
map[string]string{
"pod-group": nodeAgent + podGroupPostfix,
},
map[string]string{},
),
}
}
return env.comps
}

// Bringup doing general setup for environment level, not components.
Expand Down
30 changes: 17 additions & 13 deletions security/tests/integration/istio_ca_secret_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type (
SecretTestEnv struct {
framework.TestEnv
name string
comps []framework.Component
ClientSet *kubernetes.Clientset
NameSpace string
Hub string
Expand Down Expand Up @@ -71,20 +72,23 @@ func (env *SecretTestEnv) GetName() string {
// It defines what components a environment contains.
// Components will be stored in framework for start and stop
func (env *SecretTestEnv) GetComponents() []framework.Component {
return []framework.Component{
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
istioCaSelfSigned,
fmt.Sprintf("%v/istio-ca:%v", env.Hub, env.Tag),
[]string{
"/usr/local/bin/istio_ca",
},
[]string{
"--self-signed-ca",
},
),
if env.comps == nil {
env.comps = []framework.Component{
NewKubernetesPod(
env.ClientSet,
env.NameSpace,
istioCaSelfSigned,
fmt.Sprintf("%v/istio-ca:%v", env.Hub, env.Tag),
[]string{
"/usr/local/bin/istio_ca",
},
[]string{
"--self-signed-ca",
},
),
}
}
return env.comps
}

// Bringup doing general setup for environment level, not components.
Expand Down
6 changes: 0 additions & 6 deletions security/tests/integration/kubernetes_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func (c *KubernetesPod) Start() (err error) {
if _, err = createPod(c.clientset, c.namespace, c.image, c.name, labels, c.cmds, c.args); err != nil {
glog.Errorf("failed to create a pod: %v", c.name)
}

return err
}

Expand All @@ -88,8 +87,3 @@ func (c *KubernetesPod) IsAlive() (bool, error) {

return true, nil
}

// Cleanup clean up tmp files and other resource created by this component
func (c *KubernetesPod) Cleanup() error {
return nil
}
5 changes: 0 additions & 5 deletions security/tests/integration/kubernetes_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,3 @@ func (c *KubernetesService) IsAlive() (bool, error) {
}
return true, nil
}

// Cleanup clean up tmp files and other resource created by this component
func (c *KubernetesService) Cleanup() error {
return nil
}
71 changes: 58 additions & 13 deletions tests/integration/component/fortio_server/fortio_server_comp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,44 +18,94 @@ import (
"flag"
"fmt"
"log"
"sync"
"time"

"istio.io/istio/tests/integration/framework"
)

const (
serverEndpoint = "http://localhost:8080/"
)

var (
fortioBinary = flag.String("fortio_binary", "", "Fortio binary path.")
lock sync.Mutex
)

// LocalCompConfig contains configs for LocalComponent
type LocalCompConfig struct {
framework.Config
LogFile string
}

// LocalCompStatus contains status for LocalComponent
type LocalCompStatus struct {
framework.Status
EchoEndpoint string
}

// LocalComponent is a local fortio server componment
type LocalComponent struct {
framework.Component
testProcess framework.TestProcess
Name string
LogFile string
name string
config LocalCompConfig
status LocalCompStatus
}

// NewLocalComponent create a LocalComponent with name and log dir
func NewLocalComponent(n, logDir string) *LocalComponent {
logFile := fmt.Sprintf("%s/%s.log", logDir, n)
func NewLocalComponent(n string, config LocalCompConfig) *LocalComponent {
return &LocalComponent{
Name: n,
LogFile: logFile,
name: n,
config: config,
}
}

// GetName implement the function in component interface
func (fortioServerComp *LocalComponent) GetName() string {
return fortioServerComp.Name
return fortioServerComp.name
}

// GetConfig return the config for outside use
func (fortioServerComp *LocalComponent) GetConfig() framework.Config {
lock.Lock()
config := fortioServerComp.config
lock.Unlock()
return config
}

// SetConfig set a config into this component
func (fortioServerComp *LocalComponent) SetConfig(config framework.Config) error {
fortioConfig, ok := config.(LocalCompConfig)
if !ok {
return fmt.Errorf("cannot cast config into fortio local config")
}
lock.Lock()
fortioServerComp.config = fortioConfig
lock.Unlock()
return nil
}

// GetStatus return the status for outside use
func (fortioServerComp *LocalComponent) GetStatus() framework.Status {
lock.Lock()
status := fortioServerComp.status
lock.Unlock()
return status
}

// Start brings up a local fortio echo server
func (fortioServerComp *LocalComponent) Start() (err error) {
if err = fortioServerComp.testProcess.Start(fmt.Sprintf("%s server > %s 2>&1",
*fortioBinary, fortioServerComp.LogFile)); err != nil {
*fortioBinary, fortioServerComp.config.LogFile)); err != nil {
return
}

lock.Lock()
fortioServerComp.status.EchoEndpoint = serverEndpoint
lock.Unlock()

// TODO: Find more reliable way to tell if local components are ready to serve
time.Sleep(2 * time.Second)
log.Printf("Started component %s", fortioServerComp.GetName())
Expand All @@ -74,8 +124,3 @@ func (fortioServerComp *LocalComponent) Stop() (err error) {
log.Printf("Stopping component %s", fortioServerComp.GetName())
return fortioServerComp.testProcess.Stop()
}

// Cleanup clean up tmp files and other resource created by LocalComponent
func (fortioServerComp *LocalComponent) Cleanup() error {
return nil
}
Loading

0 comments on commit f58c575

Please sign in to comment.