Skip to content

Commit

Permalink
Add Tenant Logging Tests (#2090)
Browse files Browse the repository at this point in the history
  • Loading branch information
cniackz committed Jun 6, 2022
1 parent 2918d39 commit 2d80638
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/jobs.yaml
Expand Up @@ -1536,7 +1536,7 @@ jobs:
go tool cover -func=all.out | grep total > tmp2
result=`cat tmp2 | awk 'END {print $3}'`
result=${result%\%}
threshold=51.50
threshold=51.90
echo "Result:"
echo "$result%"
if (( $(echo "$result >= $threshold" |bc -l) )); then
Expand Down
87 changes: 87 additions & 0 deletions operator-integration/tenant_test.go
Expand Up @@ -868,3 +868,90 @@ func TestLogout(t *testing.T) {
assert.Fail("authentication token not found in cookies response")
}
}

func EnableTenantLogging(namespace, tenant string) (*http.Response, error) {
/*
Description: Enable Tenant Logging
HTTP Verb: POST
*/
request, err := http.NewRequest(
"POST",
"http://localhost:9090/api/v1/namespaces/"+namespace+"/tenants/"+tenant+"/enable-logging",
nil,
)
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
if err != nil {
log.Println(err)
}
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}

func DisableTenantLogging(namespace, tenant string) (*http.Response, error) {
/*
Description: Disable Tenant Logging
*/
request, err := http.NewRequest(
"POST",
"http://localhost:9090/api/v1/namespaces/"+namespace+"/tenants/"+tenant+"/disable-logging",
nil,
)
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
if err != nil {
log.Println(err)
}
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}

func TestEnableTenantLogging(t *testing.T) {
// Vars
assert := assert.New(t)
namespace := "tenant-lite"
tenant := "storage-lite"

// Enable tenant logging
resp, err := EnableTenantLogging(namespace, tenant)
if err != nil {
log.Println(err)
return
}
if resp != nil {
assert.Equal(
200,
resp.StatusCode,
inspectHTTPResponse(resp),
)
}
}

func TestDisableTenantLogging(t *testing.T) {
// Vars
assert := assert.New(t)
namespace := "tenant-lite"
tenant := "storage-lite"

// Disable tenant logging
resp, err := DisableTenantLogging(namespace, tenant)
if err != nil {
log.Println(err)
return
}
if resp != nil {
assert.Equal(
200,
resp.StatusCode,
inspectHTTPResponse(resp),
)
}
}

0 comments on commit 2d80638

Please sign in to comment.