Skip to content

Conversation

@keelerm84
Copy link
Member

This initial commit is quite limited in scope. It updates the existing server-side contract tests to send the FDv2 equivalent payloads to SDKs under tests.

These changes do not include any new tests. Additional commits are required to expand test coverage to include FDv2 specific handling (e.g. xfer-changes, state handling).

It should also be noted these changes have likely broken the client, mobile, PHP, and Roku integrations. That's okay because we will be updating each of those in subsequent commits as well as the FDv2 work progresses.

This initial commit is quite limited in scope. It updates the existing
server-side contract tests to send the FDv2 equivalent payloads to SDKs
under tests.

These changes do not include **any new tests**. Additional commits are
required to expand test coverage to include FDv2 specific handling (e.g.
xfer-changes, state handling).

It should also be noted these changes have likely broken the client,
mobile, PHP, and Roku integrations. That's okay because we will be
updating each of those in subsequent commits as well as the FDv2 work
progresses.
@keelerm84 keelerm84 requested a review from a team as a code owner September 5, 2024 17:44
@keelerm84 keelerm84 requested review from cwaldren-ld and removed request for a team September 5, 2024 17:44
Copy link
Member Author

@keelerm84 keelerm84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a VERY rough first pass at getting the test harness working with FDv2. Lots of todos, but I figure it is better to start getting stuff reviewed and merged so it is accessible to both of us.

@@ -0,0 +1,68 @@
package framework
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same basic types I'm carrying around everywhere right now. Need to get these into the events package or somewhere core.

func (p *PollingService) standardPollingHandler() http.Handler {
return p.pollingHandler(func(p *PollingService, r *http.Request) []byte {
return p.currentData.Serialize()
fdv2SdkData, ok := p.currentData.(FDv2SDKData)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This translation bit is a mess and is going to require the most rework. I wanted to see how the changes emerged as we developed additional FDv2 tests (like the xfer-changes stuff) before I tried to fix this hack too much.

return p.pollingHandler(func(p *PollingService, r *http.Request) []byte {
data, _ := p.currentData.(ServerSDKData)
return data["flags"][mux.Vars(r)["key"]]
// TODO: Update this logic
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP stuff will come later.

"/sdk/latest-all",
)
}
// TODO: Re-enable these tests
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix the unit tests later. Again, just getting something working out in front of you.

Serialize() []byte
}

type FDv2SDKData []framework.BaseObject
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This type may have to be more complex over time. We might need something to control the state, the version, and potential the server intent. That way the serialize method can render the full payload and we don't have to do that hacky translation I called out earlier.

// We use this for both regular server-side SDKs and the PHP SDK.
type ServerSDKData map[DataItemKind]map[string]json.RawMessage

func (s ServerSDKData) AsFDv2SDKData(t *ldtest.T) FDv2SDKData {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data model in the parameterized tests used to match the SDK format. That doesn't work anymore. For now, I do a simple translation. Ideally we would do this when loading the files.

// how we set up the polling endpoints in the mock data source, and that is handled
// transparently by the logic in mockld/polling_service.go based on the fact that the
// "SDK kind" configured for test suite is PHP.
t.Run("parameterized", runParameterizedServerSideEvalTests)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these deserve TODOs? I feel like it could get lost.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can actually add this back in, so we are good there.

}

t.Debug("setting SDK data to: %s", string(data.Serialize()))
jsonStr, _ := json.Marshal(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could check the error, then use t to assert it is nil

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

@keelerm84 keelerm84 force-pushed the mk/sc-254960/fdv2 branch 2 times, most recently from 888419c to 1720df1 Compare September 17, 2024 21:18
@keelerm84 keelerm84 merged commit de408af into feat/fdv2 Sep 17, 2024
@keelerm84 keelerm84 deleted the mk/sc-254960/fdv2 branch September 17, 2024 21:22
keelerm84 added a commit that referenced this pull request Oct 31, 2024
This initial commit is quite limited in scope. It updates the existing
server-side contract tests to send the FDv2 equivalent payloads to SDKs
under tests.

These changes do not include **any new tests**. Additional commits are
required to expand test coverage to include FDv2 specific handling (e.g.
xfer-changes, state handling).

It should also be noted these changes have likely broken the client,
mobile, PHP, and Roku integrations. That's okay because we will be
updating each of those in subsequent commits as well as the FDv2 work
progresses.
keelerm84 added a commit that referenced this pull request Oct 31, 2024
This initial commit is quite limited in scope. It updates the existing
server-side contract tests to send the FDv2 equivalent payloads to SDKs
under tests.

These changes do not include **any new tests**. Additional commits are
required to expand test coverage to include FDv2 specific handling (e.g.
xfer-changes, state handling).

It should also be noted these changes have likely broken the client,
mobile, PHP, and Roku integrations. That's okay because we will be
updating each of those in subsequent commits as well as the FDv2 work
progresses.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants