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

dev: make test target fails with overriden k8gb env vars #835

Closed
somaritane opened this issue Jan 18, 2022 · 0 comments · Fixed by #836
Closed

dev: make test target fails with overriden k8gb env vars #835

somaritane opened this issue Jan 18, 2022 · 0 comments · Fixed by #836
Labels
bug Something isn't working CI all the things related to gh actions or workflow

Comments

@somaritane
Copy link
Contributor

make test (unit test) build target fails when k8gb env vars are set in the shell
or .env file before running the target:

❯ EDGE_DNS_SERVER=8.8.8.8 make test
...
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -14,3 +14,3 @@
                                  },
                                - fallbackEdgeDNSServerName: (string) "",
                                + fallbackEdgeDNSServerName: (string) (len=7) "8.8.8.8",
                                  fallbackEdgeDNSServerPort: (int) 53,
                Test:           TestResolveConfigWithNegativeReconcileRequeueSecondsKey
...
❯ touch .env; make test
...
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -14,3 +14,3 @@
                                  },
                                - fallbackEdgeDNSServerName: (string) "",
                                + fallbackEdgeDNSServerName: (string) (len=7) "1.1.1.1",
                                  fallbackEdgeDNSServerPort: (int) 53,
                Test:           TestResolveConfigWithNegativeReconcileRequeueSecondsKey
...
echo "EDGE_DNS_SERVER=8.8.8.8" > .env; make test
...
                                Diff:
                                --- Expected
                                +++ Actual
                                @@ -14,3 +14,3 @@
                                  },
                                - fallbackEdgeDNSServerName: (string) "",
                                + fallbackEdgeDNSServerName: (string) (len=7) "8.8.8.8",
                                  fallbackEdgeDNSServerPort: (int) 53,
                Test:           TestResolveConfigWithZeroReconcileRequeueSecondsKey
...

IMHO unit testing environment should be isolated and not dependant on externally set variables.

@somaritane somaritane added bug Something isn't working CI all the things related to gh actions or workflow labels Jan 18, 2022
kuritka added a commit that referenced this issue Jan 18, 2022
resolves #835

EDGE_DNS_SERVER, EDGE_DNS_SERVER_PORT are deprecated.
We still keep them because of previous versions of k8gb and set
them explicitly in tests. We have several tests which are inspecting deprecated variables,
and count with them to be unset. Such tests creates and assert them if needed.

This patch ensures that the variables will not be set before running the tests.
I tested with all supported environment variables in `.env` file:

```env
RECONCILE_REQUEUE_SECONDS=dummy
CLUSTER_GEO_TAG=dummy
EXT_GSLB_CLUSTERS_GEO_TAGS=dummy
EXTDNS_ENABLED=dummy
EDGE_DNS_SERVERS=dummy
EDGE_DNS_ZONE=dummy
DNS_ZONE=dummy
INFOBLOX_GRID_HOST=dummy
INFOBLOX_WAPI_VERSION=dummy
INFOBLOX_WAPI_PORT=dummy
INFOBLOX_WAPI_USERNAME=dummy
INFOBLOX_WAPI_PASSWORD=dummy
INFOBLOX_HTTP_REQUEST_TIMEOUT=dummy
INFOBLOX_HTTP_POOL_CONNECTIONS=dummy
POD_NAMESPACE=dummy
COREDNS_EXPOSED=dummy
LOG_LEVEL=dummy
LOG_FORMAT=dummy
NO_COLOR=dummy
SPLIT_BRAIN_CHECK=dummy
METRICS_ADDRESS=dummy
EDGE_DNS_SERVER=8.8.8.8
EDGE_DNS_SERVER_PORT=53
```

Signed-off-by: kuritka <kuritka@gmail.com>
kuritka added a commit that referenced this issue Jan 18, 2022
resolves #835

EDGE_DNS_SERVER, EDGE_DNS_SERVER_PORT are deprecated.
We still keep them because of previous versions of k8gb and set
them explicitly in tests. We have several tests which are inspecting deprecated variables,
and count with them to be unset. Such tests creates and assert them if needed.

This patch ensures that the variables will not be set before running the tests.
I tested with all supported environment variables in `.env` file:

