Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
4ab78d0d
Commit
4ab78d0d
authored
8 years ago
by
Eric Chiang
Browse files
Options
Downloads
Patches
Plain Diff
storage/kubernetes: run transactional conformance tests
parent
5720ecf4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
storage/kubernetes/storage.go
+27
-16
27 additions, 16 deletions
storage/kubernetes/storage.go
storage/kubernetes/storage_test.go
+8
-2
8 additions, 2 deletions
storage/kubernetes/storage_test.go
with
35 additions
and
18 deletions
storage/kubernetes/storage.go
+
27
−
16
View file @
4ab78d0d
...
@@ -75,31 +75,42 @@ func (c *Config) open() (*client, error) {
...
@@ -75,31 +75,42 @@ func (c *Config) open() (*client, error) {
return
nil
,
fmt
.
Errorf
(
"create client: %v"
,
err
)
return
nil
,
fmt
.
Errorf
(
"create client: %v"
,
err
)
}
}
// Don't try to synchronize this because creating third party resources is not
// a synchronous event. Even after the API server returns a 200, it can still
// take several seconds for them to actually appear.
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
go
func
()
{
for
{
if
err
:=
cli
.
createThirdPartyResources
();
err
!=
nil
{
log
.
Printf
(
"failed creating third party resources: %v"
,
err
)
}
else
{
return
}
select
{
// Try to synchronously create the third party resources once. This doesn't mean
case
<-
ctx
.
Done
()
:
// they'll immediately be available, but ensures that the client will actually try
return
// once.
case
<-
time
.
After
(
30
*
time
.
Second
)
:
if
err
:=
cli
.
createThirdPartyResources
();
err
!=
nil
{
log
.
Printf
(
"failed creating third party resources: %v"
,
err
)
go
func
()
{
for
{
if
err
:=
cli
.
createThirdPartyResources
();
err
!=
nil
{
log
.
Printf
(
"failed creating third party resources: %v"
,
err
)
}
else
{
return
}
select
{
case
<-
ctx
.
Done
()
:
return
case
<-
time
.
After
(
30
*
time
.
Second
)
:
}
}
}
}
}
()
}
()
}
// If the client is closed, stop trying to create third party resources.
// If the client is closed, stop trying to create third party resources.
cli
.
cancel
=
cancel
cli
.
cancel
=
cancel
return
cli
,
nil
return
cli
,
nil
}
}
// createThirdPartyResources attempts to create the third party resources dex
// requires or identifies that they're already enabled.
//
// Creating a third party resource does not mean that they'll be immediately available.
//
// TODO(ericchiang): Provide an option to wait for the third party resources
// to actually be available.
func
(
cli
*
client
)
createThirdPartyResources
()
error
{
func
(
cli
*
client
)
createThirdPartyResources
()
error
{
for
_
,
r
:=
range
thirdPartyResources
{
for
_
,
r
:=
range
thirdPartyResources
{
err
:=
cli
.
postResource
(
"extensions/v1beta1"
,
""
,
"thirdpartyresources"
,
r
)
err
:=
cli
.
postResource
(
"extensions/v1beta1"
,
""
,
"thirdpartyresources"
,
r
)
...
...
This diff is collapsed.
Click to expand it.
storage/kubernetes/storage_test.go
+
8
−
2
View file @
4ab78d0d
package
kubernetes
package
kubernetes
import
(
import
(
"fmt"
"os"
"os"
"testing"
"testing"
...
@@ -78,7 +79,7 @@ func TestURLFor(t *testing.T) {
...
@@ -78,7 +79,7 @@ func TestURLFor(t *testing.T) {
func
TestStorage
(
t
*
testing
.
T
)
{
func
TestStorage
(
t
*
testing
.
T
)
{
client
:=
loadClient
(
t
)
client
:=
loadClient
(
t
)
conformance
.
RunTests
(
t
,
func
()
storage
.
Storage
{
newStorage
:=
func
()
storage
.
Storage
{
for
_
,
resource
:=
range
[]
string
{
for
_
,
resource
:=
range
[]
string
{
resourceAuthCode
,
resourceAuthCode
,
resourceAuthRequest
,
resourceAuthRequest
,
...
@@ -88,9 +89,14 @@ func TestStorage(t *testing.T) {
...
@@ -88,9 +89,14 @@ func TestStorage(t *testing.T) {
resourcePassword
,
resourcePassword
,
}
{
}
{
if
err
:=
client
.
deleteAll
(
resource
);
err
!=
nil
{
if
err
:=
client
.
deleteAll
(
resource
);
err
!=
nil
{
// Fatalf sometimes doesn't print the error message.
fmt
.
Fprintf
(
os
.
Stderr
,
"delete all %q failed: %v
\n
"
,
resource
,
err
)
t
.
Fatalf
(
"delete all %q failed: %v"
,
resource
,
err
)
t
.
Fatalf
(
"delete all %q failed: %v"
,
resource
,
err
)
}
}
}
}
return
client
return
client
})
}
conformance
.
RunTests
(
t
,
newStorage
)
conformance
.
RunTransactionTests
(
t
,
newStorage
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment