Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

Commit

Permalink
Fix employee sample
Browse files Browse the repository at this point in the history
  • Loading branch information
anuruddhal authored and Mirage20 committed Jun 25, 2019
1 parent 6d3bc5f commit cfaf498
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,11 @@ public void validateBuildTimeServiceTemplates() {
"team"),
"HR");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().get(0).
getName(), "PORT");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().get(0).
getValue(), "8080");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().get(1).
getName(), "SALARY_HOST");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().get(1).
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().get(0).
getValue(), "{{instance_name}}--salary-service");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getImage(),
"docker.io/celleryio/sampleapp-employee");
"wso2cellery/sampleapp-employee:0.3.0");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getPorts().get(0).
getContainerPort().intValue(), 8080);
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getReplicas(), 1);
Expand Down Expand Up @@ -210,18 +206,12 @@ public void validateRunTimeServiceTemplates() {
"HR");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().
get(0).
getName(), "PORT");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().
get(0).
getValue(), "8080");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().
get(1).
getName(), "SALARY_HOST");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().
get(1).
get(0).
getValue(), "emp-inst--salary-service");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getImage(),
"docker.io/celleryio/sampleapp-employee");
"wso2cellery/sampleapp-employee:0.3.0");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getPorts().
get(0).
getContainerPort().intValue(), 8080);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void validateBuildTimeServiceTemplates() {
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getEnv().get(1).
getName(), "employee_api_url");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getImage(),
"docker.io/celleryio/sampleapp-hr");
"wso2cellery/sampleapp-hr:0.3.0");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getPorts().get(0).
getContainerPort().intValue(), 8080);
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getReplicas(), 1);
Expand Down Expand Up @@ -195,7 +195,7 @@ public void validateRunTimeServiceTemplates() {
.get(1).
getName(), "employee_api_url");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getImage(),
"docker.io/celleryio/sampleapp-hr");
"wso2cellery/sampleapp-hr:0.3.0");
Assert.assertEquals(runtimeCell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getPorts()
.get(0).
getContainerPort().intValue(), 8080);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void validateBuildTimeGatewayTemplate() {
public void validateBuildTimeServiceTemplates() {
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getMetadata().getName(), "stock");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getImage(),
"docker.io/celleryio/sampleapp-stock");
"wso2cellery/sampleapp-stock:0.3.0");
Assert.assertEquals(cell.getSpec().getServicesTemplates().get(0).getSpec().getContainer().getPorts()
.get(0).
getContainerPort().intValue(), 8080);
Expand Down
6 changes: 3 additions & 3 deletions test-cases/employee-portal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Execute the following command to run the image:
$ cellery run myorg/stock:1.0.0
--------------------------------------------------------
$ cellery run myorg/stock:1.0.0
$ cellery run myorg/stock:1.0.0 -n stock
Running cell image: myorg/stock:1.0.0
cell.mesh.cellery.io/stock created
Expand Down Expand Up @@ -76,7 +76,7 @@ Execute the following command to run the image:
$ cellery run myorg/employee:1.0.0
--------------------------------------------------------
$ cellery run myorg/employee:1.0.0
$ cellery run myorg/employee:1.0.0 -n employee
Running cell image: myorg/employee:1.0.0
cell.mesh.cellery.io/employee created
Expand Down Expand Up @@ -108,7 +108,7 @@ Execute the following command to run the image:
$ cellery run myorg/hr:1.0.0
--------------------------------------------------------
2. Execute the following command deploy hr cell.
$ cellery run myorg/hr:1.0.0 -l employee -l stock
$ cellery run myorg/hr:1.0.0 -n hr -l employeeCellDep:employee -l stockCellDep:stock
Above commands will deploy the above three cells in the default namespace. To check the cell status run the following command
$ cellery list instances
Expand Down
7 changes: 2 additions & 5 deletions test-cases/employee-portal/cellery/employee/employee.bal
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function build(cellery:ImageName iName) returns error? {
cellery:Component salaryComponent = {
name: "salary",
source: {
image: "docker.io/celleryio/sampleapp-salary"
image: "wso2cellery/sampleapp-salary:0.3.0"
},
ingresses: {
SalaryAPI: <cellery:HttpApiIngress>{
Expand All @@ -38,7 +38,7 @@ public function build(cellery:ImageName iName) returns error? {
cellery:Component employeeComponent = {
name: "employee",
source: {
image: "docker.io/celleryio/sampleapp-employee"
image: "wso2cellery/sampleapp-employee:0.3.0"
},
ingresses: {
employee: <cellery:HttpApiIngress>{
Expand All @@ -51,9 +51,6 @@ public function build(cellery:ImageName iName) returns error? {
envVars: {
SALARY_HOST: {
value: cellery:getHost(salaryComponent)
},
PORT: {
value: salaryContainerPort
}
},
labels: {
Expand Down
2 changes: 1 addition & 1 deletion test-cases/employee-portal/cellery/hr/hr.bal
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public function build(cellery:ImageName iName) returns error? {
cellery:Component hrComponent = {
name: "hr",
source: {
image: "docker.io/celleryio/sampleapp-hr"
image: "wso2cellery/sampleapp-hr:0.3.0"
},
ingresses: {
"hr": <cellery:HttpApiIngress>{
Expand Down
2 changes: 1 addition & 1 deletion test-cases/employee-portal/cellery/stock/stocks.bal
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function build(cellery:ImageName iName) returns error? {
cellery:Component stockComponent = {
name: "stock",
source: {
image: "docker.io/celleryio/sampleapp-stock"
image: "wso2cellery/sampleapp-stock:0.3.0"
},
ingresses: {
stock: <cellery:HttpApiIngress>{ port: 8080,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ service<http:Service> employee bind { port: 8080 } {
log:printInfo(empName);
if (employeeIdMap.hasKey(empName)) {
json employeeIdJson = { id: employeeIdMap[empName], designation: employeeDesignationMap[empName] };

string salaryServiceName = system:getEnv("SALARY");
string salaryServiceName = system:getEnv("SALARY_HOST");

json salaryDetails = getSalaryDetails(empName, salaryServiceName, untaint req);
employeeIdJson.salary = salaryDetails.salary;
Expand Down

0 comments on commit cfaf498

Please sign in to comment.