```env
RECONCILE_REQUEUE_SECONDS=dummy
CLUSTER_GEO_TAG=dummy
EXT_GSLB_CLUSTERS_GEO_TAGS=dummy
EXTDNS_ENABLED=dummy
EDGE_DNS_SERVERS=dummy
EDGE_DNS_ZONE=dummy
DNS_ZONE=dummy
INFOBLOX_GRID_HOST=dummy
INFOBLOX_WAPI_VERSION=dummy
INFOBLOX_WAPI_PORT=dummy
INFOBLOX_WAPI_USERNAME=dummy
INFOBLOX_WAPI_PASSWORD=dummy
INFOBLOX_HTTP_REQUEST_TIMEOUT=dummy
INFOBLOX_HTTP_POOL_CONNECTIONS=dummy
POD_NAMESPACE=dummy
COREDNS_EXPOSED=dummy
LOG_LEVEL=dummy
LOG_FORMAT=dummy
NO_COLOR=dummy
SPLIT_BRAIN_CHECK=dummy
METRICS_ADDRESS=dummy
EDGE_DNS_SERVER=8.8.8.8
EDGE_DNS_SERVER_PORT=53
```

Signed-off-by: kuritka <kuritka@gmail.com>
kuritka added a commit that referenced this issue Jan 18, 2022
resolves #835

EDGE_DNS_SERVER, EDGE_DNS_SERVER_PORT are deprecated.
We still keep them because of previous versions of k8gb and set
them explicitly in tests. We have several tests which are inspecting deprecated variables,
and count with them to be unset. Such tests creates and assert them if needed.

This patch ensures that the variables will not be set before running the tests.
I tested with all supported environment variables in `.env` file:

```env
RECONCILE_REQUEUE_SECONDS=dummy
CLUSTER_GEO_TAG=dummy
EXT_GSLB_CLUSTERS_GEO_TAGS=dummy
EXTDNS_ENABLED=dummy
EDGE_DNS_SERVERS=dummy
EDGE_DNS_ZONE=dummy
DNS_ZONE=dummy
INFOBLOX_GRID_HOST=dummy
INFOBLOX_WAPI_VERSION=dummy
INFOBLOX_WAPI_PORT=dummy
INFOBLOX_WAPI_USERNAME=dummy
INFOBLOX_WAPI_PASSWORD=dummy
INFOBLOX_HTTP_REQUEST_TIMEOUT=dummy
INFOBLOX_HTTP_POOL_CONNECTIONS=dummy
POD_NAMESPACE=dummy
COREDNS_EXPOSED=dummy
LOG_LEVEL=dummy
LOG_FORMAT=dummy
NO_COLOR=dummy
SPLIT_BRAIN_CHECK=dummy
METRICS_ADDRESS=dummy
EDGE_DNS_SERVER=8.8.8.8
EDGE_DNS_SERVER_PORT=53
```

Signed-off-by: kuritka <kuritka@gmail.com>
kuritka added a commit that referenced this issue Jan 18, 2022
resolves #835

EDGE_DNS_SERVER, EDGE_DNS_SERVER_PORT are deprecated.
We still keep them because of previous versions of k8gb and set
them explicitly in tests. We have several tests which are inspecting deprecated variables,
and count with them to be unset. Such tests creates and assert them if needed.

This patch ensures that the variables will not be set before running the tests.
I tested with all supported environment variables in `.env` file:

```env
RECONCILE_REQUEUE_SECONDS=dummy
CLUSTER_GEO_TAG=dummy
EXT_GSLB_CLUSTERS_GEO_TAGS=dummy
EXTDNS_ENABLED=dummy
EDGE_DNS_SERVERS=dummy
EDGE_DNS_ZONE=dummy
DNS_ZONE=dummy
INFOBLOX_GRID_HOST=dummy
INFOBLOX_WAPI_VERSION=dummy
INFOBLOX_WAPI_PORT=dummy
INFOBLOX_WAPI_USERNAME=dummy
INFOBLOX_WAPI_PASSWORD=dummy
INFOBLOX_HTTP_REQUEST_TIMEOUT=dummy
INFOBLOX_HTTP_POOL_CONNECTIONS=dummy
POD_NAMESPACE=dummy
COREDNS_EXPOSED=dummy
LOG_LEVEL=dummy
LOG_FORMAT=dummy
NO_COLOR=dummy
SPLIT_BRAIN_CHECK=dummy
METRICS_ADDRESS=dummy
EDGE_DNS_SERVER=8.8.8.8
EDGE_DNS_SERVER_PORT=53
```

Signed-off-by: kuritka <kuritka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CI all the things related to gh actions or workflow
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant