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

[Task] Support the deployment when creating resources. #257

Merged
merged 7 commits into from
Aug 20, 2018

Conversation

hwchiu
Copy link
Contributor

@hwchiu hwchiu commented Aug 17, 2018

  1. Copy from the Pod and add new field (replica) and remove (RestartPolicy).
  2. Use the for DeletePropagationForeground to delete deployment.
  3. Add the bats testing for deployment.

@hwchiu hwchiu changed the title [WIP][Task] Support the deployment when creating resources. [Task] Support the deployment when creating resources. Aug 17, 2018
@codecov-io
Copy link

codecov-io commented Aug 17, 2018

Codecov Report

Merging #257 into develop will increase coverage by 1.46%.
The diff coverage is 86.62%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #257      +/-   ##
===========================================
+ Coverage    78.27%   79.74%   +1.46%     
===========================================
  Files           53       55       +2     
  Lines         2656     3041     +385     
===========================================
+ Hits          2079     2425     +346     
- Misses         438      469      +31     
- Partials       139      147       +8
Impacted Files Coverage Δ
src/kubernetes/deployment.go 86.66% <100%> (+0.95%) ⬆️
src/server/handler_deployment.go 69.36% <69.36%> (ø)
src/server/route.go 84.11% <88.88%> (+0.43%) ⬆️
src/deployment/deployment.go 95.04% <95.04%> (ø)
src/prometheuscontroller/controller.go 88.95% <0%> (+2.36%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0bb56f4...cf6452c. Read the comment docs.

ID bson.ObjectId `bson:"_id,omitempty" json:"id" validate:"-"`
Name string `bson:"name" json:"name" validate:"required,k8sname"`
Namespace string `bson:"namespace" json:"namespace" validate:"required"`
Labels map[string]string `bson:"labels,omitempty" json:"labels" validate:"required,dive,keys,alphanum,endkeys,required,alphanum"`
Copy link
Contributor

Choose a reason for hiding this comment

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

using printascii here?

},
}
tName := namesgenerator.GetRandomName(0)
pod := entity.Deployment{
Copy link
Contributor

Choose a reason for hiding this comment

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

variable name

deployment := entity.Deployment{

NodeAffinity: []string{},
Replicas: 1,
}
bodyBytes, err := json.MarshalIndent(pod, "", " ")
Copy link
Contributor

Choose a reason for hiding this comment

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

bodyBytes, err := json.MarshalIndent(deployment, "", "  ")

httpWriter := httptest.NewRecorder()
suite.wc.Dispatch(httpWriter, httpRequest)
assertResponseCode(suite.T(), http.StatusCreated, httpWriter)
defer suite.session.Remove(entity.DeploymentCollectionName, "name", pod.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

defer suite.session.Remove(entity.DeploymentCollectionName, "name", deployment.Name)


//load data to check
retDeployment := entity.Deployment{}
err = suite.session.FindOne(entity.DeploymentCollectionName, bson.M{"name": pod.Name}, &retDeployment)
Copy link
Contributor

Choose a reason for hiding this comment

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

err = suite.session.FindOne(entity.DeploymentCollectionName, bson.M{"name": deployment.Name}, &retDeployment)

suite.NoError(err)
suite.NotEqual("", retDeployment.ID)
suite.Equal(pod.Name, retDeployment.Name)
suite.Equal(len(pod.Containers), len(retDeployment.Containers))
Copy link
Contributor

Choose a reason for hiding this comment

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

suite.Equal(len(deployment.Containers), len(retDeployment.Containers))

err = json.Unmarshal(httpWriter.Body.Bytes(), &pod)
suite.NoError(err)
suite.Equal(tName, pod.Name)
suite.Equal(len(containers), len(pod.Containers))
Copy link
Contributor

Choose a reason for hiding this comment

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

suite.Equal(len(containers), len(deployment.Containers))

pod = entity.Deployment{}
err = json.Unmarshal(httpWriter.Body.Bytes(), &pod)
suite.NoError(err)
suite.Equal(tName, pod.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

suite.Equal(tName, deployment.Name)

assertResponseCode(suite.T(), http.StatusOK, httpWriter)

pod = entity.Deployment{}
err = json.Unmarshal(httpWriter.Body.Bytes(), &pod)
Copy link
Contributor

Choose a reason for hiding this comment

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

err = json.Unmarshal(httpWriter.Body.Bytes(), &deployment)

},
}
tName := namesgenerator.GetRandomName(0)
pod := entity.Deployment{
Copy link
Contributor

Choose a reason for hiding this comment

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

deployment := entity.Deployment{

@John-Lin John-Lin merged commit 4b51b48 into develop Aug 20, 2018
@John-Lin John-Lin deleted the hwchiu/VX-267 branch August 20, 2018 13:19
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