server_test.go 16.8 KB
Newer Older
1 2 3 4 5 6 7 8
package http

import (
	"bytes"
	"context"
	"encoding/json"
	"fmt"
	"net/http"
L
liqingping 已提交
9
	"strconv"
L
liqingping 已提交
10
	"strings"
11 12 13 14
	"time"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
L
liqingping 已提交
15 16
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/resource"
17 18 19
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"sigs.k8s.io/controller-runtime/pkg/client"

L
liqingping 已提交
20
	div1alpha1 "opendilab.org/di-orchestrator/api/v1alpha1"
L
liqingping 已提交
21
	dicommon "opendilab.org/di-orchestrator/common"
L
liqingping 已提交
22 23 24
	servertypes "opendilab.org/di-orchestrator/server/types"
	diutil "opendilab.org/di-orchestrator/utils"
	testutil "opendilab.org/di-orchestrator/utils/testutils"
25 26 27 28
)

var _ = Describe("Server Test", func() {
	Context("When send request to server", func() {
L
liqingping 已提交
29
		It("Should have correct response when request /v1alpha1/replicas and /v1alpha1/replicas/failed", func() {
L
liqingping 已提交
30 31
			job := testutil.NewDIJob()
			name := diutil.GenerateName(job.Name)
32 33
			job.SetName(name)

L
liqingping 已提交
34
			By(fmt.Sprintf("Create %dth DIJob", 1))
35 36
			var err error
			ctx := context.Background()
L
liqingping 已提交
37
			err = creatDIJob(ctx, job)
38 39 40
			Expect(err).NotTo(HaveOccurred())

			By("Send request on POST /v1alpha1/replicas")
L
liqingping 已提交
41
			coorname := diutil.ReplicaPodName(job.Name, "coordinator")
42 43 44
			addr := fmt.Sprintf("%s:%d", localServingHost, localServingPort)
			rurl := fmt.Sprintf("http://%s/v1alpha1/replicas", addr)
			var cn, ln int = 2, 3
L
liqingping 已提交
45
			req := servertypes.DIJobRequest{
46 47 48 49 50 51 52 53 54
				Namespace:   job.Namespace,
				Coordinator: coorname,
				Collectors: servertypes.ResourceQuantity{
					Replicas: cn,
				},
				Learners: servertypes.ResourceQuantity{
					Replicas: ln,
				},
			}
L
liqingping 已提交
55 56
			rbody, err := json.Marshal(req)
			Expect(err).NotTo(HaveOccurred())
57

L
liqingping 已提交
58
			njresp, err := sendRequest(http.MethodPost, rbody, rurl, http.StatusOK, true)
59 60 61 62 63 64 65 66 67
			Expect(err).NotTo(HaveOccurred())

			Expect(len(njresp.Collectors)).Should(Equal(cn))
			Expect(len(njresp.Learners)).Should(Equal(ln))

			By("Send request on GET /v1alpha1/replicas")
			gurl := fmt.Sprintf("%s?namespace=%s&coordinator=%s", rurl, job.Namespace, coorname)
			resp, err := http.Get(gurl)
			Expect(err).NotTo(HaveOccurred())
L
liqingping 已提交
68
			gnjresp, err := parseResponse(resp, http.StatusOK, true)
69 70 71 72
			Expect(err).NotTo(HaveOccurred())
			Expect(len(gnjresp.Collectors)).Should(Equal(cn))
			Expect(len(gnjresp.Learners)).Should(Equal(ln))

L
liqingping 已提交
73 74
			By("Send request on POST /v1alpha1/replicas/failed")
			furl := fmt.Sprintf("http://%s/v1alpha1/replicas/failed", addr)
L
liqingping 已提交
75
			freq := servertypes.DIJobResponse{
L
liqingping 已提交
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
				Namespace:   job.Namespace,
				Coordinator: coorname,
				Collectors: []string{
					strings.Split(gnjresp.Collectors[0], ".")[0],
				},
				Learners: []string{
					strings.Split(gnjresp.Learners[0], ".")[0],
				},
			}
			frbody, err := json.Marshal(freq)
			Expect(err).NotTo(HaveOccurred())
			fnjresp, err := sendRequest(http.MethodPost, frbody, furl, http.StatusOK, true)
			Expect(err).NotTo(HaveOccurred())
			Expect(len(fnjresp.Collectors)).Should(Equal(1))
			Expect(len(fnjresp.Learners)).Should(Equal(1))

			By("Waiting for server's cache to be synced")
			time.Sleep(250 * time.Millisecond)

			By("Checking the number of pods has not changed")
			totalPods := cn + ln + 1 // collectors + learners + coordinator
			Eventually(func() int {
L
liqingping 已提交
98
				pods, err := diutil.ListPods(ctx, k8sClient, job)
L
liqingping 已提交
99 100 101 102 103 104
				if err != nil {
					return -1
				}
				return len(pods)
			}, timeout, interval).Should(Equal(totalPods))

105 106
			By("Send request on DELETE /v1alpha1/replicas")
			var dcn, dln int = 1, 1
L
liqingping 已提交
107
			dreq := servertypes.DIJobRequest{
108 109 110 111 112 113 114 115 116
				Namespace:   job.Namespace,
				Coordinator: coorname,
				Collectors: servertypes.ResourceQuantity{
					Replicas: dcn,
				},
				Learners: servertypes.ResourceQuantity{
					Replicas: dln,
				},
			}
L
liqingping 已提交
117 118 119 120
			drbody, err := json.Marshal(dreq)
			Expect(err).NotTo(HaveOccurred())

			dnjresp, err := sendRequest(http.MethodDelete, drbody, rurl, http.StatusOK, true)
121 122 123
			Expect(err).NotTo(HaveOccurred())
			Expect(len(dnjresp.Collectors)).Should(Equal(dcn))
			Expect(len(dnjresp.Learners)).Should(Equal(dln))
L
liqingping 已提交
124

L
liqingping 已提交
125
			err = testutil.CleanUpJob(ctx, k8sClient, job.DeepCopy())
L
liqingping 已提交
126 127 128 129
			Expect(err).NotTo(HaveOccurred())
		})

		It("Should have matched responses when requests are refused", func() {
L
liqingping 已提交
130 131
			job := testutil.NewDIJob()
			name := diutil.GenerateName(job.Name)
L
liqingping 已提交
132 133
			job.SetName(name)

L
liqingping 已提交
134
			By(fmt.Sprintf("Create %dth DIJob", 1))
L
liqingping 已提交
135 136
			var err error
			ctx := context.Background()
L
liqingping 已提交
137
			err = creatDIJob(ctx, job)
L
liqingping 已提交
138 139 140 141 142 143 144 145 146 147 148
			Expect(err).NotTo(HaveOccurred())

			addr := fmt.Sprintf("%s:%d", localServingHost, localServingPort)

			By("Send request on /healthz")
			hurl := fmt.Sprintf("http://%s/healthz", addr)
			hresp, err := http.Get(hurl)
			Expect(err).NotTo(HaveOccurred())
			Expect(hresp.StatusCode).Should(Equal(http.StatusOK))

			By("Send request on POST /v1alpha1/replicas")
L
liqingping 已提交
149
			coorname := diutil.ReplicaPodName(job.Name, "coordinator")
L
liqingping 已提交
150 151
			rurl := fmt.Sprintf("http://%s/v1alpha1/replicas", addr)
			var cn, ln int = 2, 3
L
liqingping 已提交
152
			req := servertypes.DIJobRequest{
L
liqingping 已提交
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
				Namespace:   job.Namespace,
				Coordinator: coorname,
				Collectors: servertypes.ResourceQuantity{
					Replicas: cn,
				},
				Learners: servertypes.ResourceQuantity{
					Replicas: ln,
				},
			}
			rbody, err := json.Marshal(req)
			Expect(err).NotTo(HaveOccurred())

			njresp, err := sendRequest(http.MethodPost, rbody, rurl, http.StatusOK, true)
			Expect(err).NotTo(HaveOccurred())

			Expect(len(njresp.Collectors)).Should(Equal(cn))
			Expect(len(njresp.Learners)).Should(Equal(ln))

			By("Send not found resource on POST /v1alpha1/replicas")
			req.Coordinator = "not-exists"
			rbody, err = json.Marshal(req)
			Expect(err).NotTo(HaveOccurred())

			By("Send bad request on POST /v1alpha1/replicas")
			_, err = sendRequest(http.MethodPost, rbody, rurl, http.StatusNotFound, false)
			Expect(err).NotTo(HaveOccurred())

			By("Send not implemented method on /v1alpha1/replicas")
			_, err = sendRequest(http.MethodPatch, rbody, rurl, http.StatusNotImplemented, false)
			Expect(err).NotTo(HaveOccurred())

			rbody = []byte{}
			_, err = sendRequest(http.MethodPost, rbody, rurl, http.StatusBadRequest, false)
			Expect(err).NotTo(HaveOccurred())

			By("Send request on GET /v1alpha1/replicas with namespace and coordinator")
			gurl := fmt.Sprintf("%s?namespace=%s&coordinator=%s", rurl, job.Namespace, coorname)
			resp, err := http.Get(gurl)
			Expect(err).NotTo(HaveOccurred())
			gnjresp, err := parseResponse(resp, http.StatusOK, true)
			Expect(err).NotTo(HaveOccurred())
			Expect(len(gnjresp.Collectors)).Should(Equal(cn))
			Expect(len(gnjresp.Learners)).Should(Equal(ln))

			By("Send request on GET /v1alpha1/replicas with namespace")
			gurl = fmt.Sprintf("%s?namespace=%s", rurl, job.Namespace)
			resp, err = http.Get(gurl)
			Expect(err).NotTo(HaveOccurred())
			defer resp.Body.Close()
			var nresp servertypes.Response
			err = json.NewDecoder(resp.Body).Decode(&nresp)
			Expect(err).NotTo(HaveOccurred())
			Expect(resp.StatusCode).Should(Equal(http.StatusOK))
			Expect(nresp.Success).Should(BeTrue())

			By("Send request on GET /v1alpha1/replicas")
			gurl = rurl
			resp, err = http.Get(gurl)
			Expect(err).NotTo(HaveOccurred())
			defer resp.Body.Close()
			err = json.NewDecoder(resp.Body).Decode(&nresp)
			Expect(err).NotTo(HaveOccurred())
			Expect(resp.StatusCode).Should(Equal(http.StatusOK))
			Expect(nresp.Success).Should(BeTrue())

			By("Send request on POST /v1alpha1/replicas/failed")
			furl := fmt.Sprintf("http://%s/v1alpha1/replicas/failed", addr)
L
liqingping 已提交
220
			freq := servertypes.DIJobResponse{
L
liqingping 已提交
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
				Namespace:   job.Namespace,
				Coordinator: coorname,
				Collectors: []string{
					strings.Split(gnjresp.Collectors[0], ".")[0],
				},
				Learners: []string{
					strings.Split(gnjresp.Learners[0], ".")[0],
				},
			}
			frbody, err := json.Marshal(freq)
			Expect(err).NotTo(HaveOccurred())
			fnjresp, err := sendRequest(http.MethodPost, frbody, furl, http.StatusOK, true)
			Expect(err).NotTo(HaveOccurred())
			Expect(len(fnjresp.Collectors)).Should(Equal(1))
			Expect(len(fnjresp.Learners)).Should(Equal(1))

			By("Waiting for server's cache to be synced")
			time.Sleep(250 * time.Millisecond)

			By("Checking the number of pods has not changed")
			totalPods := cn + ln + 1 // collectors + learners + coordinator
			Eventually(func() int {
L
liqingping 已提交
243
				pods, err := diutil.ListPods(ctx, k8sClient, job)
L
liqingping 已提交
244 245 246 247 248 249
				if err != nil {
					return -1
				}
				return len(pods)
			}, timeout, interval).Should(Equal(totalPods))

250 251
			By("Send request on POST /v1alpha1/replicas/failed with duplicate replicas")
			fdurl := fmt.Sprintf("http://%s/v1alpha1/replicas/failed", addr)
L
liqingping 已提交
252
			fdreq := servertypes.DIJobResponse{
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276
				Namespace:   job.Namespace,
				Coordinator: coorname,
				Collectors: []string{
					strings.Split(gnjresp.Collectors[1], ".")[0],
					strings.Split(gnjresp.Collectors[1], ".")[0],
				},
				Learners: []string{
					strings.Split(gnjresp.Learners[1], ".")[0],
					strings.Split(gnjresp.Learners[1], ".")[0],
				},
			}
			fdrbody, err := json.Marshal(fdreq)
			Expect(err).NotTo(HaveOccurred())
			fdnjresp, err := sendRequest(http.MethodPost, fdrbody, fdurl, http.StatusOK, true)
			Expect(err).NotTo(HaveOccurred())
			Expect(len(fdnjresp.Collectors)).Should(Equal(1))
			Expect(len(fdnjresp.Learners)).Should(Equal(1))

			By("Waiting for server's cache to be synced")
			time.Sleep(250 * time.Millisecond)

			By("Checking the number of pods has not changed")
			dtotalPods := cn + ln + 1 // collectors + learners + coordinator
			Eventually(func() int {
L
liqingping 已提交
277
				pods, err := diutil.ListPods(ctx, k8sClient, job)
278 279 280 281 282 283
				if err != nil {
					return -1
				}
				return len(pods)
			}, timeout, interval).Should(Equal(dtotalPods))

L
liqingping 已提交
284 285
			By("Send request on DELETE /v1alpha1/replicas")
			var dcn, dln int = 1, 1
L
liqingping 已提交
286
			dreq := servertypes.DIJobRequest{
L
liqingping 已提交
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
				Namespace:   job.Namespace,
				Coordinator: coorname,
				Collectors: servertypes.ResourceQuantity{
					Replicas: dcn,
				},
				Learners: servertypes.ResourceQuantity{
					Replicas: dln,
				},
			}
			drbody, err := json.Marshal(dreq)
			Expect(err).NotTo(HaveOccurred())

			dnjresp, err := sendRequest(http.MethodDelete, drbody, rurl, http.StatusOK, true)
			Expect(err).NotTo(HaveOccurred())
			Expect(len(dnjresp.Collectors)).Should(Equal(dcn))
			Expect(len(dnjresp.Learners)).Should(Equal(dln))

L
liqingping 已提交
304
			err = testutil.CleanUpJob(ctx, k8sClient, job.DeepCopy())
L
liqingping 已提交
305
			Expect(err).NotTo(HaveOccurred())
306
		})
L
liqingping 已提交
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330

		It("Should have right replicas created when request gpu for learner", func() {
			addr := fmt.Sprintf("%s:%d", localServingHost, localServingPort)

			type testCase struct {
				ln                   int
				gpus                 int
				expectedAgg          int
				expectedLearner      int
				expectedDDPL         int
				expectedDDPLSvcPorts int
			}
			testCases := []testCase{
				// learner requests 1 gpu, so no agg or ddpl is created.
				{ln: 1, gpus: 1, expectedAgg: 0, expectedLearner: 1, expectedDDPL: 0, expectedDDPLSvcPorts: 0},
				// learner requests 2 gpus, so we need to create an agg and a ddpl.
				{ln: 1, gpus: 2, expectedAgg: 1, expectedLearner: 0, expectedDDPL: 1, expectedDDPLSvcPorts: 2},
				// learner requests 10 gpus, so we need to create an agg and 2 ddpl, one ddpl with 8 gpus and the other ddpl with 2 gpus.
				{ln: 1, gpus: 10, expectedAgg: 1, expectedLearner: 0, expectedDDPL: 2, expectedDDPLSvcPorts: 10},
				// learner requests 2 gpus, so we need to create an agg and a ddpl.
				{ln: 2, gpus: 2, expectedAgg: 2, expectedLearner: 0, expectedDDPL: 2, expectedDDPLSvcPorts: 4},
			}
			for i := range testCases {
				c := testCases[i]
L
liqingping 已提交
331 332
				job := testutil.NewDIJob()
				name := diutil.GenerateName(job.Name)
L
liqingping 已提交
333 334
				job.SetName(name)

L
liqingping 已提交
335
				By(fmt.Sprintf("Create %dth DIJob", i+1))
L
liqingping 已提交
336 337
				var err error
				ctx := context.Background()
L
liqingping 已提交
338
				err = creatDIJob(ctx, job)
L
liqingping 已提交
339 340 341
				Expect(err).NotTo(HaveOccurred())

				By("Send request on POST /v1alpha1/replicas")
L
liqingping 已提交
342
				coorname := diutil.ReplicaPodName(job.Name, "coordinator")
L
liqingping 已提交
343 344
				rurl := fmt.Sprintf("http://%s/v1alpha1/replicas", addr)
				var ln int = c.ln
L
liqingping 已提交
345
				req := servertypes.DIJobRequest{
L
liqingping 已提交
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
					Namespace:   job.Namespace,
					Coordinator: coorname,
					Learners: servertypes.ResourceQuantity{
						Replicas: ln,
						GPU:      resource.MustParse(strconv.Itoa(c.gpus)),
					},
				}
				rbody, err := json.Marshal(req)
				Expect(err).NotTo(HaveOccurred())

				njresp, err := sendRequest(http.MethodPost, rbody, rurl, http.StatusOK, true)
				Expect(err).NotTo(HaveOccurred())

				// # of learners must be as expected
				Expect(len(njresp.Learners)).Should(Equal(ln))

				// # of ddp learners must as expected
				var ddpLearners corev1.PodList
L
liqingping 已提交
364
				err = k8sClient.List(ctx, &ddpLearners, client.MatchingLabels{dicommon.ReplicaTypeLabel: dicommon.DDPLearnerName})
L
liqingping 已提交
365 366 367 368 369
				Expect(err).NotTo(HaveOccurred())
				Expect(len(ddpLearners.Items)).Should(Equal(c.expectedDDPL))

				// # of aggregators must be as expected
				var aggs corev1.PodList
L
liqingping 已提交
370
				err = k8sClient.List(ctx, &aggs, client.MatchingLabels{dicommon.ReplicaTypeLabel: dicommon.AggregatorName})
L
liqingping 已提交
371 372 373 374 375
				Expect(err).NotTo(HaveOccurred())
				Expect(len(aggs.Items)).Should(Equal(c.expectedAgg))

				// # of ddp learner service ports must be as expected
				var svcs corev1.ServiceList
L
liqingping 已提交
376
				err = k8sClient.List(ctx, &svcs, client.MatchingLabels{dicommon.ReplicaTypeLabel: dicommon.DDPLearnerName})
L
liqingping 已提交
377 378 379 380
				Expect(err).NotTo(HaveOccurred())
				portCount := 0
				for _, svc := range svcs.Items {
					portCount += len(svc.Spec.Ports)
381 382 383 384 385
					for _, port := range svc.Spec.Ports {
						if port.Name == "master-port" {
							portCount--
						}
					}
L
liqingping 已提交
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
				}
				Expect(portCount).Should(Equal(c.expectedDDPLSvcPorts))

				By("Send request on GET /v1alpha1/replicas with namespace and coordinator")
				gurl := fmt.Sprintf("%s?namespace=%s&coordinator=%s", rurl, job.Namespace, coorname)
				resp, err := http.Get(gurl)
				Expect(err).NotTo(HaveOccurred())
				gnjresp, err := parseResponse(resp, http.StatusOK, true)
				Expect(err).NotTo(HaveOccurred())
				// expect # of learners to be equal to learner+aggregator
				Expect(len(gnjresp.Learners)).Should(Equal(c.expectedLearner + c.expectedAgg))

				if len(aggs.Items) > 0 {
					By("Send request on GET /v1alpha1/replicas with namespace and aggregator")
					agg := aggs.Items[0]
					aurl := fmt.Sprintf("%s?namespace=%s&aggregator=%s", rurl, job.Namespace, agg.Name)
					aresp, err := http.Get(aurl)
					Expect(err).NotTo(HaveOccurred())
					anjresp, err := parseResponse(aresp, http.StatusOK, true)
					Expect(err).NotTo(HaveOccurred())
					// expect # of learners to be equal to ddp learners
					expectedDDPLs := c.expectedDDPLSvcPorts / c.ln
					Expect(len(anjresp.Learners)).Should(Equal(expectedDDPLs))
				}

				By("Send request on DELETE /v1alpha1/replicas")
				var dln int = 1
L
liqingping 已提交
413
				dreq := servertypes.DIJobRequest{
L
liqingping 已提交
414 415 416 417 418 419 420 421 422 423 424 425 426
					Namespace:   job.Namespace,
					Coordinator: coorname,
					Learners: servertypes.ResourceQuantity{
						Replicas: dln,
					},
				}
				drbody, err := json.Marshal(dreq)
				Expect(err).NotTo(HaveOccurred())

				dnjresp, err := sendRequest(http.MethodDelete, drbody, rurl, http.StatusOK, true)
				Expect(err).NotTo(HaveOccurred())
				Expect(len(dnjresp.Learners)).Should(Equal(dln))

427
				err = testutil.CleanUpJob(ctx, k8sClient, job.DeepCopy())
L
liqingping 已提交
428 429 430
				Expect(err).NotTo(HaveOccurred())
			}
		})
431 432 433
	})
})

