Skip to content

Commit

Permalink
Last few PR comment updates
Browse files Browse the repository at this point in the history
  • Loading branch information
anupama2501 committed Nov 6, 2024
1 parent be414df commit 131be91
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 19 deletions.
8 changes: 4 additions & 4 deletions tests/v2/actions/observability/config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package observability

type StackStateConfig struct {
ServiceToken string `json:"serviceToken" yaml:"serviceToken"`
Url string `json:"url" yaml:"url"`
ClusterApiKey string `json:"clusterApiKey" yaml:"clusterApiKey"`
StackstateUpgradeVersion string `json:"stackstateUpgradeVersion" yaml:"stackstateUpgradeVersion"`
ServiceToken string `json:"serviceToken" yaml:"serviceToken"`
Url string `json:"url" yaml:"url"`
ClusterApiKey string `json:"clusterApiKey" yaml:"clusterApiKey"`
UpgradeVersion string `json:"upgradeVersion" yaml:"upgradeVersion"`
}
14 changes: 10 additions & 4 deletions tests/v2/actions/observability/stackstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ import (
)

const (
// Public Constants
StackstateName = "stackstate"
ObservabilitySteveType = "configurations.observability.rancher.io"
CrdGroup = "observability.rancher.io"
ApiExtenisonsCRD = "apiextensions.k8s.io.customresourcedefinition"

// Private Constants
localURL = "local://"
inactiveState = "inactive"
activeState = "active"
)

// NewStackstateCRDConfiguration is a constructor that takes in the configuration and creates an unstructured type to install the CRD
Expand Down Expand Up @@ -46,8 +52,8 @@ func WhitelistStackstateDomains(client *rancher.Client, whitelistDomains []strin
Name: StackstateName,
Active: false,
WhitelistDomains: whitelistDomains,
URL: "local://",
State: "inactive",
URL: localURL,
State: inactiveState,
}

stackstateNodeDriver, err := client.Management.NodeDriver.Create(nodedriver)
Expand All @@ -61,7 +67,7 @@ func WhitelistStackstateDomains(client *rancher.Client, whitelistDomains []strin
return false, err
}

if resp.State == "inactive" {
if resp.State == inactiveState {
return true, nil
}
return false, nil
Expand Down Expand Up @@ -140,7 +146,7 @@ func InstallStackstateCRD(client *rancher.Client) error {
return false, err
}

if resp.ObjectMeta.State.Name == "active" {
if resp.ObjectMeta.State.Name == activeState {
return true, nil
}
return false, nil
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/validation/observability/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ stackstateConfigs:
url: "stackstate_ui_server_address"
serviceToken: "stackstate_user_service_token"
clusterApiKey: "stackstate_cluster_apikey"
StackstateUpgradeVersion: "Stackstate_agent_version" #optional
upgradeVersion: "Stackstate_agent_version" #optional
```
10 changes: 3 additions & 7 deletions tests/v2/validation/observability/rbac/stackstate_rbac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,10 @@ import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var (
uiExtensionsRepo = "https://github.com/rancher/ui-plugin-charts"
uiGitBranch = "main"
rancherUIPlugins = "rancher-ui-plugins"
)

const (
uiExtensionsRepo = "https://github.com/rancher/ui-plugin-charts"
uiGitBranch = "main"
rancherUIPlugins = "rancher-ui-plugins"
project = "management.cattle.io.project"
rancherPartnerCharts = "rancher-partner-charts"
systemProject = "System"
Expand Down Expand Up @@ -75,7 +72,6 @@ func (rb *StackStateRBACTestSuite) SetupSuite() {
rb.cluster, err = rb.client.Management.Cluster.ByID(cluster.ID)
require.NoError(rb.T(), err)


projectTemplate := kubeprojects.NewProjectTemplate(cluster.ID)
projectTemplate.Name = charts.StackstateNamespace
project, err := client.Steve.SteveType(project).Create(projectTemplate)
Expand Down
9 changes: 6 additions & 3 deletions tests/v2/validation/observability/stackstate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ func (ss *StackStateTestSuite) SetupSuite() {
require.NoError(ss.T(), err)
ss.projectID = project.ID

_, err = namespaces.CreateNamespace(client, cluster.ID, project.Name, charts.StackstateNamespace, "", map[string]string{}, map[string]string{})
ssNamespaceExists, err := namespaces.GetNamespaceByName(client, cluster.ID, charts.StackstateNamespace)
if ssNamespaceExists == nil && k8sErrors.IsNotFound(err) {
_, err = namespaces.CreateNamespace(client, cluster.ID, project.Name, charts.StackstateNamespace, "", map[string]string{}, map[string]string{})
}
require.NoError(ss.T(), err)

_, err = ss.client.Catalog.ClusterRepos().Get(context.TODO(), rancherUIPlugins, meta.GetOptions{})
Expand Down Expand Up @@ -286,7 +289,7 @@ func (ss *StackStateTestSuite) TestDynamicUpgradeStackstateAgentChart() {
client, err := ss.client.WithSession(subSession)
require.NoError(ss.T(), err)

versionToUpgrade := ss.stackstateConfigs.StackstateUpgradeVersion
versionToUpgrade := ss.stackstateConfigs.UpgradeVersion
if versionToUpgrade == "" {
ss.T().Skip("Skipping the test as no user version provided")
}
Expand All @@ -299,7 +302,7 @@ func (ss *StackStateTestSuite) TestDynamicUpgradeStackstateAgentChart() {
ss.T().Skip("Skipping the test, as stackstate agent chart is already installed with the provided version or stackstate agent is not installed.")
}

ss.stackstateAgentInstallOptions.Version = ss.stackstateConfigs.StackstateUpgradeVersion
ss.stackstateAgentInstallOptions.Version = ss.stackstateConfigs.UpgradeVersion
require.NoError(ss.T(), err)

ss.T().Log("Upgrading stackstate agent chart to the user provided version")
Expand Down

0 comments on commit 131be91

Please sign in to comment.