Hello devs, i am creating unit tests for the describe package in meshkit,
Here is the link to my pr K8 Unit tests by Philip-21 · Pull Request #319 · meshery/meshkit · GitHub
The main goal of this testcase is to test the describe()
which takes in a mesh client and k8 resource options .
When running the testcase it gave this error message ,
“A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.”
i dont know if the issue is from the request url or the response in my testcase struct , i had minikube and kubectl running locally while performing the tests case and it gave this error,
Initially, i also tried using a fake client as a testcase
`
// Create a fake clientset
clientset := fake.NewSimpleClientset()
// Convert clientset to JSON
obj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(clientset)
if err != nil {
log.Fatalf("Failed to convert clientset to unstructured: %v", err)
}
jsonBytes, err := json.Marshal(obj)
if err != nil {
log.Fatalf("Failed to marshal clientset to JSON: %v", err)
}
meshclient, err := meshkitkube.New(jsonBytes)
if err != nil {
log.Println("error in loading Kube configs for tests", err)
}`
but i got errors because it couldnt convert some certain aspects of the fake client to []bytes which will be used as a parameter for the meshkit.New()
that will be used and initaized in the describe()
.
Since Kubernetes unit test does not necessarily require a yml file and yml files are mainly for deployment , the Unit tests are meant to be typically focused on testing individual functions or components in isolation rather than interacting with actual Kubernetes clusters, and our main focus is testing the describe()
, but on testing the describe()
we need to initialize a meshclient, and the meshclient requires me to use a yml file.
Please i really need help in figuring this out