Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antrea native secondary network feature e2e test framework. #4252

Merged

Conversation

arunvelayutham
Copy link
Contributor

Signed-off-by: Arunkumar Velayutham arunkumar.velayutham@intel.com

@arunvelayutham arunvelayutham marked this pull request as draft September 27, 2022 23:01
@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Merging #4252 (dd1b668) into main (0be4217) will decrease coverage by 7.18%.
Report is 5 commits behind head on main.
The diff coverage is n/a.

❗ Current head dd1b668 differs from pull request most recent head 4a3462e. Consider uploading reports for the commit 4a3462e to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4252      +/-   ##
==========================================
- Coverage   74.38%   67.21%   -7.18%     
==========================================
  Files         414      404      -10     
  Lines       62884    60512    -2372     
==========================================
- Hits        46777    40672    -6105     
- Misses      13129    16992    +3863     
+ Partials     2978     2848     -130     
Flag Coverage Δ *Carryforward flag
e2e-tests 38.24% <ø> (-0.15%) ⬇️ Carriedforward from 1c20970
integration-tests 34.60% <ø> (+1.82%) ⬆️
kind-e2e-tests 41.41% <ø> (-5.29%) ⬇️ Carriedforward from 1c20970
unit-tests 57.00% <ø> (-9.12%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

see 301 files with indirect coverage changes

)

// The function ensureAntreaRunningWithSecondaryNetworkOption ensures that the antrea is enabled and running with sriov and whereabouts secondary network options
func (data *TestData) ensureAntreaRunningWithSecondaryNetworkOption() error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this doesn't belong in the test files. The scripts in #4097 already take care (or should take care) of deploying Antrea with the correct options for SecondaryNetwork testing.

Based on our Slack discussion, this is to counteract

err = ensureAntreaRunning(testData)

from the main function, which overwrites the Antrea deployment.

Which means that:

  • we have scripts that deploy Antrea with the correct configuration
  • the deployment is overwritten by ensureAntreaRunning
  • we have to run ensureAntreaRunningWithSecondaryNetworkOption to go back to the correct depoloyment

That seems wasteful.

I think the best option to move forward is to move these tests to test/e2e-secondary-network/ and let them have their own main function. I still feel that these tests don't really fit well within the main suite of tests, which supports things like code coverage measurement.


// The function getSecondaryInterface shows up the secondary interfaces created for the specific pod and extracts the IP address for the same.
func (data *TestData) getSecondaryInterface(targetPod int, targetInterface int) (string, error) {
respCode, output, _, err := data.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl exec -it %s -n kube-system -- ip addr show %s | grep \"inet\" | awk '{print $2}' | cut -d/ -f1", podData[targetPod].nameOfPods, podData[targetPod].nameOfInterfacePerPod[targetInterface]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you need to run a command on a Pod, use RunCommandOnPod. RunCommandOnNode should be avoided as much as possible, as it makes assumptions as to which software is available on each Node.

@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from ced1dce to 950d93b Compare October 12, 2022 22:51
@jianjuns
Copy link
Contributor

The PR includes two commits. Is this one a mistake: "Merge branch 'antrea-io:main' into antrea-secondary-network-test-sep22"?

@arunvelayutham arunvelayutham marked this pull request as ready for review October 25, 2022 18:57
@arunvelayutham
Copy link
Contributor Author

@jianjuns yes, the 2nd commit was a mistake during rebase and move my local repo to a different workspace. I will get it address. please review the other commit on this PR.

@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch 2 times, most recently from aa2da53 to 950d93b Compare October 28, 2022 18:25
e2eTestData *antreae2e.TestData
kubeConfig *restclient.Config
clientset kubernetes.Interface
aggregatorClient aggregatorclientset.Interface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't seem to be using this clientset?

busyboxImage = "projects.registry.vmware.com/antrea/busybox"
)

var SNtestData *SNTestData
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just rename it to testData / TestData, there is no risk of name collision since this is in its own package

return nil
}

func (data *SNTestData) RunPingCommandFromTestPod(podInfo podInfo, ns string, targetPodIPs *PodIPs, ctrName string, count int, size int) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to redefine these functions?
could you just export the existing function in the other e2e package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I missed to update on this comment. runPingCommandFromTestPod at test/e2e was not exported. exporting this would lead to changes all the other test functions which is using it already. If we are good with it, then great. I can goahead and make that change today and update the PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took care of these changes couple of weeks back. sorry, missed to follow-up on this PR. Please review when you get sometime.

