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

add upgrade tests for systest/license package #8902

Merged
merged 8 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
changes for review comments 2
  • Loading branch information
jbhamra1 committed Jul 14, 2023
commit feacd5baa16ef35bba1e1b830b37a72fc5eccf4e
11 changes: 7 additions & 4 deletions dgraphtest/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type GraphQLParams struct {
type GraphQLResponse struct {
mangalaman93 marked this conversation as resolved.
Show resolved Hide resolved
Data json.RawMessage `json:"data,omitempty"`
Errors x.GqlErrorList `json:"errors,omitempty"`
Code string `json:"code"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
}

Expand All @@ -84,6 +85,7 @@ type Location struct {
Column int `json:"column,omitempty"`
}

/*
mangalaman93 marked this conversation as resolved.
Show resolved Hide resolved
type gqlError struct {
Message string `json:"message"`
Locations []Location `json:"locations,omitempty"`
Expand All @@ -99,6 +101,7 @@ type ZeroResponse struct {
Message string `json:"message"`
License map[string]interface{} `json:"license"`
}
*/

func (hc *HTTPClient) Login(user, password string, ns uint64) error {
login := `mutation login($userId: String, $password: String, $namespace: Int, $refreshToken: String) {
Expand Down Expand Up @@ -551,12 +554,12 @@ func (hc *HTTPClient) PostPersistentQuery(query, sha string) ([]byte, error) {
}

// Apply license using http endpoint
func (hc *HTTPClient) ApplyLicenseHTTP(licenseKey []byte) (*ZeroResponse, error) {
func (hc *HTTPClient) ApplyLicenseHTTP(licenseKey []byte) (*GraphQLResponse, error) {
respBody, err := hc.doPost(licenseKey, hc.licenseURL, "application/json")
if err != nil {
return nil, errors.Wrap(err, "error applying license")
}
var enterpriseResponse ZeroResponse
var enterpriseResponse GraphQLResponse
if err = json.Unmarshal(respBody, &enterpriseResponse); err != nil {
return nil, errors.Wrap(err, "error unmarshaling the license response")
}
Expand All @@ -581,7 +584,7 @@ func (hc *HTTPClient) ApplyLicenseGraphQL(license []byte) ([]byte, error) {
return hc.RunGraphqlQuery(params, true)
}

func (hc *HTTPClient) GetZeroState() (*ZeroResponse, error) {
func (hc *HTTPClient) GetZeroState() (*GraphQLResponse, error) {
response, err := http.Get(hc.stateURL)
if err != nil {
return nil, errors.Wrap(err, "error getting zero state http response")
Expand All @@ -590,7 +593,7 @@ func (hc *HTTPClient) GetZeroState() (*ZeroResponse, error) {
if err != nil {
return nil, errors.New("error reading zero state response body")
}
var stateResponse ZeroResponse
var stateResponse GraphQLResponse
if err := json.Unmarshal(body, &stateResponse); err != nil {
return nil, errors.New("error unmarshaling zero state response")
}
Expand Down
4 changes: 2 additions & 2 deletions systest/license/license_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@ func assertLicenseNotEnabled(t *testing.T, hcli *dgraphtest.HTTPClient, user str
response, err := hcli.GetZeroState()
require.NoError(t, err)

require.Equal(t, response.License["user"], user)
require.Equal(t, response.License["enabled"], false)
require.Equal(t, response.Extensions["user"], user)
require.Equal(t, response.Extensions["enabled"], false)
}