diff --git a/ee/spec/lib/remote_development/workspace_updates_processor_reconciliation_scenarios_spec.rb b/ee/spec/lib/remote_development/workspace_updates_processor_reconciliation_scenarios_spec.rb index f0681a46d17d813e547eb79486d28ba4f99f1325..faeb2bc9230e7c60782695bdfb82ed999ef5c743 100644 --- a/ee/spec/lib/remote_development/workspace_updates_processor_reconciliation_scenarios_spec.rb +++ b/ee/spec/lib/remote_development/workspace_updates_processor_reconciliation_scenarios_spec.rb @@ -3,7 +3,11 @@ require 'spec_helper' # TODO: This spec is dense and cryptic. Make it better. -RSpec.describe ::RemoteDevelopment::WorkspaceUpdatesProcessor, 'Reconciliation Scenarios', feature_category: :remote_development do +# TODO: Several scenarios from +# https://gitlab.com/gitlab-org/remote-development/gitlab-remote-development-docs/-/blob/main/doc/workspace-updates.md +# are not yet implemented - most or all are related to ERROR or FAILURE states, because the fixtures are not yet +# implemented. +RSpec.describe ::RemoteDevelopment::WorkspaceUpdatesProcessor, 'Partial Update Reconciliation Scenarios', feature_category: :remote_development do include_context 'with remote development shared fixtures' # See following documentation for details on all scenarios: @@ -30,21 +34,114 @@ # (initial_db_state + user_desired_state_update + agent_actual_state_updates). # Array entry is nil, or 2-tuple of symbols for [desired_state, actual_state]. - # rubocop:disable Layout/LineLength + # rubocop:disable Layout/LineLength, Style/TrailingCommaInArrayLiteral - for ease of reading and editing where(:initial_db_state, :user_desired_state_update, :agent_actual_state_updates, :response_expectations, :db_expectations) do [ # - # actual:Creating* / desired: Running -> actual: Running / desired: Running + # desired: Running / actual: Creating -> desired: Running / actual: Running [nil, :running, [nil, [:creating, :starting, false], [:starting, :running, true]], [[true, false], [false, true], [false, true]], [[:running, :creating], [:running, :creating], [:running, :starting], [:running, :running]]], # - # actual:Running / desired: Running -> actual: Stopped / desired: Stopped - [[:running, :running], :stopped, [nil, [:running, :stopping, true], [:stopping, :stopped, false]], [[true, true], [false, true], [false, true]], [[:running, :running], [:stopped, :running], [:stopped, :running], [:stopped, :stopping], [:stopped, :stopped]]] + # TODO: Fixture not yet implemented... + # desired: Running / actual: Creating -> desired: Running / actual: Failed + # [nil, :running, [nil, [:creating, :starting, false], [:starting, :failed, false]], [[true, false], [false, true], [false, true]], [[:running, :creating], [:running, :creating], [:running, :starting], [:running, :failed]]], + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Creating -> desired: Running / actual: Error + # + # desired: Running / actual: Running -> desired: Stopped / actual: Stopped + [[:running, :running], :stopped, [nil, [:running, :stopping, true], [:stopping, :stopped, false]], [[true, true], [false, true], [false, true]], [[:running, :running], [:stopped, :running], [:stopped, :running], [:stopped, :stopping], [:stopped, :stopped]]], + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Running -> desired: Stopped / actual: Failed + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Running -> desired: Stopped / actual: Error + # + # TODO: This should be able to pass once https://gitlab.com/gitlab-org/gitlab/-/issues/406565 is fixed. + # We may need to update ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb + # and/or ee/lib/remote_development/actual_state_calculator.rb to make this pass, but need to see how it + # behaves in reality after the above issue is fixed in order to make the fixtures reflect reality. + # desired: Running / actual: Running -> desired: Terminated / actual: Terminated + # [[:running, :running], :terminated, [nil, [:running, :terminated, false]], [[true, true], [false, true]], [[:running, :running], [:terminated, :running], [:terminated, :running], [:terminated, :terminated]]], + # + # desired: Stopped / actual: Stopped -> desired: Running / actual: Running + [[:stopped, :stopped], :running, [nil, [:stopped, :starting, false], [:starting, :running, true]], [[true, true], [false, true], [false, true]], [[:stopped, :stopped], [:running, :stopped], [:running, :stopped], [:running, :starting], [:running, :running]]], + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Running -> desired: Terminated / actual: Failed + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Running -> desired: Terminated / actual: Error + # + # desired: Stopped / actual: Stopped -> desired: Running / actual: Running + [[:stopped, :stopped], :running, [nil, [:stopped, :starting, false], [:starting, :running, true]], [[true, true], [false, true], [false, true]], [[:stopped, :stopped], [:running, :stopped], [:running, :stopped], [:running, :starting], [:running, :running]]], + # + # TODO: Fixture not yet implemented... + # desired: Stopped / actual: Stopped -> desired: Running / actual: Failed + # + # TODO: Fixture not yet implemented... + # desired: Stopped / actual: Stopped -> desired: Running / actual: Error + # + # TODO: This should be able to pass once https://gitlab.com/gitlab-org/gitlab/-/issues/406565 is fixed. + # We may need to update ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb + # and/or ee/lib/remote_development/actual_state_calculator.rb to make this pass, but need to see how it + # behaves in reality after the above issue is fixed in order to make the fixtures reflect reality. + # desired: Stopped / actual: Stopped -> desired: Terminated / actual: Terminated + # [[:stopped, :stopped], :terminated, [nil, [:stopped, :terminated, false]], [[true, true], [false, true]], [[:stopped, :stopped], [:terminated, :stopped], [:terminated, :stopped], [:terminated, :terminated]]], + # + # TODO: Fixture not yet implemented... + # desired: Stopped / actual: Stopped -> desired: Terminated / actual: Failed + # + # TODO: Fixture not yet implemented... + # desired: Stopped / actual: Stopped -> desired: Terminated / actual: Error + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Failed -> desired: Running / actual: Running + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Failed -> desired: Stopped / actual: Stopped + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Failed -> desired: Stopped / actual: Failed + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Failed -> desired: Stopped / actual: Error + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Failed -> desired: Terminated / actual: Terminated + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Failed -> desired: Terminated / actual: Failed + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Failed -> desired: Terminated / actual: Error + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Error -> desired: Stopped / actual: Error + # + # TODO: Fixture not yet implemented... + # desired: Running / actual: Error -> desired: Terminated / actual: Error + # + # TODO: Fixture not yet implemented... + # Agent reports update for a workspace and user has also updated desired state of the workspace + # + # Restarting a workspace + [[:running, :running], :restarting, [nil, [:running, :stopping, true], [:stopping, :stopped, false], [:stopped, :starting, false], [:starting, :running, true]], [[true, true], [false, true], [true, true], [false, true], [false, true]], [[:running, :running], [:restarting, :running], [:restarting, :running], [:restarting, :stopping], [:running, :stopped], [:running, :starting], [:running, :running]]], + # + # No update for workspace from agentk or from user + # ] end - # rubocop:enable Layout/LineLength + # rubocop:enable Layout/LineLength, Style/TrailingCommaInArrayLiteral with_them do it 'behaves as expected' do + # noinspection RubyResolve + expected_db_expectations_length = + (initial_db_state ? 1 : 0) + (user_desired_state_update ? 1 : 0) + agent_actual_state_updates.length + # noinspection RubyResolve + expect(db_expectations.length).to eq(expected_db_expectations_length) + workspace = nil db_expectation_index = 0 initial_resource_version = 1 diff --git a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb index d8384582c55236b25f6130672b5d9265477383e2..aeaa05a9090e9123cf9719c75132dd143338c649 100644 --- a/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb +++ b/ee/spec/support/shared_contexts/remote_development/remote_development_shared_contexts.rb @@ -137,7 +137,6 @@ def create_workspace_agent_info( <<~STATUS_YAML STATUS_YAML in [RemoteDevelopment::States::STOPPED, RemoteDevelopment::States::STARTING, _] - raise RemoteDevelopment::AgentInfoStatusFixtureNotImplementedError # There are multiple state transitions inside kubernetes # Fields like `replicas`, `unavailableReplicas` and `updatedReplicas` eventually become present <<~STATUS_YAML @@ -238,9 +237,10 @@ def create_workspace_agent_info( updatedReplicas: 1 STATUS_YAML else - raise 'Unsupported state transition passed for create_workspace_agent_info fixture creation: ' \ + msg = 'Unsupported state transition passed for create_workspace_agent_info fixture creation: ' \ "actual_state: #{previous_actual_state} -> #{current_actual_state}, " \ "existing_workspace: #{workspace_exists}" + raise RemoteDevelopment::AgentInfoStatusFixtureNotImplementedError, msg end # rubocop:enable Lint/UnreachableCode, Lint/DuplicateBranch