Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrmiskiewicz committed Feb 7, 2025
1 parent 879389a commit fdc3e13
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 73 deletions.
8 changes: 5 additions & 3 deletions cmd/broker/broker_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
corev1 "k8s.io/api/core/v1"
"log/slog"
"net/http"
"net/http/httptest"
Expand All @@ -15,6 +14,8 @@ import (
"testing"
"time"

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

"github.com/kyma-project/kyma-environment-broker/common/hyperscaler"

"github.com/gardener/gardener/pkg/apis/core/v1beta1"
Expand Down Expand Up @@ -252,7 +253,7 @@ func NewBrokerSuiteTestWithConfig(t *testing.T, cfg *Config, version ...string)

k8sDeletionObjectTracker: ot,
}
ts.poller = &broker.TimerPoller{PollInterval: 8 * time.Millisecond, PollTimeout: 800 * time.Millisecond, Log: ts.t.Log}
ts.poller = &broker.TimerPoller{PollInterval: 3 * time.Millisecond, PollTimeout: 800 * time.Millisecond, Log: ts.t.Log}

ts.CreateAPI(inputFactory, cfg, db, provisioningQueue, deprovisioningQueue, updateQueue, log, k8sClientProvider, gardener.NewFakeClient(), eventBroker)

Expand Down Expand Up @@ -992,7 +993,7 @@ func (s *BrokerSuiteTest) AssertNetworkFilteringDisabled(iid string, expected bo
}

func (s *BrokerSuiteTest) failRuntimeByKIM(iid string) {
s.poller.Invoke(func() (bool, error) {
err := s.poller.Invoke(func() (bool, error) {
var runtimes imv1.RuntimeList
err := s.k8sKcp.List(context.Background(), &runtimes, client.MatchingLabels{"kyma-project.io/instance-id": iid})
require.NoError(s.t, err)
Expand All @@ -1006,6 +1007,7 @@ func (s *BrokerSuiteTest) failRuntimeByKIM(iid string) {
err = s.k8sKcp.Update(context.Background(), &runtime)
return true, nil
})
require.NoError(s.t, err)
}

func (s *BrokerSuiteTest) FinishDeprovisioningOperationByKIM(opID string) {
Expand Down
4 changes: 2 additions & 2 deletions cmd/broker/deprovisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package main
import (
"encoding/json"
"fmt"
"github.com/stretchr/testify/require"
"io"
"net/http"
"testing"

"github.com/stretchr/testify/require"

"github.com/google/uuid"
"github.com/kyma-project/kyma-environment-broker/common/runtime"
"github.com/pivotal-cf/brokerapi/v8/domain"
Expand All @@ -20,7 +21,6 @@ func TestReDeprovision(t *testing.T) {
// given
cfg := fixConfig()
cfg.EDP.Disabled = true // disable EDP to have all steps successful executed
//cfg.Provisioner.CheckRuntimeResourceDeletionStepTimeout = 10 * time.Millisecond
suite := NewBrokerSuiteTestWithConfig(t, cfg)
defer suite.TearDown()
iid := uuid.New().String()
Expand Down
97 changes: 32 additions & 65 deletions cmd/broker/provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,71 +180,38 @@ func TestProvisioning_HappyPathAWS(t *testing.T) {
suite.AssertKymaLabelNotExists(opID, "kyma-project.io/platform-region")
}

//
//func TestProvisioning_SeedAndShootSameRegion_Disabled(t *testing.T) {
// // given
// suite := NewBrokerSuiteTest(t)
// defer suite.TearDown()
// iid := uuid.New().String()
//
// // when
// resp := suite.CallAPI("PUT", fmt.Sprintf("oauth/v2/service_instances/%s?accepts_incomplete=true", iid),
// `{
// "service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
// "plan_id": "361c511f-f939-4621-b228-d0fb79a1fe15",
// "context": {
// "globalaccount_id": "g-account-id",
// "subaccount_id": "sub-id",
// "user_id": "[email protected]"
// },
// "parameters": {
// "name": "testing-cluster",
// "region": "eu-central-1",
// "shootAndSeedSameRegion": true
// }
// }`)
// opID := suite.DecodeOperationID(resp)
//
// suite.processKIMProvisioningByOperationID(opID)
//
// // then
// suite.WaitForOperationState(opID, domain.Succeeded)
// assert.False(t, suite.provisionerClient.IsSeedAndRegionValidationEnabled())
//}

//func TestProvisioning_SeedAndShootSameRegion_Enabled(t *testing.T) {
// // given
// cfg := fixConfig()
// cfg.Broker.EnableShootAndSeedSameRegion = true
// cfg.Provisioner.EnableShootAndSeedSameRegion = true
// suite := NewBrokerSuiteTestWithConfig(t, cfg)
// defer suite.TearDown()
// iid := uuid.New().String()
//
// // when
// resp := suite.CallAPI("PUT", fmt.Sprintf("oauth/v2/service_instances/%s?accepts_incomplete=true", iid),
// `{
// "service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
// "plan_id": "361c511f-f939-4621-b228-d0fb79a1fe15",
// "context": {
// "globalaccount_id": "g-account-id",
// "subaccount_id": "sub-id",
// "user_id": "[email protected]"
// },
// "parameters": {
// "name": "testing-cluster",
// "region": "eu-central-1",
// "shootAndSeedSameRegion": true
// }
// }`)
// opID := suite.DecodeOperationID(resp)
//
// suite.processKIMProvisioningByOperationID(opID)
//
// // then
// suite.WaitForOperationState(opID, domain.Succeeded)
// assert.True(t, suite.provisionerClient.IsSeedAndRegionValidationEnabled())
//}
func TestProvisioning_SeedAndShootSameRegion(t *testing.T) {
// given
suite := NewBrokerSuiteTest(t)
defer suite.TearDown()
iid := uuid.New().String()

// when
resp := suite.CallAPI("PUT", fmt.Sprintf("oauth/v2/service_instances/%s?accepts_incomplete=true", iid),
`{
"service_id": "47c9dcbf-ff30-448e-ab36-d3bad66ba281",
"plan_id": "361c511f-f939-4621-b228-d0fb79a1fe15",
"context": {
"globalaccount_id": "g-account-id",
"subaccount_id": "sub-id",
"user_id": "[email protected]"
},
"parameters": {
"name": "testing-cluster",
"region": "eu-central-1",
"shootAndSeedSameRegion": false
}
}`)
opID := suite.DecodeOperationID(resp)

suite.processKIMProvisioningByOperationID(opID)

// then
suite.WaitForOperationState(opID, domain.Succeeded)

runtime := suite.GetRuntimeResourceByInstanceID(iid)
assert.False(t, *runtime.Spec.Shoot.EnforceSeedLocation)
}

func TestProvisioning_HappyPathSapConvergedCloud(t *testing.T) {
// given
Expand Down
7 changes: 4 additions & 3 deletions cmd/broker/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ package main

import (
"fmt"
"net/http"
"testing"
"time"

gardener "github.com/gardener/gardener/pkg/apis/core/v1beta1"
"github.com/google/uuid"
"github.com/kyma-project/kyma-environment-broker/internal"
"github.com/kyma-project/kyma-environment-broker/internal/ptr"
"github.com/pivotal-cf/brokerapi/v8/domain"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"net/http"
"testing"
"time"
)

const updateRequestPathFormat = "oauth/v2/service_instances/%s?accepts_incomplete=true"
Expand Down

0 comments on commit fdc3e13

Please sign in to comment.