L
liqingping 已提交
434
func creatDIJob(ctx context.Context, job *div1alpha1.DIJob) error {
435 436 437 438 439 440 441 442
	var err error
	err = k8sClient.Create(ctx, job, &client.CreateOptions{})
	if err != nil {
		return err
	}

	By("Create coordinator")
	ownRefer := metav1.OwnerReference{
L
liqingping 已提交
443 444
		APIVersion: div1alpha1.GroupVersion.String(),
		Kind:       div1alpha1.KindDIJob,
445 446 447 448
		Name:       job.Name,
		UID:        job.GetUID(),
		Controller: func(c bool) *bool { return &c }(true),
	}
L
liqingping 已提交
449
	coorname := diutil.ReplicaPodName(job.Name, "coordinator")
450
	coorpod := testutil.NewPod(coorname, job.Name, ownRefer)
L
liqingping 已提交
451
	lbs := diutil.GenLabels(job.Name)
L
liqingping 已提交
452 453
	coorpod.SetLabels(lbs)

454 455 456 457 458 459 460 461 462 463
	err = k8sClient.Create(ctx, coorpod, &client.CreateOptions{})
	if err != nil {
		return err
	}

	By("Waiting for server's cache to be synced")
	time.Sleep(250 * time.Millisecond)
	return nil
}

