Skip to content

Commit

Permalink
e2e: correcting lint issues
Browse files Browse the repository at this point in the history
1. corrected the version of golang.org/x/net to 0.33.0 as per GHSA-w32m-9786-jp63
2. corrected other lint issues

Signed-off-by: Annaraya Narasagond <[email protected]>
Signed-off-by: Annaraya Narasagond <[email protected]> Annaraya Narasagond <[email protected]>
  • Loading branch information
asn1809 committed Dec 30, 2024
1 parent 79fa931 commit a224c49
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 44 deletions.
66 changes: 36 additions & 30 deletions e2e/deployers/discoveredapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
)

const timeout = 300

type DiscoveredApp struct {
IncludeRecipe bool
IncludeHooks bool
Expand All @@ -28,8 +30,10 @@ func (d DiscoveredApp) GetName() string {
if d.IncludeHooks {
return "disapp-recipe-hooks"
}

return "disapp-recipe"
}

return "disapp"
}

Expand Down Expand Up @@ -86,8 +90,11 @@ func (d DiscoveredApp) Deploy(ctx types.Context) error {
// recipe needs to be created based on flags
if d.IncludeRecipe {
recipeName := ctx.Name() + "-recipe"
createRecipe(recipeName, appNamespace, d.IncludeHooks)
log.Info("Recipe created on both dr clusters")
if err := createRecipe(recipeName, appNamespace, d.IncludeHooks); err != nil {
log.Info("recipe creation failed")
}

log.Info("recipe created on both dr clusters")
}

return nil
Expand Down Expand Up @@ -120,6 +127,7 @@ func (d DiscoveredApp) Undeploy(ctx types.Context) error {

if d.IncludeRecipe {
recipeName := ctx.Name() + "-recipe"

log.Infof("Deleting recipe on cluster %q", drpolicy.Spec.DRClusters[0])

if err := deleteRecipe(util.Ctx.C1.Client, recipeName, appNamespace); err != nil {
Expand Down Expand Up @@ -168,15 +176,19 @@ func createRecipe(name, namespace string, includeHooks bool) error {
if !errors.IsAlreadyExists(err) {
return err
}

util.Ctx.Log.Info("recipe " + name + " already exists" + " in the cluster " + "C1")
}

err = util.Ctx.C2.Client.Create(context.Background(), recipe)
if err != nil {
if !errors.IsAlreadyExists(err) {
return err
}

util.Ctx.Log.Info("recipe " + name + " already exists" + " in the cluster " + "C2")
}

return nil
}

Expand Down Expand Up @@ -265,34 +277,8 @@ func getRecipeWithHooks(name, namespace string) *recipe.Recipe {
},
},
Hooks: []*recipe.Hook{
{
Name: "backup",
Type: "check",
Namespace: namespace,
NameSelector: "busybox",
SelectResource: "deployment",
Timeout: 300,
Chks: []*recipe.Check{
{
Name: "check-replicas",
Condition: "{$.spec.replicas} == {$.status.readyReplicas}",
},
},
},
{
Name: "restore",
Type: "check",
Namespace: namespace,
NameSelector: "busybox",
SelectResource: "deployment",
Timeout: 300,
Chks: []*recipe.Check{
{
Name: "check-replicas",
Condition: "{$.spec.replicas} == {$.status.readyReplicas}",
},
},
},
getHookSpec(namespace, "backup"),
getHookSpec(namespace, "restore"),
},
Workflows: []*recipe.Workflow{
{
Expand Down Expand Up @@ -322,15 +308,35 @@ func getRecipeWithHooks(name, namespace string) *recipe.Recipe {
}
}

func getHookSpec(namespace, hookType string) *recipe.Hook {
return &recipe.Hook{
Name: hookType,
Type: "check",
Namespace: namespace,
NameSelector: "busybox",
SelectResource: "deployment",
Timeout: timeout,
Chks: []*recipe.Check{
{
Name: "check-replicas",
Condition: "{$.spec.replicas} == {$.status.readyReplicas}",
},
},
}
}

func deleteRecipe(client client.Client, name, namespace string) error {
r := &recipe.Recipe{}
key := k8stypes.NamespacedName{Namespace: namespace, Name: name}

err := client.Get(context.Background(), key, r)
if err != nil {
if !errors.IsNotFound(err) {
return err
}

return nil
}

return client.Delete(context.Background(), r)
}
6 changes: 4 additions & 2 deletions e2e/exhaustive_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ var (
discoveredApps = &deployers.DiscoveredApp{}
discoveredAppsWithoutHook = &deployers.DiscoveredApp{IncludeRecipe: true, IncludeHooks: false}
discoveredAppsWithHook = &deployers.DiscoveredApp{IncludeRecipe: true, IncludeHooks: true}
Deployers = []types.Deployer{subscription, appset, discoveredApps, discoveredAppsWithoutHook,
discoveredAppsWithHook}
Deployers = []types.Deployer{
subscription, appset, discoveredApps, discoveredAppsWithoutHook,
discoveredAppsWithHook,
}
)

func generateWorkloads([]types.Workload) {
Expand Down
11 changes: 7 additions & 4 deletions e2e/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ require (
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.6.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
Expand All @@ -78,4 +78,7 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace github.com/ramendr/ramen/api => ../api
replace (
github.com/ramendr/ramen/api => ../api
golang.org/x/net v0.29.0 => golang.org/x/net v0.33.0
)
16 changes: 8 additions & 8 deletions e2e/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs=
golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -158,14 +158,14 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U=
golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down

0 comments on commit a224c49

Please sign in to comment.