Skip to content

Commit

Permalink
fix: flaky tests (#168)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrparkers authored Oct 17, 2019
1 parent e2fd0cf commit 095aa37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 9 additions & 1 deletion keycloak/role.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keycloak

import (
"fmt"
"log"
)

type Role struct {
Expand Down Expand Up @@ -91,7 +92,14 @@ func (keycloakClient *KeycloakClient) UpdateRole(role *Role) error {
}

func (keycloakClient *KeycloakClient) DeleteRole(realmId, id string) error {
return keycloakClient.delete(fmt.Sprintf("/realms/%s/roles-by-id/%s", realmId, id), nil)
err := keycloakClient.delete(fmt.Sprintf("/realms/%s/roles-by-id/%s", realmId, id), nil)
if err != nil {
log.Printf("[DEBUG] Failed to delete role with id %s. Trying again...", id)

return keycloakClient.delete(fmt.Sprintf("/realms/%s/roles-by-id/%s", realmId, id), nil)
}

return nil
}

func (keycloakClient *KeycloakClient) AddCompositesToRole(role *Role, compositeRoles []*Role) error {
Expand Down
8 changes: 4 additions & 4 deletions provider/resource_keycloak_ldap_user_federation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ func TestAccKeycloakLdapUserFederation_basicUpdateAll(t *testing.T) {
firstValidatePasswordPolicy := randomBool()
firstPagination := randomBool()

firstConnectionTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1000, 3600000)))
secondConnectionTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1000, 3600000)))
firstReadTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1000, 3600000)))
secondReadTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1000, 3600000)))
firstConnectionTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1, 3600) * 1000))
secondConnectionTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1, 3600) * 1000))
firstReadTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1, 3600) * 1000))
secondReadTimeout, _ := keycloak.GetDurationStringFromMilliseconds(strconv.Itoa(acctest.RandIntRange(1, 3600) * 1000))

firstLdap := &keycloak.LdapUserFederation{
RealmId: realmName,
Expand Down

0 comments on commit 095aa37

Please # to comment.