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

Adding upgrade test for TestCustomGetQuery() in graphql/e2e/custom_logic #8848

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

SiddeshUbale
Copy link
Contributor

Adding upgrade test for TestCustomGetQuery() in graphql/e2e/custom_logic.

Problem:-
1] Added test only for TestCustomGetQuery() function from graphql/e2e/custom_logic.
2] Comments and commented code lines are not yet removed.
3] Some logs which are useful for development are not yet removed.

contrib/Dockerfile Outdated Show resolved Hide resolved
dgraphtest/dgraph.go Outdated Show resolved Hide resolved
dgraphtest/graphql.go Outdated Show resolved Hide resolved
}
}

func Equal(expected interface{}, actual interface{}) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does require.Equal not work?

return reflect.DeepEqual(expected, actual)
}

func (hc *HTTPClient) SafelyUpdateGQLSchema(schema string, alphaPort string) *GqlSchema {
Copy link
Contributor

Choose a reason for hiding this comment

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

We already have UpdateGQLSchema function that is already available in dgraphtest package?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

Copy link
Contributor

Choose a reason for hiding this comment

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

I still see this function here

return nil
}

func (hc *HTTPClient) RetryProbeGraphQL(alphaPort string) *ProbeGraphQLResp {
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably do not need this function. This could be replaced retryProbeGraphQL function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

}
}
if err := json.Unmarshal(updateResp, &updateResult); err != nil {
debug.PrintStack()
Copy link
Contributor

Choose a reason for hiding this comment

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

when we panic, we do not need to call debug.PrintStack()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

RequireNoError(err)
// require.Equalf(t, updateResult.UpdateGQLSchema.GqlSchema.Schema, schema,
// "updateGQLSchema response doesn't reflect the updated schema")
if !Equal(updateResult.UpdateGQLSchema.GqlSchema.Schema, schema) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we not using require.NotEqual?

}
}

func (hc *HTTPClient) updateGQLSchema(alphaPort string, schema string) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this function is already present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

expected := `{"myFavoriteMovies":[{"id":"0x3","name":"Star Wars","director":[{"id":"0x4","name":"George Lucas"}]},{"id":"0x5","name":"Star Trek","director":[{"id":"0x6","name":"J.J. Abrams"}]}]}`
require.JSONEq(t, expected, string(result.Data))
}
// func TestCustomGetQuery(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove these comments so that the diff looks better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Resolved

dgraphtest/dgraph.go Outdated Show resolved Hide resolved

"github.com/dgraph-io/dgraph/dql"
"github.com/dgraph-io/dgraph/x"
"github.com/pkg/errors"
Copy link
Contributor

Choose a reason for hiding this comment

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

fix imports order

Copy link
Contributor

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

reviewed most of the PR. Can you cleanup the rest of the PR and address comments, I will review it again then.

@@ -37,17 +37,20 @@ const (
alphaNameFmt = "%v_alpha%d"
alphaLNameFmt = "alpha%d"
volNameFmt = "%v_%v"
genNameFmt = "%v_mock%d"
Copy link
Contributor

Choose a reason for hiding this comment

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

name should come as part of the config


zeroGrpcPort = "5080"
zeroHttpPort = "6080"
alphaInterPort = "7080"
alphaHttpPort = "8080"
alphaGrpcPort = "9080"
genericPort = "8888"
Copy link
Contributor

Choose a reason for hiding this comment

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

port should come as part of the config too because any other container could expose a different port

}

func (gen *genericContainer) cmd(c *LocalCluster) []string {
zcmd := []string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

could just do return []string{}

DefaultExportDir = "/data/exports"
alphaWorkingDir = "/data/alpha"
zeroWorkingDir = "/data/zero"
genericWorkingDir = "/go/src/cmd"
Copy link
Contributor

Choose a reason for hiding this comment

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

this also has to come as part of the config, could be different for different containers.

type ClusterConfig struct {
prefix string
numAlphas int
numZeros int
genContainers int
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: genCs is also a good name

}

func (gen *genericContainer) healthURL(c *LocalCluster) (string, error) {
publicPort, err := publicPort(c.dcli, gen, genericPort)
Copy link
Contributor

Choose a reason for hiding this comment

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

health URL won't exist for genC

return "http://localhost:" + publicPort + "/health", nil
}

func (gen *genericContainer) assignURL(c *LocalCluster) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Extensions map[string]interface{} `json:"extensions,omitempty"`
}

var safelyUpdateGQLSchemaErr = "New Counter: %v, Old Counter: %v.\n" +
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this?

" retries. The most probable cause is the new GraphQL schema is same as the old" +
" GraphQL schema."

func RequireNoError(err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we already have x.Panic and other functions, we don't need this

return reflect.DeepEqual(expected, actual)
}

func (hc *HTTPClient) SafelyUpdateGQLSchema(schema string, alphaPort string) *GqlSchema {
Copy link
Contributor

Choose a reason for hiding this comment

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

I still see this function here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants