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

Fix project creation #30

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ toolchain go1.22.7

require (
github.com/pkg/errors v0.9.1 // indirect
github.com/rancher/norman v0.0.0-20240708202514-a0127673d1b9 // indirect
github.com/rancher/norman v0.0.0-20240708202514-a0127673d1b9
github.com/rancher/shepherd v0.0.0-20240913161053-43e119d13724 // rancher/shepherd release/v2.9-HEAD commit
github.com/sirupsen/logrus v1.9.3 // indirect
k8s.io/apimachinery v0.30.2
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/installations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
e2e "k8s.io/kubernetes/test/e2e/framework"
)

const exampleAppProjectName = "demo-project"
const exampleAppProjectName = "System"

var _ = Describe("Observability Installation Test Suite", func() {
var clientWithSession *rancher.Client
Expand Down
35 changes: 28 additions & 7 deletions tests/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/rancher/norman/types"
rancher "github.com/rancher/shepherd/clients/rancher"
management "github.com/rancher/shepherd/clients/rancher/generated/management/v3"
clusters "github.com/rancher/shepherd/extensions/clusters"
Expand Down Expand Up @@ -59,6 +60,8 @@ func TestE2E(t *testing.T) {

// This setup will run once for the entire test suite
var _ = BeforeSuite(func() {
project = nil

testSession := session.NewSession()
sess = testSession

Expand All @@ -77,14 +80,32 @@ var _ = BeforeSuite(func() {
registrySetting, err = client.Management.Setting.ByID("system-default-registry")
Expect(err).NotTo(HaveOccurred())

// Create project
projectConfig := &management.Project{
ClusterID: cluster.ID,
Name: exampleAppProjectName,
}
project, err = client.Management.Project.Create(projectConfig)
projectsList, err := client.Management.Project.List(&types.ListOpts{
Filters: map[string]interface{}{
"clusterId": cluster.ID,
},
})
Expect(err).NotTo(HaveOccurred())
Expect(project.Name).To(Equal(exampleAppProjectName))

for i := range projectsList.Data {
p := &projectsList.Data[i]
if p.Name == exampleAppProjectName {
project = p
break
}
}

// Check if project was found
if project == nil {
projectConfig := &management.Project{
ClusterID: cluster.ID,
Name: exampleAppProjectName,
}

project, err = client.Management.Project.Create(projectConfig)
Expect(err).NotTo(HaveOccurred())
Expect(project.Name).To(Equal(exampleAppProjectName))
}
})

// This teardown will run once after all the tests in the suite are done
Expand Down
Loading