L
liqingping 已提交
464
func sendRequest(method string, rbody []byte, url string, expectedCode int, expectedSuccess bool) (*servertypes.DIJobResponse, error) {
465 466 467 468 469 470 471 472 473 474 475 476 477 478

	// Create client
	reqs, err := http.NewRequest(method, url, bytes.NewReader(rbody))
	if err != nil {
		return nil, err
	}
	reqs.Header.Add("Content-Type", "application/json")

	// Fetch Request
	resp, err := http.DefaultClient.Do(reqs)
	if err != nil {
		return nil, err
	}

L
liqingping 已提交
479
	return parseResponse(resp, expectedCode, expectedSuccess)
480 481
}

L
liqingping 已提交
482
func parseResponse(resp *http.Response, expectedCode int, expectedSuccess bool) (*servertypes.DIJobResponse, error) {
483 484 485 486 487 488 489
	defer resp.Body.Close()
	var nresp servertypes.Response
	err := json.NewDecoder(resp.Body).Decode(&nresp)
	if err != nil {
		return nil, err
	}

L
liqingping 已提交
490 491
	Expect(resp.StatusCode).Should(Equal(expectedCode))
	Expect(nresp.Success).Should(Equal(expectedSuccess))
492

L
liqingping 已提交
493
	var njresp servertypes.DIJobResponse
494 495 496 497 498 499 500 501 502 503
	jsonBytes, err := json.Marshal(nresp.Data)
	if err != nil {
		return nil, err
	}
	err = json.Unmarshal(jsonBytes, &njresp)
	if err != nil {
		return nil, err
	}
	return &njresp, nil
}