feat: bootstrap official runner through SPIFFE facade
This commit is contained in:
@@ -17,8 +17,14 @@ type fakeBackend struct {
|
||||
deleted int
|
||||
}
|
||||
|
||||
type fakeBootstrap struct{}
|
||||
|
||||
func (fakeBootstrap) Environment(taskassignment.Assignment) (map[string]string, error) {
|
||||
return map[string]string{"CI_RUNNER_CAPABILITY": "capability"}, nil
|
||||
}
|
||||
|
||||
func (b *fakeBackend) Find(context.Context, string) (*Executor, error) { return b.executor, nil }
|
||||
func (b *fakeBackend) Create(_ context.Context, _ taskassignment.Assignment, _ Metadata) (*Executor, error) {
|
||||
func (b *fakeBackend) Create(_ context.Context, _ taskassignment.Assignment, _ LaunchSpec) (*Executor, error) {
|
||||
b.created++
|
||||
b.executor = &Executor{Name: "executor", IdentityTarget: "pod-uid", Phase: PhaseRunning}
|
||||
return b.executor, nil
|
||||
@@ -60,7 +66,7 @@ func assignment() taskassignment.Assignment {
|
||||
|
||||
func TestHandleRecoversExistingExecutorWithoutCreatingAnother(t *testing.T) {
|
||||
backend := &fakeBackend{executor: &Executor{Name: "existing", IdentityTarget: "uid", Phase: PhaseRunning}}
|
||||
worker := Worker{Backend: backend, Tasks: &fakeTasks{}}
|
||||
worker := Worker{Backend: backend, Tasks: &fakeTasks{}, Bootstrap: fakeBootstrap{}}
|
||||
|
||||
done, err := worker.Handle(context.Background(), assignment())
|
||||
if err != nil || done {
|
||||
@@ -73,7 +79,7 @@ func TestHandleRecoversExistingExecutorWithoutCreatingAnother(t *testing.T) {
|
||||
|
||||
func TestAcceptAcknowledgesAfterBackendAndIdentityAreDurable(t *testing.T) {
|
||||
backend := &fakeBackend{}
|
||||
worker := Worker{Backend: backend, Tasks: &fakeTasks{}}
|
||||
worker := Worker{Backend: backend, Tasks: &fakeTasks{}, Bootstrap: fakeBootstrap{}}
|
||||
|
||||
accepted, err := worker.Accept(context.Background(), assignment())
|
||||
if err != nil || !accepted {
|
||||
@@ -86,7 +92,7 @@ func TestAcceptAcknowledgesAfterBackendAndIdentityAreDurable(t *testing.T) {
|
||||
|
||||
func TestAcceptRetriesWhileBackendIdentityTargetIsUnavailable(t *testing.T) {
|
||||
backend := &fakeBackend{executor: &Executor{Name: "pending", Phase: PhasePending}}
|
||||
worker := Worker{Backend: backend, Tasks: &fakeTasks{}}
|
||||
worker := Worker{Backend: backend, Tasks: &fakeTasks{}, Bootstrap: fakeBootstrap{}}
|
||||
|
||||
accepted, err := worker.Accept(context.Background(), assignment())
|
||||
if err != nil || accepted {
|
||||
@@ -100,7 +106,7 @@ func TestAcceptRetriesWhileBackendIdentityTargetIsUnavailable(t *testing.T) {
|
||||
func TestHandleReportsBeforeCleanupAndBecomesRecoverable(t *testing.T) {
|
||||
backend := &fakeBackend{executor: &Executor{Name: "finished", IdentityTarget: "uid", Phase: PhaseSucceeded}}
|
||||
tasks := &fakeTasks{}
|
||||
worker := Worker{Backend: backend, Tasks: tasks}
|
||||
worker := Worker{Backend: backend, Tasks: tasks, Bootstrap: fakeBootstrap{}}
|
||||
|
||||
done, err := worker.Handle(context.Background(), assignment())
|
||||
if err != nil || !done {
|
||||
|
||||
Reference in New Issue
Block a user