Comment on lines 35 to 50
type PodConfig struct {
InterfaceType struct {
InterfaceType string `yaml:"interfacetype"`
} `yaml:"interface_type"`
SriovConf struct {
Networkinterface string `yaml:"networkinterface"`
Numberofvfs int `yaml:"numberofvfs"`
} `yaml:"sriov_conf"`
VirNet struct {
TotalNumberOfVirtualNetworks int `yaml:"totalnumberofvirtualnetworks"`
Virtualnetworknames []string `yaml:"virtualnetworknames"`
} `yaml:"vir_net"`
CreatePod struct {
Numberofpods int `yaml:"numberofpods"`
Describe [][]interface{} `yaml:"describe"`
} `yaml:"create_pod"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use camelCase consistently for yaml field names

Comment on lines 86 to 97
if err := data.extractPodsInfo(); err != nil {
tb.Errorf("Error in extracting Pods info from secondary_network_configuration.yml : %v", err)
return nil, err
}
// Set log directory for test execution.
if err := data.setupLogDirectoryForTest(tb.Name()); err != nil {
tb.Errorf("Error creating logs directory '%s': %v", data.logsDirForTestCase, err)
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you return the error, I don't think you should be calling tb.Error

var totalNumberOfPods int
var interfaceType string

const secondary_network_config_yaml = "../e2e/infra/secondary_network/secondary_network_configuration.yml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use camelCase for variable names


for podCheckForSubnet := 0; podCheckForSubnet < podData[sourcePod].countOfVirtualNetworksPerPod; podCheckForSubnet++ {
if podData[sourcePod].nameOfVirtualNetworkPerPod[podCheckForSubnet] == podData[targetPod].nameOfVirtualNetworkPerPod[targetInterface] {
time.Sleep(5 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't use sleeps in tests as much as possible as it leads to flaky tests or tests that take longer to run than they should
we typically use wait.Poll

test/e2e-secondary-network/framework.go Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
test/e2e-secondary-network/secondary_network_test.go Outdated Show resolved Hide resolved
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from 950d93b to 21f1e65 Compare October 31, 2022 17:05
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch 2 times, most recently from f71fd40 to 92e2fc8 Compare November 23, 2022 20:05
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch 2 times, most recently from 7746f3a to f6f2c63 Compare November 28, 2022 21:56
@jianjuns
Copy link
Contributor

@arunvelayutham : could you check these two comments from @antoninbas ?

#4252 (comment)

#4252 (comment)

@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch 2 times, most recently from d950dc5 to afec677 Compare November 30, 2022 01:30
@arunvelayutham
Copy link
Contributor Author

@jianjuns @antoninbas addressed the pending comments as well and updated the PR couple of days back. Please review further.

Copy link
Contributor

@antoninbas antoninbas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a lot of CI jobs failing

"time"

corev1 "k8s.io/api/core/v1"
//restclient "k8s.io/client-go/rest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove if no longer needed

Comment on lines 36 to 38
InterfaceType struct {
InterfaceType string `yaml:"interfacetype"`
} `yaml:"interface_type"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the nesting here for a simple string value

Comment on lines 67 to 84
const secondaryNetworkConfigYaml = "../e2e/infra/secondary_network/secondary_network_configuration.yml"
const nameSpace = "kube-system"
const ctrName = "busyboxpod"
const testPodName = "testsecpod"
const osType = "linux"
const count = 5
const size = 40
const defaultTimeout = 10 * time.Second
const reqName = "intel.com/intel_sriov_netdevice"
const resNum = 3
const (
podName = iota
podVNsCount
podVirtualNetwork
podInterfaceName
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group consts as one block?

} `yaml:"vir_net"`
CreatePod struct {
NumberOfPods int `yaml:"numberofpods"`
Describe [][]interface{} `yaml:"describe"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we use interface{} here instead of a concrete type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interface used here to make the extractPodInfo() more readable and easier to process the pod description data from the test input file (specific to secondary network test config).
Please check extractPodsInfo() for the details.

} else {
t.Logf("Error in Ping: Target interface %v of %v Pod not created", podData[targetPod].nameOfInterfacePerPod[targetInterface], podData[targetPod].nameOfPods)
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

for _, s := range service.CreatePod.Describe {
output := describePodInfo{nameOfPods: s[podName].(string), countOfVirtualNetworksPerPod: s[podVNsCount].(int), nameOfVirtualNetworkPerPod: strings.Split(s[podVirtualNetwork].(string), ","), nameOfInterfacePerPod: strings.Split(s[podInterfaceName].(string), ",")}
podData = append(podData, output)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from afec677 to fcf62ed Compare December 7, 2022 20:59
@jianjuns
Copy link
Contributor

jianjuns commented Dec 7, 2022

@arunvelayutham : please fix the test errors (could you check the failed tests after an update?):

Error: test/e2e/connectivity_test.go:74:61: undefined: podInfo
Error: test/e2e/connectivity_test.go:95:60: undefined: podInfo
Error: test/e2e/connectivity_test.go:191:98: undefined: podInfo
Error: test/e2e/antreaipam_test.go:254:21: undefined: podInfo
Error: test/e2e/antreaipam_test.go:260:30: undefined: podInfo
Error: test/e2e/antreaipam_test.go:280:17: undefined: podInfo
Error: test/e2e/antreaipam_test.go:344:87: podIPs.ipv4 undefined (type *PodIPs has no field or method ipv4)
Error: test/e2e/antreapolicy_test.go:2319:15: server0IP.ipv4 undefined (type *PodIPs has no field or method ipv4)
Error: test/e2e/antreapolicy_test.go:2325:15: server1IP.ipv4 undefined (type *PodIPs has no field or method ipv4)
Error: test/e2e/antreapolicy_test.go:2335:15: server0IP.ipv6 undefined (type *PodIPs has no field or method ipv6)
Error: test/e2e/antreapolicy_test.go:2335:15: too many errors

@arunvelayutham
Copy link
Contributor Author

@arunvelayutham : please fix the test errors (could you check the failed tests after an update?):

Error: test/e2e/connectivity_test.go:74:61: undefined: podInfo
Error: test/e2e/connectivity_test.go:95:60: undefined: podInfo
Error: test/e2e/connectivity_test.go:191:98: undefined: podInfo
Error: test/e2e/antreaipam_test.go:254:21: undefined: podInfo
Error: test/e2e/antreaipam_test.go:260:30: undefined: podInfo
Error: test/e2e/antreaipam_test.go:280:17: undefined: podInfo
Error: test/e2e/antreaipam_test.go:344:87: podIPs.ipv4 undefined (type *PodIPs has no field or method ipv4)
Error: test/e2e/antreapolicy_test.go:2319:15: server0IP.ipv4 undefined (type *PodIPs has no field or method ipv4)
Error: test/e2e/antreapolicy_test.go:2325:15: server1IP.ipv4 undefined (type *PodIPs has no field or method ipv4)
Error: test/e2e/antreapolicy_test.go:2335:15: server0IP.ipv6 undefined (type *PodIPs has no field or method ipv6)
Error: test/e2e/antreapolicy_test.go:2335:15: too many errors

sorry @jianjuns, today's push was not ready for review. I did push while moving to a different workspace. I will ensure all works before request for review

@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from 0cbbe9b to 1c20970 Compare December 10, 2022 04:17
@arunvelayutham
Copy link
Contributor Author

/test-all

@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from dd1b668 to 6af366c Compare February 8, 2023 18:26
// PodInfo combines OS info with a Pod name. It is useful when choosing commands and options on Pods of different OS (Windows, Linux).
type PodInfo struct {
Name string
Os string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Os -> OS

Use upper case for abbreviations.

package e2e

import (
antreae2e "antrea.io/antrea/test/e2e"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We divide imports to sub-groups, like:

import (
	"log"
	"os"
	"path/filepath"
	"time"

	corev1 "k8s.io/api/core/v1"

	antreae2e "antrea.io/antrea/test/e2e"
)


var clusterInfo ClusterInfo

// podWaitForRunning polls the k8s apiserver until the specified Pod is in the "running" state (or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: k8s -> K8s


// podWaitForRunning polls the k8s apiserver until the specified Pod is in the "running" state (or
// until the provided timeout expires).
func (data *TestData) podWaitForRunning(timeout time.Duration, name, namespace string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question - do we really need to wrap these funcs, compared to directly calling data.e2eTestData.Func() in code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we create few wrappers with references to how a similar scenario was handled at the multicluster test implementation. removed this now and addressed as suggested. Please note: updated code was not tested (just compiled) due to K8s cluster setup issues. I will test the e2e flows once its recovered.

return err
}

func (data *TestData) setupLogDirectoryForTest(testName string) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we need to re-implement this func, instead of reusing e2eTestData.setupLogDirectoryForTest()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setupLog**() was not exported at test/e2e. More over, we create few wrappers with references to how a similar scenario was handled at the multicluster test implementation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @antoninbas @luolanzone know the background of the MC design.

I am fine to start with the current code anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a notable difference with the existing e2e tests is that the e2e-secondary-network tests assume that antrea has already been deployed, with the correct configuration (that's by design). So we cannot reuse setupTest for example.

That being said, I tend to agree with Jianjun about reusing TestOptions and TestData as is.

One thing that is also not clear to me is whether the e2e-secondary-network tests actually export any logs? In Antrea e2e tests, this is handled by

func exportLogs(tb testing.TB, data *TestData, logsSubDir string, writeNodeLogs bool) {

But I don't see any code here that would export logs? I could be missing something.

var interfaceType string

const (
secondaryNetworkConfigYaml = "../e2e/infra/secondary_network/secondary_network_configuration.yml"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: secondaryNetworkConfigYaml -> secondaryNetworkConfigYAML

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secondary_network_configuration.yml -> secondary-network-configuration.yml

return data, nil
}

// extractPodsInfo extracts the Pod and secondary network interface information for the creation of Podsfrom secondary_network_configuration.yaml file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secondary_network_configuration.yml -> secondary-network-configuration.yml

return nil
}

// formAnnotationStringOfPod forms the annotation string, used in the generation of each Pod yaml file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: yaml -> YAML

}

func TestNativeSecondaryNetwork(t *testing.T) {
//skipIfHasWindowsNodes(t)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took care.

if err != nil {
t.Logf("Error when up setupTestWithSecondaryNetworkConfig: %v", err)
}
//defer teardownSecondaryNetworkTest(t, data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uncomment or remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

took care.

@github-actions
Copy link
Contributor

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 16, 2023
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from 6af366c to fd3d8f7 Compare May 18, 2023 21:54
@arunvelayutham arunvelayutham marked this pull request as draft May 18, 2023 21:59
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from fd3d8f7 to 4369655 Compare May 18, 2023 23:01
@arunvelayutham arunvelayutham marked this pull request as ready for review May 18, 2023 23:11
@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 19, 2023
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch 3 times, most recently from a04d1ec to 3e9eb6c Compare May 29, 2023 05:49
@github-actions
Copy link
Contributor

github-actions bot commented Sep 5, 2023

This PR is stale because it has been open 90 days with no activity. Remove stale label or comment, or this will be closed in 90 days

@github-actions github-actions bot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Sep 5, 2023
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from 0eb3a9f to 3e9eb6c Compare October 12, 2023 23:36
@github-actions github-actions bot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 13, 2023
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from 3e9eb6c to 4a3462e Compare October 17, 2023 00:52
@arunvelayutham
Copy link
Contributor Author

/test-all

@jianjuns
Copy link
Contributor

@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from 4a3462e to 0d2d6fa Compare November 8, 2023 05:43
Signed-off-by: Arunkumar Velayutham <arunkumar.velayutham@intel.com>
@arunvelayutham arunvelayutham force-pushed the antrea-secondary-network-test-sep22 branch from 0d2d6fa to 3797ee8 Compare November 8, 2023 07:08
@arunvelayutham
Copy link
Contributor Author

/test-all

@jianjuns
Copy link
Contributor

/test-ipv6-e2e
/test-all

@jianjuns
Copy link
Contributor

/test-ipv6-e2e
/test-all

@jianjuns
Copy link
Contributor

/test-ipv6-e2e

Copy link
Contributor

@jianjuns jianjuns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will merge the PR. Let us continue improving the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants