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

Json match throws error due to spec attribute mismatch on windows 3.11 cluster #3499

Closed
prietyc123 opened this issue Jul 7, 2020 · 11 comments
Assignees
Labels
area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering kind/bug Categorizes issue or PR as related to a bug.

Comments

@prietyc123
Copy link
Contributor

prietyc123 commented Jul 7, 2020

/kind bug

What versions of software are you using?

Operating System:
Win10

Output of odo version:
master

How did you run odo exactly?

Ran make test-cmd-cmp on windows 3.11 cluster

Actual behavior

> make test-cmd-cmp
Running Suite: Integration Suite
================================
Random Seed: 1594114879
Will run 2 of 177 specs

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSCreated dir: C:\Users\Admin\AppData\Local\Temp\798876515
Creating a new project: beieqxrocp
Running odo.exe with args [odo project create beieqxrocp -w -v4]
[odo]  -  Waiting for project to come up  ...
[odo] I0707 09:41:27.024903    2456 occlient.go:543] Status of creation of project beieqxrocp is Active
[odo] I0707 09:41:27.118935    2456 occlient.go:548] Project beieqxrocp now exists
[odo] I0707 09:41:27.122898    2456 occlient.go:583] Status of creation of service account &ServiceAccount{ObjectMeta:{default  beieqxrocp /api/v1/namespaces/beieqxrocp/serviceaccounts/default 41a87758-c035-11ea-b0ca-fa163e9b6334 18848962 0 2020-07-07 09:35:55 +0000 GMT <nil> <nil> map[] map[] [] []  []},Secrets:[]ObjectReference{ObjectReference{Kind:,Namespace:,Name:default-token-6p9ks,UID:,APIVersion:,ResourceVersion:,FieldPath:,},ObjectReference{Kind:,Namespace:,Name:default-dockercfg-9xs8k,UID:,APIVersion:,ResourceVersion:,FieldPath:,},},ImagePullSecrets:[]LocalObjectReference{LocalObjectReference{Name:default-dockercfg-9xs8k,},},AutomountServiceAccountToken:nil,} is ready
 V  Waiting for project to come up [245ms]
[odo]  V  Project 'beieqxrocp' is ready for use
[odo]  V  New project created and now using project: beieqxrocp
[odo] I0707 09:41:27.158306    2456 odo.go:72] Could not get the latest release information in time. Never mind, exiting gracefully :)
Current working dir: C:\Users\Admin\go\src\github.com\openshift\odo\tests\integration
Setting current dir to: C:\Users\Admin\AppData\Local\Temp\798876515
Running odo.exe with args [odo create nodejs cmp-git --project beieqxrocp --git https://github.com/openshift/nodejs-ex --context C:\Users\Admin\AppData\Local\Temp\798876515 --app testing]
[odo] Validation
 V  Validating component [7ms]
[odo]
[odo] Please use `odo push` command to create the component with source deployed
Running odo.exe with args [odo url create url-1 --context C:\Users\Admin\AppData\Local\Temp\798876515]
[odo]  V  URL url-1 created for component: cmp-git
[odo]
[odo] To apply the URL configuration changes, please use `odo push`
Running odo.exe with args [odo url create url-2 --context C:\Users\Admin\AppData\Local\Temp\798876515]
[odo]  V  URL url-2 created for component: cmp-git
[odo]
[odo] To apply the URL configuration changes, please use `odo push`
Running odo.exe with args [odo storage create storage-1 --size 1Gi --path /data1 --context C:\Users\Admin\AppData\Local\Temp\798876515]
[odo]  V  Added storage storage-1 to cmp-git
[odo]
[odo] Please use `odo push` command to make the storage accessible to the component
Running odo.exe with args [odo describe --context C:\Users\Admin\AppData\Local\Temp\798876515]
[odo] Component Name: cmp-git
[odo] Type: nodejs
[odo] Source: https://github.com/openshift/nodejs-ex
[odo] Storage:
[odo]  · storage-1 of size 1Gi mounted to /data1
[odo] URLs:
[odo]  · URL named url-1 will be exposed via 8080/TCP
[odo]  · URL named url-2 will be exposed via 8080/TCP
Running odo.exe with args [odo describe -o json --context C:\Users\Admin\AppData\Local\Temp\798876515]
[odo] {
[odo]     "kind": "Component",
[odo]     "apiVersion": "odo.dev/v1alpha1",
[odo]     "metadata": {
[odo]         "name": "cmp-git",
[odo]         "namespace": "beieqxrocp",
[odo]         "creationTimestamp": null
[odo]     },
[odo]     "spec": {
[odo]         "app": "testing",
[odo]         "type": "nodejs",
[odo]         "source": "https://github.com/openshift/nodejs-ex",
[odo]         "sourceType": "git",
[odo]         "urls": {
[odo]             "kind": "List",
[odo]             "apiVersion": "odo.dev/v1alpha1",
[odo]             "metadata": {},
[odo]             "items": [
[odo]                 {
[odo]                     "kind": "url",
[odo]                     "apiVersion": "odo.dev/v1alpha1",
[odo]                     "metadata": {
[odo]                         "name": "url-1",
[odo]                         "creationTimestamp": null
[odo]                     },
[odo]                     "spec": {
[odo]                         "port": 8080,
[odo]                         "secure": false
[odo]                     },
[odo]                     "status": {
[odo]                         "state": "Not Pushed"
[odo]                     }
[odo]                 },
[odo]                 {
[odo]                     "kind": "url",
[odo]                     "apiVersion": "odo.dev/v1alpha1",
[odo]                     "metadata": {
[odo]                         "name": "url-2",
[odo]                         "creationTimestamp": null
[odo]                     },
[odo]                     "spec": {
[odo]                         "port": 8080,
[odo]                         "secure": false
[odo]                     },
[odo]                     "status": {
[odo]                         "state": "Not Pushed"
[odo]                     }
[odo]                 }
[odo]             ]
[odo]         },
[odo]         "storages": {
[odo]             "kind": "List",
[odo]             "apiVersion": "odo.dev/v1alpha1",
[odo]             "metadata": {},
[odo]             "items": [
[odo]                 {
[odo]                     "kind": "storage",
[odo]                     "apiVersion": "odo.dev/v1alpha1",
[odo]                     "metadata": {
[odo]                         "name": "storage-1",
[odo]                         "creationTimestamp": null
[odo]                     },
[odo]                     "spec": {
[odo]                         "size": "1Gi",
[odo]                         "path": "/data1"
[odo]                     }
[odo]                 }
[odo]             ]
[odo]         },
[odo]         "ports": [
[odo]             "8080/TCP"
[odo]         ]
[odo]     },
[odo]     "status": {
[odo]         "state": "Not Pushed"
[odo]     }
[odo] }
Deleting project: beieqxrocp
Running odo.exe with args [odo project delete beieqxrocp -f]
[odo]  V  Deleted project : beieqxrocp
[odo]  !  Warning! Projects are deleted from the cluster asynchronously. Odo does its best to delete the project. Due to multi-tenant clusters, the project 
may still exist on a different node.
Setting current dir to: C:\Users\Admin\go\src\github.com\openshift\odo\tests\integration
Deleting dir: C:\Users\Admin\AppData\Local\Temp\798876515

------------------------------
+ Failure [2.764 seconds]
odo component command tests
C:/Users/Admin/go/src/github.com/openshift/odo/tests/integration/cmd_cmp_test.go:13
  Creating component
  C:/Users/Admin/go/src/github.com/openshift/odo/tests/integration/component.go:52
    should describe the component when it is not pushed [It]
    C:/Users/Admin/go/src/github.com/openshift/odo/tests/integration/component.go:233

    Expected
        <string>: "...c":{"port":..."
    to equal               |
        <string>: "...c":{"kind":..."

    C:/Users/Admin/go/src/github.com/openshift/odo/tests/integration/component.go:253
------------------------------
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS

Expected behavior

On windows odo describe -o json --context <context> should match

{"kind": "Component","apiVersion": "odo.dev/v1alpha1","metadata": {"name": "cmp-git","namespace": "` + project + 
`","creationTimestamp": null},"spec":{"app": "testing","type":"nodejs","source": "https://github.com/openshift/nodejs-
ex","sourceType": "git","urls": {"kind": "List", "apiVersion": "odo.dev/v1alpha1", "metadata": {}, "items": [{"kind": "url", 
"apiVersion": "odo.dev/v1alpha1", "metadata": {"name": "url-1", "creationTimestamp": null}, "spec": {"port": 8080, "secure": 
false, "kind": "route"}, "status": {"state": "Not Pushed"}}, {"kind": "url", "apiVersion": "odo.dev/v1alpha1", "metadata": {"name": 
"url-2", "creationTimestamp": null}, "spec": {"port": 8080, "secure": false,"kind": "route"}, "status": {"state": "Not 
Pushed"}}]},"storages": {"kind": "List", "apiVersion": "odo.dev/v1alpha1", "metadata": {}, "items": [{"kind": "storage", 
"apiVersion": "odo.dev/v1alpha1", "metadata": {"name": "storage-1", "creationTimestamp": null}, "spec": {"size": "1Gi", "path": 
"/data1"}}]},"ports": ["8080/TCP"]},"status": {"state": "Not Pushed"}}

Any logs, error output, etc?

@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jul 7, 2020
@kadel
Copy link
Member

kadel commented Jul 8, 2020

/kind test
/area testing

@openshift-ci-robot openshift-ci-robot added kind/test area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering labels Jul 8, 2020
@prietyc123
Copy link
Contributor Author

It seems it works properly on linux and macOS but the issue is coming with windows platform only, where the "kind": "route" attribute is missing in json match. So I was not sure about the issue where it belongs to testing or something else. I will provide more info on this issue and will change the current label accordingly.

@kadel
Copy link
Member

kadel commented Jul 8, 2020

Couldn't it be just because the fields in JSON struct have a different order?

@kadel
Copy link
Member

kadel commented Jul 8, 2020

When JSON structs need to be matched it should be done using MatchJson (https://onsi.github.io/gomega/#matchjsonjson-interface)

So, Instead of Expect(ACTUAL).To(Equal(EXPECTED)) it should be Expect(ACTUAL).Should(MatchJSON(EXPECTED)).
This needs to be fixed in other places also.

@girishramnani
Copy link
Contributor

I can work on this

@girishramnani
Copy link
Contributor

opened a PR, please confirm @prietyc123 that it resolves the error on windows

@prietyc123
Copy link
Contributor Author

prietyc123 commented Jul 9, 2020

Couldn't it be just because the fields in JSON struct have a different order?

No, I have checked the JSON struct thoroughly and nowhere I found "kind": "route" attribute. So clearly its not order issue. Strange part is its only happening on windows and I am running on our PSI 3.11 cluster. Need a deeper debug to find this out why is it behaving so strange.

Instead of Expect(ACTUAL).To(Equal(EXPECTED)) it should be Expect(ACTUAL).Should(MatchJSON(EXPECTED)).

+1

@prietyc123
Copy link
Contributor Author

Even I found the same things happening with make test-cmd-url and tried running the steps manually on windows 3.11 cluster internal PSI.

> odo project create testjson
 V  Project 'testjson' is ready for use
 V  New project created and now using project: testjson

> odo create nodejs nodejs --app myapp --project testjson --git https://github.com/openshift/nodejs-ex
Validation
 V  Validating component [27ms]
Please use `odo push` command to create the component with source deployed
PS C:\Users\Admin\go\src\github.com\openshift\odo\testurl> odo url create myurl
 V  URL myurl created for component: nodejs

To apply the URL configuration changes, please use `odo push`

> odo push
Validation
 V  Checking component [17ms]

Configuration changes
 V  Initializing component
 V  Creating component [212ms]
 V  Triggering build from git [95ms]
 V  Waiting for build to finish [26s]
 V  Deploying component nodejs [7s]

Applying URL changes
 V  URL myurl: http://myurl-myapp-testjson.apps.ocp311.psiodo.net created

Pushing to component nodejs of type git
 V  Changes successfully pushed to component

> odo url list -o json
{
    "kind": "List",
    "apiVersion": "odo.dev/v1alpha1",
    "metadata": {},
    "items": [
        {
            "kind": "url",
            "apiVersion": "odo.dev/v1alpha1",
            "metadata": {
                "name": "myurl",
                "creationTimestamp": null
            },
            "spec": {
                "host": "myurl-myapp-testjson.apps.ocp311.psiodo.net",
                "protocol": "http",
                "port": 8080,
                "secure": false
            },
            "status": {
                "state": "Pushed"
            }
        }
    ]
}

But again the desired json still did not match in cmd_url_test and with some more spec. Problem is same with "kind": "route" attribute.

@prietyc123
Copy link
Contributor Author

prietyc123 commented Jul 9, 2020

opened a PR, please confirm @prietyc123 that it resolves the error on windows

@girishramnani But its not the problem with json struct different order. But still will check and update it.

@prietyc123
Copy link
Contributor Author

opened a PR, please confirm @prietyc123 that it resolves the error on windows

@girishramnani But its not the problem with json struct different order. But still will check and update it.

Commented the outcome #3523 (comment)

@prietyc123
Copy link
Contributor Author

On latest master it works fine, so closing the issue.

/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/testing Issues or PRs related to testing, Quality Assurance or Quality Engineering kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

4 participants