Skip to content

Commit

Permalink
Bump sigs.k8s.io/e2e-framework from 0.0.6 to 0.3.0 (#198)
Browse files Browse the repository at this point in the history
* Bump sigs.k7s.io/e2e-framework from 0.0.6 to 0.3.0

Bumps [sigs.k8s.io/e2e-framework](https://github.com/kubernetes-sigs/e2e-framework) from 0.0.6 to 0.3.0.
- [Release notes](https://github.com/kubernetes-sigs/e2e-framework/releases)
- [Changelog](https://github.com/kubernetes-sigs/e2e-framework/blob/main/RELEASE.md)
- [Commits](kubernetes-sigs/e2e-framework@v0.0.6...v0.3.0)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/e2e-framework
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* update e2e to use new cluster create/destory apis

Signed-off-by: Mohamed Mahmoud <[email protected]>

* Increase kafka timeout

* next try

* next try

---------

Signed-off-by: dependabot[bot] <[email protected]>
Signed-off-by: Mohamed Mahmoud <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Mohamed Mahmoud <[email protected]>
Co-authored-by: Joel Takvorian <[email protected]>
  • Loading branch information
3 people authored Nov 23, 2023
1 parent aa2e411 commit a5378d6
Show file tree
Hide file tree
Showing 189 changed files with 12,906 additions and 11,624 deletions.
3 changes: 2 additions & 1 deletion e2e/basic/flow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/mariomac/guara/pkg/test"
"github.com/netobserv/netobserv-ebpf-agent/e2e/cluster"
"github.com/netobserv/netobserv-ebpf-agent/e2e/cluster/tester"

"github.com/sirupsen/logrus"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -93,7 +94,7 @@ func TestSinglePacketFlows(t *testing.T) {

const ipIcmpHeadersLen = 42
latestFlowMS := time.Now().Add(-time.Minute)
for pktLen := 50; pktLen <= 200; pktLen++ {
for pktLen := 50; pktLen <= 200; pktLen += 7 {
logrus.WithField("destinationIP", serverPodIP).Debug("Sending ICMP packet")
stdOut, stdErr, err := pods.Execute(ctx, namespace, "pinger",
"ping", "-s", strconv.Itoa(pktLen), "-c", "1", serverPodIP)
Expand Down
20 changes: 12 additions & 8 deletions e2e/cluster/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
rt2 "runtime"

"github.com/netobserv/netobserv-ebpf-agent/e2e/cluster/tester"

"github.com/sirupsen/logrus"
"github.com/vladimirvivien/gexe"
"k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -34,6 +35,7 @@ import (
"sigs.k8s.io/e2e-framework/pkg/env"
"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/envfuncs"
"sigs.k8s.io/e2e-framework/support/kind"
)

// DeployOrder specifies the order in which a Deployment must be executed, from lower to higher
Expand Down Expand Up @@ -170,9 +172,11 @@ func NewKind(kindClusterName, baseDir string, options ...Option) *Kind {
// Run the Kind cluster for the later execution of tests.
func (k *Kind) Run(m *testing.M) {
envFuncs := []env.Func{
envfuncs.CreateKindClusterWithConfig(k.clusterName,
kindImage,
path.Join(packageDir(), "base", "00-kind.yml")),
envfuncs.CreateClusterWithConfig(
kind.NewProvider(),
k.clusterName,
path.Join(packageDir(), "base", "00-kind.yml"),
kind.WithImage(kindImage)),
k.loadLocalImage(),
}
// Deploy base cluster dependencies and wait for readiness (if needed)
Expand All @@ -195,7 +199,7 @@ func (k *Kind) Run(m *testing.M) {
code := k.testEnv.Setup(envFuncs...).
Finish(
k.exportLogs(),
envfuncs.DestroyKindCluster(k.clusterName),
envfuncs.DestroyCluster(k.clusterName),
).Run(m)
log.WithField("returnCode", code).Info("tests finished run")
}
Expand Down Expand Up @@ -352,15 +356,15 @@ func withTimeout(f env.Func, timeout time.Duration) env.Func {
if time.Since(start) > timeout {
return ctx, fmt.Errorf("timeout (%s) trying to execute function: %w", timeout, err)
}
tlog.WithError(err).Debug("function did not succeed. Retrying after 1s")
time.Sleep(time.Second)
tlog.WithError(err).Debug("function did not succeed. Retrying after 5s")
time.Sleep(5 * time.Second)
}
}
}

// isReady succeeds if the passed deployment does not have ReadyFunction, or it succeeds
func isReady(definition Deployment) env.Func {
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
return withTimeout(func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
if definition.ReadyFunction != nil {
log.WithFields(logrus.Fields{
"function": "isReady",
Expand All @@ -371,7 +375,7 @@ func isReady(definition Deployment) env.Func {
}
}
return ctx, nil
}
}, time.Minute*20)
}

// helper to get the base directory of this package, allowing to load the test deployment
Expand Down
103 changes: 45 additions & 58 deletions e2e/kafka/kafka_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,36 @@
package basic

import (
"context"
"errors"
"fmt"
"path"
"strings"
"testing"
"time"

"github.com/netobserv/netobserv-ebpf-agent/e2e/basic"
"github.com/netobserv/netobserv-ebpf-agent/e2e/cluster"

"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/e2e-framework/klient/k8s"
"sigs.k8s.io/e2e-framework/klient/wait"
"sigs.k8s.io/e2e-framework/klient/wait/conditions"
appsv1 "k8s.io/api/apps/v1"
"sigs.k8s.io/e2e-framework/klient"
"sigs.k8s.io/e2e-framework/pkg/envconf"
)

const (
clusterNamePrefix = "kafka-test-cluster"
testTimeout = 20 * time.Minute
testTimeout = 10 * time.Minute
namespace = "default"
)

var (
klog = logrus.WithField("component", "Kafka")
testCluster *cluster.Kind
)

func TestMain(m *testing.M) {
logrus.StandardLogger().SetLevel(logrus.DebugLevel)
scheme.Scheme.AddKnownTypeWithName(schema.GroupVersionKind{
Group: "kafka.strimzi.io",
Version: "v1beta2",
Kind: "Kafka",
}, &Kafka{})

testCluster = cluster.NewKind(
clusterNamePrefix+time.Now().Format("20060102-150405"),
Expand All @@ -49,21 +44,9 @@ func TestMain(m *testing.M) {
cluster.Deploy(cluster.Deployment{
Order: cluster.ExternalServices, ManifestFile: path.Join("manifests", "11-kafka-cluster.yml"),
ReadyFunction: func(cfg *envconf.Config) error {
client, err := cfg.NewClient()
if err != nil {
return fmt.Errorf("can't create k8s client: %w", err)
}
// wait for kafka to be ready
kfk := Kafka{ObjectMeta: metav1.ObjectMeta{
Namespace: namespace, Name: "kafka-cluster",
}}
if err := wait.For(conditions.New(client.Resources(namespace)).
ResourceMatch(&kfk, func(object k8s.Object) bool {
return object.(*Kafka).Status.Ready()
}),
wait.WithTimeout(testTimeout),
); err != nil {
return fmt.Errorf("waiting for kafka cluster to be ready: %w", err)
if !checkResources(cfg.Client(), "kafka-cluster-zookeeper", "kafka-cluster-kafka", "strimzi-cluster-operator", "kafka-cluster-entity-operator") {
return errors.New("waiting for kafka cluster to be ready")
}
return nil
},
Expand Down Expand Up @@ -93,39 +76,43 @@ func TestBasicFlowCapture(t *testing.T) {
bt.DoTest(t)
}

const conditionReady = "Ready"

var klog = logrus.WithField("component", "Kafka")

// Kafka meta object for its usage within the API
type Kafka struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Status *KafkaStatus `json:"status,omitempty"`
}

type KafkaStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

func (k *Kafka) DeepCopyObject() runtime.Object {
return &(*k)
}

func (ks *KafkaStatus) Ready() bool {
if ks == nil {
func checkResources(client klient.Client, list ...string) bool {
ready := map[string]bool{}
for _, name := range list {
ready[name] = false
}
var depl appsv1.DeploymentList
err := client.Resources(namespace).List(context.TODO(), &depl)
if err != nil {
klog.Errorf("Can't list deployments: %v", err)
return false
}
deplInfo := []string{}
for _, p := range depl.Items {
deplInfo = append(deplInfo, fmt.Sprintf("%s (%d/%d)", p.Name, p.Status.ReadyReplicas, p.Status.Replicas))
if _, toCheck := ready[p.Name]; toCheck {
ready[p.Name] = p.Status.ReadyReplicas == 1
}
}
klog.Infof("Deployments: " + strings.Join(deplInfo, ", "))
var sfs appsv1.StatefulSetList
err = client.Resources(namespace).List(context.TODO(), &sfs)
if err != nil {
klog.Errorf("Can't list stateful sets: %v", err)
return false
}
for _, cond := range ks.Conditions {
klog.WithFields(logrus.Fields{
"reason": cond.Reason,
"msg": cond.Message,
"type": cond.Type,
"status": cond.Status,
}).Debug("Waiting for kafka to be up and running")
if cond.Type == conditionReady {
return cond.Status == metav1.ConditionTrue
sfsInfo := []string{}
for _, p := range sfs.Items {
sfsInfo = append(sfsInfo, fmt.Sprintf("%s (%d/%d/%d)", p.Name, p.Status.ReadyReplicas, p.Status.AvailableReplicas, p.Status.Replicas))
if _, toCheck := ready[p.Name]; toCheck {
ready[p.Name] = p.Status.ReadyReplicas == 1
}
}
klog.Infof("StatefulSets: " + strings.Join(sfsInfo, ", "))
for _, state := range ready {
if !state {
return false
}
}
return false
return true
}
2 changes: 0 additions & 2 deletions e2e/kafka/manifests/11-kafka-cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: kafka-cluster
spec:
kafka:
version: 3.1.0
replicas: 1
listeners:
- name: plain
Expand All @@ -25,7 +24,6 @@ spec:
transaction.state.log.min.isr: 1
default.replication.factor: 1
min.insync.replicas: 1
inter.broker.protocol.version: "3.1"
storage:
type: ephemeral
resources:
Expand Down
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ require (
github.com/stretchr/testify v1.8.4
github.com/vishvananda/netlink v1.1.0
github.com/vishvananda/netns v0.0.4
github.com/vladimirvivien/gexe v0.1.1
github.com/vladimirvivien/gexe v0.2.0
github.com/vmware/go-ipfix v0.8.0
golang.org/x/sys v0.14.1-0.20231108175955-e4099bfacb8c
google.golang.org/grpc v1.59.0
google.golang.org/protobuf v1.31.0
k8s.io/api v0.28.4
k8s.io/apimachinery v0.28.4
k8s.io/client-go v0.28.4
sigs.k8s.io/e2e-framework v0.0.6
sigs.k8s.io/e2e-framework v0.3.0
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
Expand All @@ -45,13 +45,13 @@ require (
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.15 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jpillora/backoff v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.13 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -64,10 +64,10 @@ require (
github.com/pion/udp v0.1.4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/prometheus/client_golang v1.15.1 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
Expand All @@ -88,7 +88,7 @@ require (
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
sigs.k8s.io/controller-runtime v0.11.0 // indirect
sigs.k8s.io/controller-runtime v0.15.1 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
Expand Down
Loading

0 comments on commit a5378d6

Please sign in to comment.