-
Notifications
You must be signed in to change notification settings - Fork 198
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
test(e2e-cilium): add e2e test for cilium event observer plugin #665
Open
snguyen64
wants to merge
5
commits into
microsoft:main
Choose a base branch
from
snguyen64:feat/cilium-update
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
91eb27e
test(e2e-cilium): add e2e test for cilium event observer plugin
snguyen64 2bdb521
Merge branch 'main' into feat/cilium-update
snguyen64 50f51db
update makefile and readme
snguyen64 5727fdc
update test with attributes and add gitignore
snguyen64 ef09dd9
update test to add ipv6 and icmpv6 checks
snguyen64 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,109 @@ | ||
package azure | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azidentity" | ||
armcontainerservice "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice/v4" | ||
) | ||
|
||
type CreateCiliumCluster struct { | ||
SubscriptionID string | ||
ResourceGroupName string | ||
Location string | ||
ClusterName string | ||
} | ||
|
||
func (c *CreateCiliumCluster) Prevalidate() error { | ||
return nil | ||
} | ||
|
||
func (c *CreateCiliumCluster) Stop() error { | ||
return nil | ||
} | ||
|
||
func (c *CreateCiliumCluster) Run() error { | ||
// Start with default cluster template | ||
ciliumCluster := GetStarterClusterTemplate(c.Location) | ||
|
||
ciliumCluster.Properties.NetworkProfile.NetworkPlugin = to.Ptr(armcontainerservice.NetworkPluginAzure) | ||
ciliumCluster.Properties.NetworkProfile.NetworkPluginMode = to.Ptr(armcontainerservice.NetworkPluginModeOverlay) | ||
ciliumCluster.Properties.NetworkProfile.NetworkDataplane = to.Ptr(armcontainerservice.NetworkDataplaneCilium) | ||
ipv4 := armcontainerservice.IPFamilyIPv4 | ||
ipv6 := armcontainerservice.IPFamilyIPv6 | ||
ciliumCluster.Properties.NetworkProfile.IPFamilies = []*armcontainerservice.IPFamily{&ipv4, &ipv6} | ||
|
||
//nolint:appendCombine // separate for verbosity | ||
ciliumCluster.Properties.AgentPoolProfiles = append(ciliumCluster.Properties.AgentPoolProfiles, &armcontainerservice.ManagedClusterAgentPoolProfile{ //nolint:all | ||
Type: to.Ptr(armcontainerservice.AgentPoolTypeVirtualMachineScaleSets), | ||
// AvailabilityZones: []*string{to.Ptr("1")}, | ||
Count: to.Ptr[int32](AuxilaryNodeCount), | ||
EnableNodePublicIP: to.Ptr(false), | ||
Mode: to.Ptr(armcontainerservice.AgentPoolModeUser), | ||
OSType: to.Ptr(armcontainerservice.OSTypeLinux), | ||
ScaleDownMode: to.Ptr(armcontainerservice.ScaleDownModeDelete), | ||
VMSize: to.Ptr(AgentARMSKU), | ||
Name: to.Ptr("arm64"), | ||
MaxPods: to.Ptr(int32(MaxPodsPerNode)), | ||
}) | ||
|
||
ciliumCluster.Properties.AutoUpgradeProfile = &armcontainerservice.ManagedClusterAutoUpgradeProfile{ | ||
NodeOSUpgradeChannel: to.Ptr(armcontainerservice.NodeOSUpgradeChannelNodeImage), | ||
} | ||
|
||
// Deploy cluster | ||
cred, err := azidentity.NewAzureCLICredential(nil) | ||
if err != nil { | ||
return fmt.Errorf("failed to obtain a credential: %w", err) | ||
} | ||
ctx, cancel := context.WithTimeout(context.Background(), clusterTimeout) | ||
defer cancel() | ||
|
||
clientFactory, err := armcontainerservice.NewClientFactory(c.SubscriptionID, cred, nil) | ||
if err != nil { | ||
return fmt.Errorf("failed to create az client: %w", err) | ||
} | ||
|
||
log.Printf("when the cluster is ready, use the below command to access and debug") | ||
log.Printf("az aks get-credentials --resource-group %s --name %s --subscription %s", c.ResourceGroupName, c.ClusterName, c.SubscriptionID) | ||
log.Printf("creating cluster \"%s\" in resource group \"%s\"...", c.ClusterName, c.ResourceGroupName) | ||
|
||
poller, err := clientFactory.NewManagedClustersClient().BeginCreateOrUpdate(ctx, c.ResourceGroupName, c.ClusterName, ciliumCluster, nil) | ||
if err != nil { | ||
return fmt.Errorf("failed to finish the create cluster request: %w", err) | ||
} | ||
|
||
notifychan := make(chan struct{}) | ||
go func() { | ||
_, err = poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{ | ||
Frequency: pollFrequency, | ||
}) | ||
if err != nil { | ||
log.Printf("failed to create cluster: %v\n", err) | ||
} else { | ||
log.Printf("cluster %s is ready\n", c.ClusterName) | ||
} | ||
close(notifychan) | ||
}() | ||
|
||
ticker := time.NewTicker(clusterCreateTicker) | ||
defer ticker.Stop() | ||
for { | ||
select { | ||
case <-ctx.Done(): | ||
return fmt.Errorf("failed to create cluster: %w", ctx.Err()) | ||
case <-ticker.C: | ||
log.Printf("waiting for cluster %s to be ready...\n", c.ClusterName) | ||
case <-notifychan: | ||
if err != nil { | ||
return fmt.Errorf("received notification, failed to create cluster: %w", err) | ||
} | ||
return nil | ||
} | ||
} | ||
} |
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,64 @@ | ||
package retina | ||
|
||
import ( | ||
"crypto/rand" | ||
"math/big" | ||
"os" | ||
"os/user" | ||
"path/filepath" | ||
"strconv" | ||
"testing" | ||
"time" | ||
|
||
"github.com/microsoft/retina/test/e2e/common" | ||
"github.com/microsoft/retina/test/e2e/framework/types" | ||
jobs "github.com/microsoft/retina/test/e2e/jobs" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
var retinaCiliumLocations = []string{"eastus2", "centralus", "southcentralus", "uksouth", "centralindia", "westus2"} | ||
|
||
// TestE2ERetinaCilium tests all e2e scenarios for retina on cilium clusters | ||
func TestE2ERetinaCilium(t *testing.T) { | ||
curuser, err := user.Current() | ||
require.NoError(t, err) | ||
clusterName := curuser.Username + common.NetObsRGtag + "cil-" + strconv.FormatInt(time.Now().Unix(), 10) | ||
|
||
subID := os.Getenv("AZURE_SUBSCRIPTION_ID") | ||
require.NotEmpty(t, subID) | ||
|
||
location := os.Getenv("AZURE_LOCATION") | ||
if location == "" { | ||
var nBig *big.Int | ||
nBig, err = rand.Int(rand.Reader, big.NewInt(int64(len(retinaCiliumLocations)))) | ||
if err != nil { | ||
t.Fatalf("Failed to generate a secure random index: %v", err) | ||
} | ||
location = retinaCiliumLocations[nBig.Int64()] | ||
} | ||
|
||
cwd, err := os.Getwd() | ||
require.NoError(t, err) | ||
|
||
// Get to root of the repo by going up two directories | ||
rootDir := filepath.Dir(filepath.Dir(cwd)) | ||
|
||
chartPath := filepath.Join(rootDir, "deploy", "hubble", "manifests", "controller", "helm", "retina") | ||
profilePath := filepath.Join(rootDir, "test", "profiles", "advanced", "hubble", "cilium", "values.yaml") | ||
kubeConfigFilePath := filepath.Join(rootDir, "test", "e2e", "test.pem") | ||
|
||
// CreateTestInfra with Cilium dataplane | ||
createTestInfra := types.NewRunner(t, jobs.CreateTestInfraCilium(subID, clusterName, location, kubeConfigFilePath)) | ||
createTestInfra.Run() | ||
|
||
// Hacky way to ensure that the test infra is deleted even if the test panics | ||
defer func() { | ||
if r := recover(); r != nil { | ||
t.Logf("Recovered in TestE2ERetinaCilium, %v", r) | ||
} | ||
_ = jobs.DeleteTestInfra(subID, clusterName, location).Run() | ||
}() | ||
|
||
advanceMetricsE2E := types.NewRunner(t, jobs.InstallAndTestRetinaCiliumMetrics(kubeConfigFilePath, chartPath, profilePath)) | ||
advanceMetricsE2E.Run() | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this will run sequentially, can we make it run in parallel, preferably in another gh workflow stage so we can see output separately for both clusters.
You might want to add anoher one of this
retina/.github/workflows/images.yaml
Line 197 in 32ecf7e